提交 cfbf7490 编写于 作者: G Gabriele Cirulli

refactor code

上级 a831baed
...@@ -28,7 +28,7 @@ ...@@ -28,7 +28,7 @@
<div class="game-message"> <div class="game-message">
<p></p> <p></p>
<div class="lower"> <div class="lower">
<a class="keep-playing-button">Keep playing</a> <a class="keep-playing-button">Keep playing</a>
<a class="retry-button">Try again</a> <a class="retry-button">Try again</a>
</div> </div>
</div> </div>
......
...@@ -15,25 +15,23 @@ function GameManager(size, InputManager, Actuator, ScoreManager) { ...@@ -15,25 +15,23 @@ function GameManager(size, InputManager, Actuator, ScoreManager) {
// Restart the game // Restart the game
GameManager.prototype.restart = function () { GameManager.prototype.restart = function () {
this.actuator.restart(); this.actuator.continue();
this.setup(); this.setup();
}; };
// Keep playing after winning // Keep playing after winning
GameManager.prototype.keepPlaying = function () { GameManager.prototype.keepPlaying = function () {
this.keepPlaying = true; this.keepPlaying = true;
this.actuator.keepPlaying(); this.actuator.continue();
}; };
GameManager.prototype.isGameOver = function() { GameManager.prototype.isGameOver = function () {
if (this.over || (this.won && !this.keepPlaying) ) { if (this.over || (this.won && !this.keepPlaying)) {
return true; return true;
} } else {
else {
return false; return false;
} }
} };
// Set up the game // Set up the game
GameManager.prototype.setup = function () { GameManager.prototype.setup = function () {
......
...@@ -32,11 +32,8 @@ HTMLActuator.prototype.actuate = function (grid, metadata) { ...@@ -32,11 +32,8 @@ HTMLActuator.prototype.actuate = function (grid, metadata) {
}); });
}; };
HTMLActuator.prototype.restart = function () { // Continues the game (both restart and keep playing)
this.clearMessage(); HTMLActuator.prototype.continue = function () {
};
HTMLActuator.prototype.keepPlaying = function () {
this.clearMessage(); this.clearMessage();
}; };
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册