From cfbf74905fa44e72a39d50701f96b614660ba445 Mon Sep 17 00:00:00 2001 From: Gabriele Cirulli Date: Fri, 14 Mar 2014 13:27:57 +0100 Subject: [PATCH] refactor code --- index.html | 2 +- js/game_manager.js | 14 ++++++-------- js/html_actuator.js | 7 ++----- 3 files changed, 9 insertions(+), 14 deletions(-) diff --git a/index.html b/index.html index 575c62a..25f49c9 100644 --- a/index.html +++ b/index.html @@ -28,7 +28,7 @@

diff --git a/js/game_manager.js b/js/game_manager.js index 95f75e5..8161f8e 100644 --- a/js/game_manager.js +++ b/js/game_manager.js @@ -15,25 +15,23 @@ function GameManager(size, InputManager, Actuator, ScoreManager) { // Restart the game GameManager.prototype.restart = function () { - this.actuator.restart(); + this.actuator.continue(); this.setup(); }; // Keep playing after winning GameManager.prototype.keepPlaying = function () { this.keepPlaying = true; - this.actuator.keepPlaying(); + this.actuator.continue(); }; -GameManager.prototype.isGameOver = function() { - if (this.over || (this.won && !this.keepPlaying) ) { +GameManager.prototype.isGameOver = function () { + if (this.over || (this.won && !this.keepPlaying)) { return true; - } - else { + } else { return false; } -} - +}; // Set up the game GameManager.prototype.setup = function () { diff --git a/js/html_actuator.js b/js/html_actuator.js index adfff59..25394ac 100644 --- a/js/html_actuator.js +++ b/js/html_actuator.js @@ -32,11 +32,8 @@ HTMLActuator.prototype.actuate = function (grid, metadata) { }); }; -HTMLActuator.prototype.restart = function () { - this.clearMessage(); -}; - -HTMLActuator.prototype.keepPlaying = function () { +// Continues the game (both restart and keep playing) +HTMLActuator.prototype.continue = function () { this.clearMessage(); };