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
157c0baeea3b4dd016f355ee15f32058e123ef75
parent
58ed4737a2a6836b80666a2a13b1f4b5a27bfdd6
Author
Tobias Bengfort <tobias.bengfort@posteo.de>
Date
2025-01-16 06:04
link to next scenario on win

Diffstat

M src/index.js 3 +++
M src/template.js 10 +++++++++-

2 files changed, 12 insertions, 1 deletions


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

@@ -155,11 +155,14 @@ const onNavigate = function() {
  155   155             board: logic.setupBoard(),
  156   156         });
  157   157         state.game.sandbox = true;
   -1   158         state.scenario = null;
  158   159     } else if (path[0] === 'scenario') {
  159   160         const i = parseInt(path[1], 10);
  160   161         state.game = createGame(scenarios[i]);
   -1   162         state.scenario = i;
  161   163     } else {
  162   164         state.game = null;
   -1   165         state.scenario = null;
  163   166     }
  164   167     render();
  165   168 };

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

@@ -87,7 +87,15 @@ const renderMenu = function() {
   87    87 
   88    88 const renderWinState = function(state) {
   89    89     if (state.game.winState) {
   90    -1         return h('p', {}, 'You have won');
   -1    90         const items = ['You have won!'];
   -1    91         if (state.scenario !== null && state.scenario + 1 < scenarios.length) {
   -1    92             items.push(' ');
   -1    93             items.push(h('a', {
   -1    94                 'class': 'btn',
   -1    95                 'href': `#!scenario/${state.scenario + 1}`,
   -1    96             }, 'Next'));
   -1    97         }
   -1    98         return h('p', {}, items);
   91    99     } else if (state.game.winState === false) {
   92   100         return h('p', {}, 'You have lost');
   93   101     }