-
player
-
+
+
+
-
-
-
player
+
- vs -
+
+
+
)
diff --git a/webapp/src/context/app/reducer.js b/webapp/src/context/app/reducer.js
index 38b8775..287af2e 100644
--- a/webapp/src/context/app/reducer.js
+++ b/webapp/src/context/app/reducer.js
@@ -5,6 +5,9 @@ export const reducer = (state, action) => {
case "game-selector":
return GameSelector_update(state, action)
+ case "new-game":
+ return NewGame_update(state, action)
+
default:
console.warn("Unknown action.component", action.component)
return state
@@ -15,12 +18,18 @@ export const initialState = {
gameSelector: {
selectedGameProposal: null,
selectedActiveGame: null,
- selectedArchiveGame: null
- }
+ selectedArchiveGame: null,
+ },
+
+ newGame: {
+ whitePlayer: '',
+ blackPlayer: '',
+ },
+
}
function GameSelector_update(state, action) {
- if (Object.hasOwn(action, 'selectedGameProposal'))
+ if (Object.hasOwn(action, 'selectedGameProposal')) {
return {
...state,
gameSelector: {
@@ -28,8 +37,9 @@ function GameSelector_update(state, action) {
selectedGameProposal: action.selectedGameProposal
}
}
+ }
- if (Object.hasOwn(action, 'selectedActiveGame'))
+ if (Object.hasOwn(action, 'selectedActiveGame')) {
return {
...state,
gameSelector: {
@@ -37,8 +47,9 @@ function GameSelector_update(state, action) {
selectedActiveGame: action.selectedActiveGame
}
}
+ }
- if (Object.hasOwn(action, 'selectedArchiveGame'))
+ if (Object.hasOwn(action, 'selectedArchiveGame')) {
return {
...state,
gameSelector: {
@@ -46,6 +57,31 @@ function GameSelector_update(state, action) {
selectedArchiveGame: action.selectedArchiveGame
}
}
+ }
- console.warn(action.component, "- bad property")
+ console.warn(action.component, "- bad property")
}
+
+function NewGame_update(state, action) {
+ if (Object.hasOwn(action, 'whitePlayer')) {
+ return {
+ ...state,
+ newGame: {
+ ...state.newGame,
+ whitePlayer: action.whitePlayer
+ }
+ }
+ }
+
+ if (Object.hasOwn(action, 'blackPlayer')) {
+ return {
+ ...state,
+ newGame: {
+ ...state.newGame,
+ blackPlayer: action.blackPlayer
+ }
+ }
+ }
+
+ console.warn(action.component, "- bad property")
+}
\ No newline at end of file