Skip to content

Commit

Permalink
feat: add option to change round when house cards evolve
Browse files Browse the repository at this point in the history
  • Loading branch information
Alec Jones committed Aug 26, 2023
1 parent fd8a481 commit fc59dfd
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 3 deletions.
2 changes: 1 addition & 1 deletion agot-bg-game-server/src/client/EntireGameComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ export default class EntireGameComponent extends Component<EntireGameComponentPr
placement="auto"
overlay={
<Tooltip id="evolution-active-tooltip">
From round <b>5</b> onwards, each house returns its alternative deck when the last house card has been played.
From round <b>{this.settings.houseCardsEvolutionRound}</b> onwards, each house returns its alternative deck when the last house card has been played.
</Tooltip>}
popperConfig={{ modifiers: [preventOverflow] }}
>
Expand Down
37 changes: 37 additions & 0 deletions agot-bg-game-server/src/client/GameSettingsComponent.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -364,6 +364,29 @@ export default class GameSettingsComponent extends Component<GameSettingsCompone
onChange={() => this.changeGameSettings(() => this.gameSettings.houseCardsEvolution = !this.gameSettings.houseCardsEvolution)}
/>
</Col>
{
this.gameSettings.houseCardsEvolution && (
<Col xs="12">
<div>
<select id="decks-evolution-setting-round"
value={this.gameSettings.houseCardsEvolutionRound}
onChange={(e) => this.onHouseCardsEvolutionRoundChange(e.target.value)}
style={{marginBottom: "8px"}}
>
<option key="2" value={2}>2</option>
<option key="3" value={3}>3</option>
<option key="4" value={4}>4</option>
<option key="5" value={5}>5</option>
<option key="6" value={6}>6</option>
<option key="7" value={7}>7</option>
<option key="8" value={8}>8</option>
<option key="9" value={9}>9</option>
<option key="10" value={10}>10</option>
</select>&nbsp;House Card Evolution Round
</div>
</Col>
)
}
{this.props.entireGame.isCustomBalancingOptionAvailable(this.gameSettings) && <Col xs="12">
<FormCheck
id="custom-balancing-setting"
Expand Down Expand Up @@ -861,6 +884,20 @@ export default class GameSettingsComponent extends Component<GameSettingsCompone
this.changeGameSettings();
}

onHouseCardsEvolutionRoundChange(newVal: string): void {
if (!this.canChangeGameSettings) {
return;
}

if (!this.gameSettings.houseCardsEvolution) {
return;
}

this.gameSettings.houseCardsEvolutionRound = parseInt(newVal);

this.changeGameSettings();
}

onRandomChosenHousesChange(): void {
if (!this.entireGame.gameSettings.randomChosenHouses && this.entireGame.gameSettings.randomHouses) {
return;
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 @@ -48,7 +48,7 @@ export default class EntireGame extends GameState<null, LobbyGameState | IngameG
lastMessageReceivedAt: Date | null = null;

@observable gameSettings: GameSettings = { setupId: "mother-of-dragons", playerCount: 8, pbem: true, onlyLive: false, startWhenFull: false, private: false,
addPortToTheEyrie: false, adwdHouseCards: false, asosHouseCards: false, houseCardsEvolution: false,
addPortToTheEyrie: false, adwdHouseCards: false, asosHouseCards: false, houseCardsEvolution: false, houseCardsEvolutionRound: 5,
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,
Expand Down Expand Up @@ -798,6 +798,7 @@ export interface GameSettings {
randomVassalAssignment: boolean;
customBalancing: boolean;
houseCardsEvolution: boolean;
houseCardsEvolutionRound: number;
initialLiveClock: number;
noPrivateChats: boolean;
tournamentMode: boolean;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -461,7 +461,7 @@ export default class PostCombatGameState extends GameState<
if (house.houseCards.values.every(hc => hc.state == HouseCardState.USED)) {
if (this.entireGame.gameSettings.houseCardsEvolution
&& house.laterHouseCards != null
&& this.combat.ingameGameState.game.turn >= 5) {
&& this.combat.ingameGameState.game.turn >= this.entireGame.gameSettings.houseCardsEvolutionRound) {

// We need to swap to the new deck now
this.game.previousPlayerHouseCards.set(house, new BetterMap());
Expand Down

0 comments on commit fc59dfd

Please sign in to comment.