Open afiodorov opened 10 years ago
I'd suggest having a main game state, the whole one that the server stores, and functions to turn the gameState into a side specific one. (see below) gameState = { turn: side.light | side.dark, stage: stage.start | stage.move | stage.battle | stage.finish, pieces: [{name: "gandalf", position: [2,1]}, ...] } lightState { turn: side.light | side.dark, stage: stage.start | stage.move | stage.battle | stage.finish, friendlyPieces: [{name: "gandalf", position: [2,1]}, ...], enemyPieces: [[2,1],[0,0]] } Same for dark.
no quite the same, but on master in models/utils/gameutils.js
/**
gameState = { turn: side.light | side.dark, stage: stage.start | stage.move | stage.battle | stage.finish, pieces: [{name: "gandalf", position: {row:2, col:1}}, ...] } lightState { turn: side.light | side.dark, stage: stage.start | stage.move | stage.battle | stage.finish, friendlyPieces: [{name: "gandalf", position: {row: 2,col:1 } }, ...], enemyPieces: [{position:{row:2, col:1}}, {position:{row:0,col:0}},...] }
Board class implements update() method which receives an instance of gameState class.
GameState class: