Fixed league/practice menus
This commit is contained in:
@@ -22,22 +22,24 @@ const initialState = {
|
||||
|
||||
const scoreReducer = (state, action) => {
|
||||
switch (action.type) {
|
||||
case ACTIONS.START_GAME:
|
||||
case ACTIONS.START_NEW_ROUND:
|
||||
return {
|
||||
...state,
|
||||
currentGame: {
|
||||
...initialState.currentGame,
|
||||
gameType: action.payload.gameType,
|
||||
isLeague: action.payload.isLeague,
|
||||
date: new Date().toISOString()
|
||||
}
|
||||
rounds: [],
|
||||
totalScore: 0,
|
||||
totalBullseyes: 0,
|
||||
dateStarted: new Date().toISOString(),
|
||||
},
|
||||
};
|
||||
|
||||
|
||||
case ACTIONS.ADD_ROUND:
|
||||
const updatedRounds = [...state.currentGame.rounds];
|
||||
updatedRounds[action.payload.roundIndex] = {
|
||||
arrows: action.payload.arrows,
|
||||
total: action.payload.arrows.reduce((sum, arrow) => sum + arrow.score, 0),
|
||||
total: action.payload.total,
|
||||
bullseyes: action.payload.arrows.filter(arrow => arrow.isBullseye).length
|
||||
};
|
||||
|
||||
@@ -51,7 +53,7 @@ const scoreReducer = (state, action) => {
|
||||
rounds: updatedRounds,
|
||||
totalScore,
|
||||
totalBullseyes
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
case ACTIONS.SAVE_GAME:
|
||||
|
||||
Reference in New Issue
Block a user