Commit 4c4090c7 authored by Tobias Bengfort's avatar Tobias Bengfort
Browse files

Gardening (Tabs!)

parent 4f04f2a8
Pipeline #1790 canceled with stage
......@@ -6,7 +6,7 @@ export default {
"title": "Survival 2",
"description": "Try and survive for 100 turns. You only have 5 Tiles.",
"board": scenBoard,
"tileLimit": 5,
"tileLimit": 5,
"winCondition": function(state) {
if (logic.compareBoards(scenBoard, state.game.board)) {
return false;
......
......@@ -6,9 +6,9 @@ export default {
"title": "Survival 3",
"description": "Try and survive for 100 turns. You only have 5 Tiles. You may only build in the top left corner.",
"board": scenBoard,
"tileLimit": 5,
"limitBuildSpaceA":{x:0,y:0},
"limitBuildSpaceB":{x:10,y:10},
"tileLimit": 5,
"limitBuildSpaceA": {x: 0, y: 0},
"limitBuildSpaceB": {x: 10, y: 10},
"winCondition": function(state) {
if (logic.compareBoards(scenBoard, state.game.board)) {
return false;
......
......@@ -61,17 +61,20 @@ on('mousedown', '.board-cell', function(state, event) {
const x = Array.prototype.indexOf.call(row.children, this);
const y = Array.prototype.indexOf.call(board.children, row);
const currentPlayer = state.game.currentPlayer === constants.EMPTY ? constants.GAIA : state.game.currentPlayer;
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;
if (
(state.game.limitBuildSpaceA && state.game.limitBuildSpaceB) &&
(x < state.game.limitBuildSpaceA.x || x > state.game.limitBuildSpaceB.x || y < state.game.limitBuildSpaceA.y || y > state.game.limitBuildSpaceB.y)
) return;
if (state.game.board[y][x] === currentPlayer) {
state.game.board[y][x] = constants.EMPTY;
if (state.game.tileLimit != null) {
state.game.tileLimit ++;
}
if (state.game.tileLimit != null) {
state.game.tileLimit ++;
}
} else if (state.game.board[y][x] === constants.EMPTY) {
if (state.game.tileLimit != null) {
if (state.game.tileLimit<1) return;
state.game.tileLimit --;
}
if (state.game.tileLimit) {
if (state.game.tileLimit < 1) return;
state.game.tileLimit -= 1;
}
state.game.board[y][x] = currentPlayer;
}
});
......
......@@ -6,6 +6,6 @@ import survive3 from '../scenarios/01_03survive.js';
export default [
gun,
survive,
survive2,
survive3,
survive2,
survive3,
];
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