- commit
- 4c4090c77eb71e83242d07dbbc31aa85ce1dbe28
- parent
- 4f04f2a8c558380f767e2b7b10e32204df1269d4
- Author
- Tobias Bengfort <tobias.bengfort@posteo.de>
- Date
- 2019-10-31 06:17
Gardening (Tabs!)
Diffstat
| M | scenarios/01_02survive.js | 2 | +- |
| M | scenarios/01_03survive.js | 6 | +++--- |
| M | src/index.js | 19 | +++++++++++-------- |
| M | src/scenarios.js | 4 | ++-- |
4 files changed, 17 insertions, 14 deletions
diff --git a/scenarios/01_02survive.js b/scenarios/01_02survive.js
@@ -6,7 +6,7 @@ export default {
6 6 "title": "Survival 2",
7 7 "description": "Try and survive for 100 turns. You only have 5 Tiles.",
8 8 "board": scenBoard,
9 -1 "tileLimit": 5,
-1 9 "tileLimit": 5,
10 10 "winCondition": function(state) {
11 11 if (logic.compareBoards(scenBoard, state.game.board)) {
12 12 return false;
diff --git a/scenarios/01_03survive.js b/scenarios/01_03survive.js
@@ -6,9 +6,9 @@ export default {
6 6 "title": "Survival 3",
7 7 "description": "Try and survive for 100 turns. You only have 5 Tiles. You may only build in the top left corner.",
8 8 "board": scenBoard,
9 -1 "tileLimit": 5,
10 -1 "limitBuildSpaceA":{x:0,y:0},
11 -1 "limitBuildSpaceB":{x:10,y:10},
-1 9 "tileLimit": 5,
-1 10 "limitBuildSpaceA": {x: 0, y: 0},
-1 11 "limitBuildSpaceB": {x: 10, y: 10},
12 12 "winCondition": function(state) {
13 13 if (logic.compareBoards(scenBoard, state.game.board)) {
14 14 return false;
diff --git a/src/index.js b/src/index.js
@@ -61,17 +61,20 @@ on('mousedown', '.board-cell', function(state, event) {
61 61 const x = Array.prototype.indexOf.call(row.children, this);
62 62 const y = Array.prototype.indexOf.call(board.children, row);
63 63 const currentPlayer = state.game.currentPlayer === constants.EMPTY ? constants.GAIA : state.game.currentPlayer;
64 -1 if ((state.game.limitBuildSpaceA != null && state.game.limitBuildSpaceB != null) && (x < state.game.limitBuildSpaceA.x || x > state.game.limitBuildSpaceB.x || y < state.game.limitBuildSpaceA.y || y > state.game.limitBuildSpaceB.y)) return;
-1 64 if (
-1 65 (state.game.limitBuildSpaceA && state.game.limitBuildSpaceB) &&
-1 66 (x < state.game.limitBuildSpaceA.x || x > state.game.limitBuildSpaceB.x || y < state.game.limitBuildSpaceA.y || y > state.game.limitBuildSpaceB.y)
-1 67 ) return;
65 68 if (state.game.board[y][x] === currentPlayer) {
66 69 state.game.board[y][x] = constants.EMPTY;
67 -1 if (state.game.tileLimit != null) {
68 -1 state.game.tileLimit ++;
69 -1 }
-1 70 if (state.game.tileLimit != null) {
-1 71 state.game.tileLimit ++;
-1 72 }
70 73 } else if (state.game.board[y][x] === constants.EMPTY) {
71 -1 if (state.game.tileLimit != null) {
72 -1 if (state.game.tileLimit<1) return;
73 -1 state.game.tileLimit --;
74 -1 }
-1 74 if (state.game.tileLimit) {
-1 75 if (state.game.tileLimit < 1) return;
-1 76 state.game.tileLimit -= 1;
-1 77 }
75 78 state.game.board[y][x] = currentPlayer;
76 79 }
77 80 });
diff --git a/src/scenarios.js b/src/scenarios.js
@@ -6,6 +6,6 @@ import survive3 from '../scenarios/01_03survive.js'; 6 6 export default [ 7 7 gun, 8 8 survive,9 -1 survive2,10 -1 survive3,-1 9 survive2, -1 10 survive3, 11 11 ];