Skip to content

Commit 0666875

Browse files
committed
games: Support lowdrawing (only when bank is low or player has too many) in Splendor
1 parent ecdfc1b commit 0666875

1 file changed

Lines changed: 9 additions & 0 deletions

File tree

src/ps/games/splendor/index.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,15 @@ export class Splendor extends BaseGame<State> {
459459

460460
if (input.length > 3) return { success: false, error: "You can't take that many tokens!" as ToTranslate };
461461
if (input.length === 0) return { success: false, error: 'You must take at least 2 tokens!' as ToTranslate };
462+
if (input.length < 3 && input.every(({ count }) => count === 1)) {
463+
// Support people taking one-of-a-kind for _less_ than 3
464+
// Mainly matters when either the bank doesn't have enough types or the player can't take 3 more
465+
const typesInBank = TokenTypes.filter(tokenType => this.state.board.tokens[tokenType] > 0);
466+
const playerTokens = Object.values(this.state.playerData[this.turn!].tokens).sum();
467+
if (!(typesInBank.length < 3 || playerTokens + 3 > MAX_TOKEN_COUNT))
468+
return { success: false, error: 'You should probably be taking one token of three different types...' as ToTranslate };
469+
return { success: true, data: null };
470+
}
462471
if (input.length === 2) {
463472
return { success: false, error: 'You can only take 2 from 1 type or 1 each from 3 types!' as ToTranslate };
464473
}

0 commit comments

Comments
 (0)