Fix age fields

This commit is contained in:
Kenneth Allen 2021-10-15 17:39:57 +11:00
parent 5abba327ba
commit 9fc770d086

View File

@ -377,7 +377,7 @@ export function countPoints(state: State, playerIdx: number): number {
}))
}
function beginAge(state: State): State {
const age = (state.age ?? minAge - 1) + 1
const age = state.age === undefined ? 0 : state.age + 1
const deck = shuffle(buildDeck(age, state.players.length).map(s => s.name))
const handSize = Math.ceil(deck.length / state.players.length)
const hands = chunk(deck, handSize)
@ -453,7 +453,7 @@ function doTurn(state: State): State {
}
if (state.turnsRemaining === 0) {
state = endAge(state)
if (state.age === maxAge) {
if (state.age === numAges - 1) {
return {
...state,
stage: 'finished',