Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Introduce Random draft additionally to Blind draft #1818

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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