- commit
- 7a8f320b9e8622960a478107aec027c526f7c025
- parent
- ab8c745e6885ef4f5f24d19a05f54ae8f56708ba
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2020-01-02 09:41
reset game to last manual change instead of last play
Diffstat
| M | src/index.js | 19 | +++++++++---------- |
1 files changed, 9 insertions, 10 deletions
diff --git a/src/index.js b/src/index.js
@@ -73,6 +73,10 @@ on('mousedown', '.board-cell', function(state, event) {
73 73 state.game.tileLimit -= 1;
74 74 state.game.board[y][x] = currentPlayer;
75 75 }
-1 76
-1 77 state.game.resetGame.board = clone(state.game.board);
-1 78 state.game.resetGame.turnCounter = state.game.turnCounter;
-1 79 state.game.resetGame.tileLimit = state.game.tileLimit;
76 80 });
77 81
78 82 on('click', '.js-next-gen', function(state) {
@@ -85,11 +89,6 @@ on('click', '.js-next-gen', function(state) {
85 89 });
86 90
87 91 on('click', '.js-play', function(state) {
88 -1 if (!state.game.playing) {
89 -1 state.game.gameOnPlay.board = clone(state.game.board);
90 -1 state.game.gameOnPlay.turnCounter = state.game.turnCounter;
91 -1 state.game.gameOnPlay.tileLimit = state.game.tileLimit;
92 -1 }
93 92 state.game.playing = !state.game.playing;
94 93 play();
95 94 });
@@ -98,9 +97,9 @@ on('click', '.js-reset', function(state) {
98 97 if (state.game.playing) {
99 98 return;
100 99 }
101 -1 state.game.board = clone(state.game.gameOnPlay.board);
102 -1 state.game.turnCounter = state.game.gameOnPlay.turnCounter;
103 -1 state.game.tileLimit = state.game.gameOnPlay.tileLimit;
-1 100 state.game.board = clone(state.game.resetGame.board);
-1 101 state.game.turnCounter = state.game.resetGame.turnCounter;
-1 102 state.game.tileLimit = state.game.resetGame.tileLimit;
104 103 });
105 104
106 105 on('click', '.js-current-player', function(state) {
@@ -130,7 +129,7 @@ on('click', '.js-menu-sandbox', function(state) {
130 129 steps: 0,
131 130 turnCounter: 0,
132 131 sandbox: true,
133 -1 gameOnPlay: {
-1 132 resetGame: {
134 133 board: logic.setupBoard(),
135 134 tileLimit: Infinity,
136 135 turnCounter: 0,
@@ -150,7 +149,7 @@ on('click', '.js-menu-scenario', function(state) {
150 149 playing: false,
151 150 steps: 0,
152 151 turnCounter: 0,
153 -1 gameOnPlay: {
-1 152 resetGame: {
154 153 board: clone(scenarios[i].board),
155 154 tileLimit: scenarios[i].tileLimit || Infinity,
156 155 turnCounter: 0,