From 9b4b7bfaeba6ef1100faf17c9c6f2f5a199d39a1 Mon Sep 17 00:00:00 2001 From: gereon77 Date: Tue, 6 Feb 2024 21:33:09 +0100 Subject: [PATCH] Hide house cards for blind draft --- .../src/client/GameLogListComponent.tsx | 2 +- .../src/client/GameSettingsComponent.tsx | 3 +- .../src/client/HouseRowComponent.tsx | 71 +++++++++---------- .../src/client/IngameComponent.tsx | 2 +- .../ingame-game-state/IngameGameState.ts | 8 ++- .../game-data-structure/GameLogManager.ts | 18 ++++- .../game-data-structure/House.ts | 1 - .../src/server/GlobalServer.ts | 4 +- 8 files changed, 64 insertions(+), 45 deletions(-) diff --git a/agot-bg-game-server/src/client/GameLogListComponent.tsx b/agot-bg-game-server/src/client/GameLogListComponent.tsx index c25198033..d72475b14 100644 --- a/agot-bg-game-server/src/client/GameLogListComponent.tsx +++ b/agot-bg-game-server/src/client/GameLogListComponent.tsx @@ -79,7 +79,7 @@ export default class GameLogListComponent extends Component - Players receive random House cards and Influence positions. Can be combined with Limited Draft. + Players receive random House cards and Influence positions. House cards remain hidden throughout the game. + Can be combined with Limited Draft. }> } diff --git a/agot-bg-game-server/src/client/HouseRowComponent.tsx b/agot-bg-game-server/src/client/HouseRowComponent.tsx index 09425af3a..652026378 100644 --- a/agot-bg-game-server/src/client/HouseRowComponent.tsx +++ b/agot-bg-game-server/src/client/HouseRowComponent.tsx @@ -74,7 +74,7 @@ export default class HouseRowComponent extends Component render(): ReactNode { const isVassal = this.ingame.isVassalHouse(this.house); - const gameRunning = !this.ingame.isEnded && !this.ingame.isCancelled; + const gameRunning = !this.ingame.isEndedOrCancelled; // We crop the victory points to victoryCountsNeededToWin but in the UI we want to show if a player was able to gain more VPs const victoryPoints = this.ingame.entireGame.isFeastForCrows @@ -298,7 +298,15 @@ export default class HouseRowComponent extends Component )} - {this.renderHouseCards(isVassal)} + {!isVassal + ? this.renderPlayerHouseCards() + : _.sortBy(this.game.vassalHouseCards.values, hc => hc.combatStrength).map(hc => ( + + + + ))} {this.house.laterHouseCards != null && !isVassal && @@ -325,53 +333,44 @@ export default class HouseRowComponent extends Component ; } - private renderHouseCards(isVassal: boolean): ReactNode { - const showAllOtherPlayerHouseCards = !this.ingame.hasChildGameState(ThematicDraftHouseCardsGameState); + renderPlayerHouseCards(): ReactNode { + const showOnlyCardBacksForOtherHouses = this.ingame.hasChildGameState(ThematicDraftHouseCardsGameState) + || (this.ingame.entireGame.gameSettings.blindDraft && !this.ingame.isEndedOrCancelled); + const doesControlCurrentHouse = this.props.gameClient.doesControlHouse(this.house); + + const chooseHouseCards = this.ingame.hasChildGameState(ChooseHouseCardGameState) ? this.ingame.getChildGameState(ChooseHouseCardGameState) as ChooseHouseCardGameState : null; + const isCommandingVassalInCombat = chooseHouseCards?.combatGameState.isCommandingVassalInCombat(this.house) ?? false; - return !isVassal - ? (showAllOtherPlayerHouseCards || this.props.gameClient.doesControlHouse(this.house)) - ? this.renderPlayerHouseCards() - : null - : _.sortBy(this.game.vassalHouseCards.values, hc => hc.combatStrength).map(hc => ( - + if (isCommandingVassalInCombat) { + return _.range(0, 3).map(i => +
+ ); + } + + if (!showOnlyCardBacksForOtherHouses || doesControlCurrentHouse) { + return _.sortBy(this.house.houseCards.values, hc => hc.combatStrength).map(hc => ( + {hc.state == HouseCardState.AVAILABLE ? ( ) : ( )} )); - } - - renderPlayerHouseCards(): ReactNode { - const chooseHouseCards = this.ingame.hasChildGameState(ChooseHouseCardGameState) ? this.ingame.getChildGameState(ChooseHouseCardGameState) as ChooseHouseCardGameState : null; - const isCommandingVassalInCombat = chooseHouseCards?.combatGameState.isCommandingVassalInCombat(this.house) ?? false; + } - return isCommandingVassalInCombat - ? _.range(0, 3).map(i => -
- ) - : _.sortBy(this.house.houseCards.values, hc => hc.combatStrength).map(hc => ( - - {hc.state == HouseCardState.AVAILABLE ? ( - - ) : ( - - )} - - )); + return _.range(0, this.house.houseCards.size).map(i => +
+ ); } renderVassalDropDownItems(): ReactNode { diff --git a/agot-bg-game-server/src/client/IngameComponent.tsx b/agot-bg-game-server/src/client/IngameComponent.tsx index ccc233633..9e5ff444d 100644 --- a/agot-bg-game-server/src/client/IngameComponent.tsx +++ b/agot-bg-game-server/src/client/IngameComponent.tsx @@ -829,7 +829,7 @@ export default class IngameComponent extends Component { this.authenticatedPlayer.house.knowsNextWildlingCard; const nextWildlingCard = this.game.wildlingDeck.find(c => c.id == this.game.clientNextWildlingCardId); - const gameRunning = !this.ingame.isEnded && !this.ingame.isCancelled; + const gameRunning = !this.ingame.isEndedOrCancelled; const roundWarning = gameRunning && (this.game.maxTurns - this.game.turn) == 1; const roundCritical = gameRunning && (this.game.turn == this.game.maxTurns); diff --git a/agot-bg-game-server/src/common/ingame-game-state/IngameGameState.ts b/agot-bg-game-server/src/common/ingame-game-state/IngameGameState.ts index e07ee10f6..96b6221bd 100644 --- a/agot-bg-game-server/src/common/ingame-game-state/IngameGameState.ts +++ b/agot-bg-game-server/src/common/ingame-game-state/IngameGameState.ts @@ -114,6 +114,10 @@ export default class IngameGameState extends GameState< return this.childGameState instanceof CancelledGameState; } + get isEndedOrCancelled(): boolean { + return this.isEnded || this.isCancelled; + } + get fogOfWar(): boolean { return this.entireGame.gameSettings.fogOfWar; } @@ -1589,7 +1593,7 @@ export default class IngameGameState extends GameState< } getVisibleRegionsForPlayer(player: Player | null): Region[] { - if (!this.fogOfWar || this.isCancelled || this.isEnded) { + if (!this.fogOfWar || this.isEndedOrCancelled) { return this.world.regions.values; } @@ -1605,7 +1609,7 @@ export default class IngameGameState extends GameState< return []; } - if (this.isCancelled || this.isEnded) { + if (this.isEndedOrCancelled) { return this.world.regions.values; } diff --git a/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/GameLogManager.ts b/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/GameLogManager.ts index 32b877fa7..f7a481934 100644 --- a/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/GameLogManager.ts +++ b/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/GameLogManager.ts @@ -16,6 +16,13 @@ const fogOfWarBannedLogs = [ 'orders-revealed' ]; +const blindDraftBannedLogs = [ + 'orders-revealed', + 'house-cards-returned', + 'roose-bolton-house-cards-returned', + 'massing-on-the-milkwater-house-cards-back' +]; + export default class GameLogManager { ingameGameState: IngameGameState; @observable logs: GameLog[] = []; @@ -26,11 +33,20 @@ export default class GameLogManager { } private logFilter = (log: GameLog): boolean => { + if (this.ingameGameState.isEndedOrCancelled) return true; + return this.fogOfWarFilter(log) && this.blindDraftFilter(log); + } + + private fogOfWarFilter = (log: GameLog): boolean => { if (!this.ingameGameState.fogOfWar) return true; - if (this.ingameGameState.isEnded || this.ingameGameState.isCancelled) return true; return !fogOfWarBannedLogs.includes(log.data.type); } + private blindDraftFilter = (log: GameLog): boolean => { + if (!this.ingameGameState.entireGame.gameSettings.blindDraft) return true; + return !blindDraftBannedLogs.includes(log.data.type); + } + log(data: GameLogData, resolvedAutomatically = false): void { const time = new Date(); const log = {data, time, resolvedAutomatically}; diff --git a/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/House.ts b/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/House.ts index b48c9ad56..610794771 100644 --- a/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/House.ts +++ b/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/House.ts @@ -7,7 +7,6 @@ import Game from "./Game"; import { ObjectiveCard, SpecialObjectiveCard } from "./static-data-structure/ObjectiveCard"; import Player from "../Player"; import { objectiveCards, specialObjectiveCards } from "./static-data-structure/objectiveCards"; -import ThematicDraftHouseCardsGameState from "../thematic-draft-house-cards-game-state/ThematicDraftHouseCardsGameState"; export default class House { id: string; diff --git a/agot-bg-game-server/src/server/GlobalServer.ts b/agot-bg-game-server/src/server/GlobalServer.ts index d59489350..0062f81a8 100644 --- a/agot-bg-game-server/src/server/GlobalServer.ts +++ b/agot-bg-game-server/src/server/GlobalServer.ts @@ -260,7 +260,7 @@ export default class GlobalServer { } if (!entireGame.gameSettings.onlyLive || !entireGame.ingameGameState - || entireGame.ingameGameState.isEnded || entireGame.ingameGameState.isCancelled) { + || entireGame.ingameGameState.isEndedOrCancelled) { return; } @@ -553,7 +553,7 @@ export default class GlobalServer { if (entireGame.gameSettings.onlyLive && entireGame.ingameGameState) { const ingame = entireGame.ingameGameState; - if (!ingame.isEnded && !ingame.isCancelled) { + if (!ingame.isEndedOrCancelled) { // Do not unload running clock games until they are finished return; }