mirror of
https://github.com/danog/2048.git
synced 2024-11-26 19:34:44 +01:00
refactor code
This commit is contained in:
parent
a831baed58
commit
cfbf74905f
@ -28,7 +28,7 @@
|
||||
<div class="game-message">
|
||||
<p></p>
|
||||
<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>
|
||||
</div>
|
||||
</div>
|
||||
|
@ -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 () {
|
||||
|
@ -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();
|
||||
};
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user