summaryrefslogtreecommitdiff
path: root/frontend/src/models
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/models')
-rw-r--r--frontend/src/models/currentGame.js8
-rw-r--r--frontend/src/models/games.js84
-rw-r--r--frontend/src/models/players.js47
3 files changed, 0 insertions, 139 deletions
diff --git a/frontend/src/models/currentGame.js b/frontend/src/models/currentGame.js
deleted file mode 100644
index 398c65e8..00000000
--- a/frontend/src/models/currentGame.js
+++ /dev/null
@@ -1,8 +0,0 @@
-import { List } from 'immutable';
-import type { ApiPlayerTurnInfo, ApiTable } from '../api/model';
-
-export class CurrentGameState {
- readyUsernames: List<string> = new List();
- turnInfo: ApiPlayerTurnInfo | null = null;
- table: ApiTable | null = null;
-}
diff --git a/frontend/src/models/games.js b/frontend/src/models/games.js
deleted file mode 100644
index 85aab2df..00000000
--- a/frontend/src/models/games.js
+++ /dev/null
@@ -1,84 +0,0 @@
-import { List, Map, Record } from 'immutable';
-
-export type SettingsShape = {
- initialGold: number,
- lostPointsPerDefeat: number,
- timeLimitInSeconds: number,
- randomSeedForTests: number,
- discardedCardGold: number,
- defaultTradingCost: number,
- wonPointsPerVictoryPerAge: {
- "1": number,
- "2": number,
- "3": number
- },
- wonderSidePickMethod: "EACH_RANDOM" | "TODO",
- pointsPer3Gold: number
-};
-
-export type SettingsType = Record<SettingsShape>;
-
-const SettingsRecord: SettingsType = 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 {}
-
-export type GameState = 'LOBBY' | 'PLAYING';
-export type GameShape = {
- id: number,
- name: string | void,
- owner: string,
- players: List<string>,
- settings: SettingsType,
- state: GameState,
-};
-
-export type GameType = Record<GameShape>;
-export type GameMapType = Map<string, GameShape>;
-export type GameNormalMapType = { [string]: GameShape };
-
-const GameRecord: GameType = Record({
- id: -1,
- name: null,
- owner: 'anonymous',
- players: new List(),
- settings: new Settings(),
- state: 'LOBBY',
-});
-
-export class Game extends GameRecord {}
-
-export type GamesShape = {
- all: Map<Game>,
- current: string
-};
-
-export type GamesType = Record<GamesShape>;
-
-const GamesRecord: GamesType = Record({
- all: new Map(),
- current: null,
-});
-
-export class GamesState extends GamesRecord {
- addGame(g: GameShape) {
- const game: Game = new Game(g);
- return this.mergeDeepIn(['all', game.id], game);
- }
- addGames(games: GameNormalMapType) {
- return this.mergeIn(['all'], games.map((game: GameShape): Game => new Game(game)));
- }
-}
diff --git a/frontend/src/models/players.js b/frontend/src/models/players.js
deleted file mode 100644
index 587300f5..00000000
--- a/frontend/src/models/players.js
+++ /dev/null
@@ -1,47 +0,0 @@
-// @flow
-import { Map, Record } from 'immutable';
-
-export type PlayerShape = {
- username: string,
- displayName: string,
- index: number,
- ready: boolean,
- gameOwner: boolean,
- user: boolean,
-};
-export type PlayerType = Record<PlayerShape>;
-
-const PlayerRecord: PlayerType = Record({
- username: null,
- displayName: null,
- index: 0,
- ready: false,
- gameOwner: false,
- user: false,
-});
-// $FlowFixMe
-export class Player extends PlayerRecord {}
-
-export type PlayersShape = {
- all: Map<string, PlayerType>,
- current: string
-};
-export type PlayersType = Record<PlayersShape>;
-
-const PlayersRecord: PlayersType = Record({
- all: Map(),
- current: '',
-});
-// $FlowFixMe
-export class PlayerState extends PlayersRecord {
- addPlayer(p: PlayerShape) {
- const player: Player = new Player(p);
- const playerMap = Map({ [player.username]: player });
- return this.addPlayers(playerMap).set('current', player.username);
- }
-
- addPlayers(p: Map<string, PlayerShape>) {
- const players: Map<string, PlayerShape> = Map(p);
- return this.mergeIn(['all'], players.map((player: PlayerShape): Player => new Player(player)));
- }
-}
bgstack15