game-of-death

antagonistic game of life  https://xi.github.io/game-of-death/
git clone https://git.ce9e.org/game-of-death.git

commit
25c0f01fae595d1f369731fdab0177b54ca214eb
parent
7dc409383c1e8455fac3b28e0c5c32df7caef847
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2020-01-02 09:54
add restart button

Diffstat

M src/index.js 12 ++++++++++++
M src/template.js 4 ++++

2 files changed, 16 insertions, 0 deletions


diff --git a/src/index.js b/src/index.js

@@ -66,6 +66,11 @@ const createGame = function(scenario) {
   66    66             tileLimit: scenario.tileLimit || Infinity,
   67    67             turnCounter: 0,
   68    68         },
   -1    69         restartGame: {
   -1    70             board: clone(scenario.board),
   -1    71             tileLimit: scenario.tileLimit || Infinity,
   -1    72             turnCounter: 0,
   -1    73         },
   69    74     };
   70    75 };
   71    76 
@@ -117,6 +122,13 @@ on('click', '.js-reset', function(state) {
  117   122     state.game.tileLimit = state.game.resetGame.tileLimit;
  118   123 });
  119   124 
   -1   125 on('click', '.js-restart', function(state) {
   -1   126     state.game.playing = false;
   -1   127     state.game.board = clone(state.game.restartGame.board);
   -1   128     state.game.turnCounter = state.game.restartGame.turnCounter;
   -1   129     state.game.tileLimit = state.game.restartGame.tileLimit;
   -1   130 });
   -1   131 
  120   132 on('click', '.js-current-player', function(state) {
  121   133     state.game.currentPlayer = (state.game.currentPlayer + 1) % constants.playerCount;
  122   134 });

diff --git a/src/template.js b/src/template.js

@@ -39,6 +39,8 @@ const renderControls = function(state) {
   39    39             ' ',
   40    40             h('button', {'class': 'js-reset'}, 'Reset'),
   41    41             ' ',
   -1    42             h('button', {'class': 'js-restart'}, 'Restart'),
   -1    43             ' ',
   42    44             h('button', {'class': `js-current-player fg-${state.game.currentPlayer}`}, 'Current Player'),
   43    45             ' ',
   44    46             h('button', {'class': 'js-export'}, 'Export'),
@@ -61,6 +63,8 @@ const renderControls = function(state) {
   61    63             ' ',
   62    64             h('button', {'class': 'js-reset'}, 'Reset'),
   63    65             ' ',
   -1    66             h('button', {'class': 'js-restart'}, 'Restart'),
   -1    67             ' ',
   64    68             h('button', {'class': 'js-quit'}, 'Back'),
   65    69         ]);
   66    70     }