Skip to content

Commit

Permalink
Merge pull request #1818 from gereon77/introduce-random-draft-option
Browse files Browse the repository at this point in the history
Introduce Random draft additionally to Blind draft
  • Loading branch information
gereon77 authored Feb 7, 2024
2 parents d2bd61b + d7cda63 commit 6c60074
Show file tree
Hide file tree
Showing 5 changed files with 49 additions and 11 deletions.
16 changes: 16 additions & 0 deletions agot-bg-game-server/src/client/GameSettingsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -606,6 +606,22 @@ export default class GameSettingsComponent extends Component<GameSettingsCompone
onChange={() => this.changeGameSettings(() => this.gameSettings.thematicDraft = !this.gameSettings.thematicDraft)}
/>
</Col>
<Col xs="12">
<FormCheck
id="random-draft-setting"
type="switch"
label={
<OverlayTrigger overlay={
<Tooltip id="random-draft-tooltip">
Players receive random House cards and Influence positions.
Can be combined with <i>Limited Draft</i>.
</Tooltip>}>
<label htmlFor="random-draft-setting">Random Draft</label>
</OverlayTrigger>}
checked={this.gameSettings.randomDraft}
onChange={() => this.changeGameSettings(() => this.gameSettings.randomDraft = !this.gameSettings.randomDraft)}
/>
</Col>
<Col xs="12">
<FormCheck
id="blind-draft-setting"
Expand Down
3 changes: 2 additions & 1 deletion agot-bg-game-server/src/common/EntireGame.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ export default class EntireGame extends GameState<null, LobbyGameState | IngameG
addPortToTheEyrie: false, adwdHouseCards: false, asosHouseCards: false, houseCardsEvolution: false,
vassals: true, ironBank: true, seaOrderTokens: true, allowGiftingPowerTokens: true, randomVassalAssignment: false, customBalancing: false,
randomHouses: false, randomChosenHouses: false, tidesOfBattle: false, removeTob3: false, removeTobSkulls: false, limitTob2: false,
draftHouseCards: false, thematicDraft: false, limitedDraft: false, blindDraft: false,
draftHouseCards: false, thematicDraft: false, limitedDraft: false, randomDraft: false, blindDraft: false,
mixedWesterosDeck1: false, cokWesterosPhase: false, fogOfWar: false, victoryPointsCountNeededToWin: 7, loyaltyTokenCountNeededToWin: 7, endless: false, faceless: false,
useVassalPositions: false, precedingMustering: false, randomStartPositions: false, initialLiveClock: 60,
noPrivateChats: false, tournamentMode: false, fixedClock: false, holdVictoryPointsUntilEndOfRound: false
Expand Down Expand Up @@ -786,6 +786,7 @@ export interface GameSettings {
draftHouseCards: boolean;
thematicDraft: boolean;
limitedDraft: boolean;
randomDraft: boolean;
blindDraft: boolean;
endless: boolean;
useVassalPositions: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -195,7 +195,7 @@ export default class IngameGameState extends GameState<
beginDraftingHouseCards(): void {
if (this.entireGame.gameSettings.thematicDraft) {
this.setChildGameState(new ThematicDraftHouseCardsGameState(this)).firstStart();
} else if (this.entireGame.gameSettings.blindDraft) {
} else if (this.entireGame.gameSettings.blindDraft || this.entireGame.gameSettings.randomDraft) {
houseCardCombatStrengthAllocations.entries.forEach(([hcStrength, count]) => {
for(let i=0; i<count; i++) {
this.players.values.forEach(p => {
Expand Down Expand Up @@ -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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -238,6 +238,7 @@ export default class LobbyGameState extends GameState<EntireGame> {
settings.draftHouseCards = true;
settings.limitedDraft = false;
settings.blindDraft = false;
settings.randomDraft = false;
}

if (settings.draftHouseCards && !settings.limitedDraft) {
Expand Down Expand Up @@ -294,8 +295,9 @@ export default class LobbyGameState extends GameState<EntireGame> {
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;
Expand Down
8 changes: 8 additions & 0 deletions agot-bg-game-server/src/server/serializedGameMigrations.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
}
Expand Down

0 comments on commit 6c60074

Please sign in to comment.