diff options
Diffstat (limited to 'frontend/src/models/games.js')
-rw-r--r-- | frontend/src/models/games.js | 41 |
1 files changed, 41 insertions, 0 deletions
diff --git a/frontend/src/models/games.js b/frontend/src/models/games.js new file mode 100644 index 00000000..95bf8015 --- /dev/null +++ b/frontend/src/models/games.js @@ -0,0 +1,41 @@ +import { Record, Map, List } from 'immutable'; + +const SettingsRecord = Record({ + initialGold: 3, + lostPointsPerDefeat: 1, + timeLimitInSeconds: 45, + randomSeedForTests: -1, + discardedCardGold: 3, + defaultTradingCost: 2, + wonPointsPerVictoryPerAge: { + '1': 1, + '2': 3, + '3': 5, + }, + wonderSidePickMethod: 'EACH_RANDOM', + pointsPer3Gold: 1, +}); +export class Settings extends SettingsRecord {} + +const GameRecord = Record({ + id: -1, + name: null, + players: new List(), + settings: new Settings(), + state: 'LOBBY', +}); +export class Game extends GameRecord {} + +const GamesRecord = Record({ + all: new Map(), + current: '', +}); +export default class GamesState extends GamesRecord { + addGame(g) { + const game = new Game(g); + return this.mergeDeepIn(['all', game.id], game); + } + addGames(games) { + return this.mergeIn(['all'], games.map(game => new Game(game))); + } +} |