summaryrefslogtreecommitdiff
path: root/frontend/src/redux/actions/lobby.js
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2019-02-22 23:09:40 +0100
committerjbion <joffrey.bion@amadeus.com>2019-02-22 23:09:40 +0100
commit27990fcba5a47252df617db1bc98e2276b326e7e (patch)
tree7fba886ae83379ee9d76e6540efae7b0e7ce2a25 /frontend/src/redux/actions/lobby.js
parentFix websocket value when no message body is received (diff)
downloadseven-wonders-27990fcba5a47252df617db1bc98e2276b326e7e.tar.gz
seven-wonders-27990fcba5a47252df617db1bc98e2276b326e7e.tar.bz2
seven-wonders-27990fcba5a47252df617db1bc98e2276b326e7e.zip
Implement Game start
Diffstat (limited to 'frontend/src/redux/actions/lobby.js')
-rw-r--r--frontend/src/redux/actions/lobby.js35
1 files changed, 35 insertions, 0 deletions
diff --git a/frontend/src/redux/actions/lobby.js b/frontend/src/redux/actions/lobby.js
new file mode 100644
index 00000000..b3151a23
--- /dev/null
+++ b/frontend/src/redux/actions/lobby.js
@@ -0,0 +1,35 @@
+import { fromJS } from 'immutable';
+import type { GameMapType, GameNormalMapType } from '../../models/games';
+
+export const types = {
+ UPDATE_GAMES: 'GAMES/UPDATE_GAMES',
+ REQUEST_CREATE_GAME: 'GAMES/REQUEST_CREATE_GAME',
+ REQUEST_JOIN_GAME: 'GAMES/REQUEST_JOIN_GAME',
+ REQUEST_START_GAME: 'GAMES/REQUEST_START_GAME',
+ ENTER_LOBBY: 'GAMES/ENTER_LOBBY',
+ ENTER_GAME: 'GAMES/ENTER_GAME',
+};
+
+export type UpdateGamesAction = { type: 'GAMES/UPDATE_GAMES', games: GameMapType };
+export type RequestCreateGameAction = { type: 'GAMES/REQUEST_CREATE_GAME', gameName: string };
+export type RequestJoinGameAction = { type: 'GAMES/REQUEST_JOIN_GAME', gameId: number };
+export type RequestStartGameAction = { type: 'GAMES/REQUEST_START_GAME' };
+export type EnterLobbyAction = { type: 'GAMES/ENTER_LOBBY', gameId: number };
+export type EnterGameAction = { type: 'GAMES/ENTER_GAME', gameId: number };
+
+export type LobbyAction =
+ | UpdateGamesAction
+ | RequestCreateGameAction
+ | RequestJoinGameAction
+ | RequestStartGameAction
+ | EnterLobbyAction
+ | EnterGameAction;
+
+export const actions = {
+ updateGames: (games: GameNormalMapType): UpdateGamesAction => ({ type: types.UPDATE_GAMES, games: fromJS(games) }),
+ requestJoinGame: (gameId: number): RequestJoinGameAction => ({ type: types.REQUEST_JOIN_GAME, gameId }),
+ requestCreateGame: (gameName: string): RequestCreateGameAction => ({ type: types.REQUEST_CREATE_GAME, gameName }),
+ requestStartGame: (): RequestStartGameAction => ({ type: types.REQUEST_START_GAME }),
+ enterLobby: (gameId: number): EnterLobbyAction => ({ type: types.ENTER_LOBBY, gameId }),
+ enterGame: (gameId: number): EnterGameAction => ({ type: types.ENTER_GAME, gameId }),
+};
bgstack15