diff options
Diffstat (limited to 'frontend/src/models/players.js')
-rw-r--r-- | frontend/src/models/players.js | 47 |
1 files changed, 0 insertions, 47 deletions
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))); - } -} |