summaryrefslogtreecommitdiff
path: root/frontend
diff options
context:
space:
mode:
authorjbion <joffrey.bion@amadeus.com>2019-02-24 02:02:23 +0100
committerjbion <joffrey.bion@amadeus.com>2019-02-24 02:02:23 +0100
commit219d49355c48eceaecd99fda804996e12fd1ac97 (patch)
treec67084d9a880a52b7559cb7bc4119dc7db08d981 /frontend
parentAdd prepare move actions (diff)
downloadseven-wonders-219d49355c48eceaecd99fda804996e12fd1ac97.tar.gz
seven-wonders-219d49355c48eceaecd99fda804996e12fd1ac97.tar.bz2
seven-wonders-219d49355c48eceaecd99fda804996e12fd1ac97.zip
Reset current turn when executed so that people can say ready again
Diffstat (limited to 'frontend')
-rw-r--r--frontend/src/models/currentGame.js5
-rw-r--r--frontend/src/redux/currentGame.js25
2 files changed, 19 insertions, 11 deletions
diff --git a/frontend/src/models/currentGame.js b/frontend/src/models/currentGame.js
index 6ff00858..398c65e8 100644
--- a/frontend/src/models/currentGame.js
+++ b/frontend/src/models/currentGame.js
@@ -1,7 +1,8 @@
import { List } from 'immutable';
-import type { ApiPlayerTurnInfo } from '../api/model';
+import type { ApiPlayerTurnInfo, ApiTable } from '../api/model';
export class CurrentGameState {
readyUsernames: List<string> = new List();
- turnInfo: ApiPlayerTurnInfo | null = null
+ turnInfo: ApiPlayerTurnInfo | null = null;
+ table: ApiTable | null = null;
}
diff --git a/frontend/src/redux/currentGame.js b/frontend/src/redux/currentGame.js
index f4174eca..e5659195 100644
--- a/frontend/src/redux/currentGame.js
+++ b/frontend/src/redux/currentGame.js
@@ -10,6 +10,7 @@ export function createCurrentGameReducer() {
return combineReducers({
readyUsernames: readyUsernamesReducer,
turnInfo: turnInfoReducer,
+ table: tableUpdatesReducer,
});
}
@@ -22,18 +23,24 @@ const readyUsernamesReducer = (state: List<string> = new List(), action: Action)
};
const turnInfoReducer = (state: ApiPlayerTurnInfo | null = null, action: Action) => {
- if (action.type === types.TURN_INFO_RECEIVED) {
- return action.turnInfo;
- } else {
- return state;
+ switch (action.type) {
+ case types.TURN_INFO_RECEIVED:
+ return action.turnInfo;
+ case types.TABLE_UPDATE_RECEIVED:
+ return null;
+ default:
+ return state;
}
};
-const tableUpdatesReducer = (state: ApiTable, action: Action) => {
- if (action.type === types.TABLE_UPDATE_RECEIVED) {
- return action.table;
- } else {
- return state;
+const tableUpdatesReducer = (state: ApiTable | null = null, action: Action) => {
+ switch (action.type) {
+ case types.TURN_INFO_RECEIVED:
+ return action.turnInfo.table;
+ case types.TABLE_UPDATE_RECEIVED:
+ return action.table;
+ default:
+ return state;
}
};
bgstack15