Commit 3755e241 authored by Tobias Bengfort's avatar Tobias Bengfort
Browse files

split calculateNextGen in board-logic and state-logic

parent 7f7beea4
......@@ -39,7 +39,7 @@ const play = function() {
state.game.playing = false;
}
}
logic.calculateNextGen(state);
logic.step(state);
render();
const speed = document.querySelector('[name="speed"]').value;
const timeout = 2000 * Math.pow(0.95, speed);
......
......@@ -11,9 +11,7 @@ export const setupBoard = function() {
return board;
};
export const calculateNextGen = function(state) {
state.game.turnCounter++;
const board = state.game.board;
export const calculateNextGen = function(board) {
const calcBoard = [];
// Calculate every player seperatly
......@@ -54,6 +52,11 @@ export const calculateNextGen = function(state) {
}
}
}
};
export const step = function(state) {
state.game.turnCounter++;
calculateNextGen(state.game.board);
// Scenariostuff
if (state.game.winCondition) {
......@@ -63,7 +66,7 @@ export const calculateNextGen = function(state) {
state.game.playing = false;
}
}
};
}
const getFriendlyNeighbors = function(board, x, y, p){
let count = 0;
......
Markdown is supported
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