Skip to content

Commit

Permalink
Ensure a house does not get 2 dominance tokens in blind draft
Browse files Browse the repository at this point in the history
  • Loading branch information
gereon77 committed Feb 6, 2024
1 parent 264a027 commit 9132cd2
Showing 1 changed file with 17 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,11 @@ export default class IngameGameState extends GameState<

this.game.draftableHouseCards.clear();

this.setInfluenceTrack(0, this.getRandomTrackOrder());
this.setInfluenceTrack(1, this.getRandomTrackOrder());
this.setInfluenceTrack(2, this.getRandomTrackOrder());
do {
this.setInfluenceTrack(0, this.getRandomTrackOrder());
this.setInfluenceTrack(1, this.getRandomTrackOrder());
this.setInfluenceTrack(2, this.getRandomTrackOrder());
} while (this.hasAnyHouseTooMuchDominanceTokens());

this.onDraftingFinish();
} else {
Expand Down Expand Up @@ -252,6 +254,18 @@ export default class IngameGameState extends GameState<
return _.concat(shuffleInPlace(playerHouses), shuffleInPlace(vassalHouses));
}

private hasAnyHouseTooMuchDominanceTokens(): boolean {
const dominanceHolders = _.uniqBy(this.game.influenceTracks.map(track => track[0]), h => h.id);
return this.players.size == 1
// Ensure a single player can hold all 3 dominance tokens in a debug game:
? false
: this.players.size > 2
// Ensure every domininance token is help by another house
? dominanceHolders.length != this.game.influenceTracks.length
// Ensure a player does not get all dominance tokens in 2p games
: dominanceHolders.length == 1;
}

log(data: GameLogData, resolvedAutomatically = false): void {
this.gameLogManager.log(data, resolvedAutomatically);
}
Expand Down

0 comments on commit 9132cd2

Please sign in to comment.