add win condition
[2048.git] / js / html_actuator.js
blob:a/js/html_actuator.js -> blob:b/js/html_actuator.js
--- a/js/html_actuator.js
+++ b/js/html_actuator.js
@@ -22,9 +22,8 @@
 
     self.updateScore(metadata.score);
 
-    if (metadata.over) {
-      self.gameOver();
-    }
+    if (metadata.over) self.message(false); // You lose
+    if (metadata.won) self.message(true); // You win!
   });
 };
 
@@ -87,7 +86,8 @@
   }
 };
 
-HTMLActuator.prototype.gameOver = function () {
-  this.gameContainer.classList.add("game-over");
+HTMLActuator.prototype.message = function (won) {
+  var type = won ? "game-won" : "game-over";
+  this.gameContainer.classList.add(type);
 };
 

comments