diff options
author | Joffrey BION <joffrey.bion@gmail.com> | 2017-05-14 18:43:58 +0200 |
---|---|---|
committer | Joffrey BION <joffrey.bion@gmail.com> | 2017-05-14 18:43:58 +0200 |
commit | b6f54ed56121aa5435dd813c952b292b25b56bfb (patch) | |
tree | b4c88476393b031f00e9a1398f4f2a352f530341 /frontend/src/redux | |
parent | Fix typo in error subscription path (diff) | |
download | seven-wonders-b6f54ed56121aa5435dd813c952b292b25b56bfb.tar.gz seven-wonders-b6f54ed56121aa5435dd813c952b292b25b56bfb.tar.bz2 seven-wonders-b6f54ed56121aa5435dd813c952b292b25b56bfb.zip |
Add lobby saga
- Fix lobby's player list updates
- Fix lobby's player list order
- Add 'start game' button (not restricted to owner yet)
Resolves:
https://github.com/luxons/seven-wonders/issues/7
Diffstat (limited to 'frontend/src/redux')
-rw-r--r-- | frontend/src/redux/games.js | 4 | ||||
-rw-r--r-- | frontend/src/redux/players.js | 4 |
2 files changed, 6 insertions, 2 deletions
diff --git a/frontend/src/redux/games.js b/frontend/src/redux/games.js index 2b9a92a4..2986de07 100644 --- a/frontend/src/redux/games.js +++ b/frontend/src/redux/games.js @@ -4,14 +4,18 @@ export const types = { UPDATE_GAMES: 'GAME/UPDATE_GAMES', REQUEST_CREATE_GAME: 'GAME/REQUEST_CREATE_GAME', REQUEST_JOIN_GAME: 'GAME/REQUEST_JOIN_GAME', + REQUEST_START_GAME: 'GAME/REQUEST_JOIN_GAME', ENTER_LOBBY: 'GAME/ENTER_LOBBY', + ENTER_GAME: 'GAME/ENTER_GAME', } export const actions = { updateGames: (games) => ({ type: types.UPDATE_GAMES, games: Immutable(games) }), requestJoinGame: (gameId) => ({ type: types.REQUEST_JOIN_GAME, gameId }), requestCreateGame: (gameName) => ({ type: types.REQUEST_CREATE_GAME, gameName }), + requestStartGame: () => ({ type: types.REQUEST_START_GAME }), enterLobby: (lobby) => ({ type: types.ENTER_LOBBY, lobby: Immutable(lobby) }), + enterGame: () => ({ type: types.ENTER_GAME }), } const initialState = Immutable.from({ diff --git a/frontend/src/redux/players.js b/frontend/src/redux/players.js index 84e24796..2b530ca1 100644 --- a/frontend/src/redux/players.js +++ b/frontend/src/redux/players.js @@ -40,5 +40,5 @@ export default (state = initialState, action) => { } export const getCurrentPlayer = state => state.players.all && state.players.all[state.players.current] -export const getPlayers = (state, usernames) => Object.values(state.players.all) - .filter(p => usernames.indexOf(p.username) !== -1) +export const getPlayer = (state, username) => state.players.all[username] +export const getPlayers = (state, usernames) => usernames.map(u => getPlayer(state, u)) |