diff options
Diffstat (limited to 'frontend/src/redux/players.js')
-rw-r--r-- | frontend/src/redux/players.js | 35 |
1 files changed, 5 insertions, 30 deletions
diff --git a/frontend/src/redux/players.js b/frontend/src/redux/players.js index b9f37c8c..ce3c305f 100644 --- a/frontend/src/redux/players.js +++ b/frontend/src/redux/players.js @@ -1,34 +1,9 @@ -import { Map } from 'immutable'; -import { Player, PlayerShape, PlayerState } from '../models/players'; +import { List } from 'immutable'; +import { Player, PlayerState } from '../models/players'; +import type { Action } from './actions/all'; +import { types } from './actions/players'; -export const types = { - REQUEST_CHOOSE_USERNAME: 'USER/REQUEST_CHOOSE_USERNAME', - SET_CURRENT_PLAYER: 'USER/SET_CURRENT_PLAYER', - UPDATE_PLAYERS: 'USER/UPDATE_PLAYERS', -}; - -export type RequestChooseUsernameAction = { type: types.REQUEST_CHOOSE_USERNAME, username: string }; -export type SetCurrentPlayerAction = { type: types.SET_CURRENT_PLAYER, player: PlayerShape }; -export type UpdatePlayersAction = { type: types.UPDATE_PLAYERS, players: Map<string, PlayerShape> }; - -export type PlayerAction = RequestChooseUsernameAction | SetCurrentPlayerAction | UpdatePlayersAction; - -export const actions = { - chooseUsername: (username: string): RequestChooseUsernameAction => ({ - type: types.REQUEST_CHOOSE_USERNAME, - username, - }), - setCurrentPlayer: (player: PlayerShape): SetCurrentPlayerAction => ({ - type: types.SET_CURRENT_PLAYER, - player, - }), - updatePlayers: (players: Map<string, PlayerShape>): UpdatePlayersAction => ({ - type: types.UPDATE_PLAYERS, - players, - }), -}; - -export const playersReducer = (state = new PlayerState(), action: PlayerAction) => { +export const playersReducer = (state = new PlayerState(), action: Action) => { switch (action.type) { case types.SET_CURRENT_PLAYER: return state.addPlayer(action.player); |