diff --git a/agot-bg-game-server/src/client/GameSettingsComponent.tsx b/agot-bg-game-server/src/client/GameSettingsComponent.tsx index bad1d2d86..a0c7de77f 100644 --- a/agot-bg-game-server/src/client/GameSettingsComponent.tsx +++ b/agot-bg-game-server/src/client/GameSettingsComponent.tsx @@ -606,6 +606,22 @@ export default class GameSettingsComponent extends Component this.changeGameSettings(() => this.gameSettings.thematicDraft = !this.gameSettings.thematicDraft)} /> + + + Players receive random House cards and Influence positions. + Can be combined with Limited Draft. + }> + + } + checked={this.gameSettings.randomDraft} + onChange={() => this.changeGameSettings(() => this.gameSettings.randomDraft = !this.gameSettings.randomDraft)} + /> + { for(let i=0; i { @@ -259,15 +259,26 @@ export default class IngameGameState extends GameState< } 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 held by another house - ? dominanceHolders.length != this.game.influenceTracks.length + const uniqDominanceHolders = _.uniq(this.game.influenceTracks.map(track => this.game.getTokenHolder(track))); + + switch (this.players.size) { + case 0: + throw new Error("Games with 0 players cannot start"); + case 1: + // Ensure a single player can hold all 3 dominance tokens in a debug game: + return false; + case 2: // Ensure a player does not get all dominance tokens in 2p games - : dominanceHolders.length == 1; + // With Targaryen the other player can hold all 3 tokens. + return this.game.targaryen ? uniqDominanceHolders.length != 1 : uniqDominanceHolders.length != 2; + case 3: + // Ensure every dominance token is held by another house + // With Targaryen the other player can hold all 3 tokens. + return this.game.targaryen ? uniqDominanceHolders.length != 2 : uniqDominanceHolders.length != 3; + default: + // Ensure every dominance token is held by another house + return uniqDominanceHolders.length != 3; + } } log(data: GameLogData, resolvedAutomatically = false): void { diff --git a/agot-bg-game-server/src/common/lobby-game-state/LobbyGameState.ts b/agot-bg-game-server/src/common/lobby-game-state/LobbyGameState.ts index 09f6d80fa..e90efc50c 100644 --- a/agot-bg-game-server/src/common/lobby-game-state/LobbyGameState.ts +++ b/agot-bg-game-server/src/common/lobby-game-state/LobbyGameState.ts @@ -238,6 +238,7 @@ export default class LobbyGameState extends GameState { settings.draftHouseCards = true; settings.limitedDraft = false; settings.blindDraft = false; + settings.randomDraft = false; } if (settings.draftHouseCards && !settings.limitedDraft) { @@ -294,8 +295,9 @@ export default class LobbyGameState extends GameState { settings.asosHouseCards = false; } - if (settings.blindDraft) { + if (settings.blindDraft || settings.randomDraft) { settings.draftHouseCards = true; + settings.randomDraft = true; settings.thematicDraft = false; settings.adwdHouseCards = false; settings.asosHouseCards = false; diff --git a/agot-bg-game-server/src/server/serializedGameMigrations.ts b/agot-bg-game-server/src/server/serializedGameMigrations.ts index da469682f..b4b05e743 100644 --- a/agot-bg-game-server/src/server/serializedGameMigrations.ts +++ b/agot-bg-game-server/src/server/serializedGameMigrations.ts @@ -2166,6 +2166,14 @@ const serializedGameMigrations: {version: string; migrate: (serializeGamed: any) ingame.publicVisibleRegions = []; } + return serializedGame; + } + }, + { + version: "111", + migrate: (serializedGame: any) => { + serializedGame.gameSettings.randomDraft = serializedGame.gameSettings.blindDraft; + serializedGame.gameSettings.blindDraft = false; return serializedGame; } }