summaryrefslogtreecommitdiff
path: root/frontend/src/redux/players.js
diff options
context:
space:
mode:
Diffstat (limited to 'frontend/src/redux/players.js')
-rw-r--r--frontend/src/redux/players.js36
1 files changed, 36 insertions, 0 deletions
diff --git a/frontend/src/redux/players.js b/frontend/src/redux/players.js
new file mode 100644
index 00000000..e49d4bbf
--- /dev/null
+++ b/frontend/src/redux/players.js
@@ -0,0 +1,36 @@
+import { fromJS } from 'immutable'
+
+export const types = {
+ SET_USERNAME: 'USER/SET_USERNAME',
+ CHOOSE_USERNAME: 'USER/CHOOSE_USERNAME'
+}
+
+export const actions = {
+ setUsername: (username, displayName, index) => ({
+ type: types.SET_USERNAME,
+ username,
+ index,
+ displayName
+ }),
+ chooseUsername: (username) => ({ type: types.CHOOSE_USERNAME, username }),
+}
+
+
+const initialState = fromJS({
+ all: {},
+ current: null
+})
+
+export default (state = initialState, action) => {
+ switch (action.type) {
+ case types.SET_USERNAME:
+ const user = fromJS({
+ username: action.username,
+ displayName: action.displayName,
+ index: action.index,
+ })
+ return state.setIn(['all', user.get('username')], user).set('current', user.get('username'))
+ default:
+ return state
+ }
+}
bgstack15