Commit 25c0f01f authored by Tobias Bengfort's avatar Tobias Bengfort
Browse files

add restart button

parent 7dc40938
......@@ -66,6 +66,11 @@ const createGame = function(scenario) {
tileLimit: scenario.tileLimit || Infinity,
turnCounter: 0,
},
restartGame: {
board: clone(scenario.board),
tileLimit: scenario.tileLimit || Infinity,
turnCounter: 0,
},
};
};
......@@ -117,6 +122,13 @@ on('click', '.js-reset', function(state) {
state.game.tileLimit = state.game.resetGame.tileLimit;
});
on('click', '.js-restart', function(state) {
state.game.playing = false;
state.game.board = clone(state.game.restartGame.board);
state.game.turnCounter = state.game.restartGame.turnCounter;
state.game.tileLimit = state.game.restartGame.tileLimit;
});
on('click', '.js-current-player', function(state) {
state.game.currentPlayer = (state.game.currentPlayer + 1) % constants.playerCount;
});
......
......@@ -39,6 +39,8 @@ const renderControls = function(state) {
' ',
h('button', {'class': 'js-reset'}, 'Reset'),
' ',
h('button', {'class': 'js-restart'}, 'Restart'),
' ',
h('button', {'class': `js-current-player fg-${state.game.currentPlayer}`}, 'Current Player'),
' ',
h('button', {'class': 'js-export'}, 'Export'),
......@@ -61,6 +63,8 @@ const renderControls = function(state) {
' ',
h('button', {'class': 'js-reset'}, 'Reset'),
' ',
h('button', {'class': 'js-restart'}, 'Restart'),
' ',
h('button', {'class': 'js-quit'}, 'Back'),
]);
}
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment