From b2faddff5a5dd1bf7af8bbe7f2df84f41e93ee70 Mon Sep 17 00:00:00 2001 From: gereon77 Date: Sat, 6 Jul 2024 11:09:59 +0200 Subject: [PATCH] Finalize Dense Fog --- agot-bg-game-server/data/baseGameData.json | 3 --- .../game-state-panel/PlaceOrdersComponent.tsx | 2 +- .../ingame-game-state/IngameGameState.ts | 11 ++++++++--- .../game-data-structure/createGame.ts | 18 ++++++++---------- .../westeros-card/DenseFogWesterosCardType.ts | 4 ++-- .../planningRestrictions.ts | 4 +--- .../westeros-card/westerosCardTypes.ts | 2 +- .../planning-game-state/PlanningGameState.ts | 1 - 8 files changed, 21 insertions(+), 24 deletions(-) diff --git a/agot-bg-game-server/data/baseGameData.json b/agot-bg-game-server/data/baseGameData.json index dfce98ee7..06d1c0ed3 100644 --- a/agot-bg-game-server/data/baseGameData.json +++ b/agot-bg-game-server/data/baseGameData.json @@ -1790,9 +1790,6 @@ { "type": "wildlings-attack", "quantity": 3 - }, - { - "type": "dense-fog" } ] ], diff --git a/agot-bg-game-server/src/client/game-state-panel/PlaceOrdersComponent.tsx b/agot-bg-game-server/src/client/game-state-panel/PlaceOrdersComponent.tsx index cbf3bae63..6477d1ef3 100644 --- a/agot-bg-game-server/src/client/game-state-panel/PlaceOrdersComponent.tsx +++ b/agot-bg-game-server/src/client/game-state-panel/PlaceOrdersComponent.tsx @@ -32,7 +32,7 @@ export default class PlaceOrdersComponent extends Component = new BetterMap(); @observable visibleRegionsPerPlayer: BetterMap = new BetterMap(); @observable publicVisibleRegions: Region[] = []; + unitVisibilityRange = 1; votes: BetterMap = new BetterMap(); @observable paused: Date | null = null; @@ -336,6 +337,7 @@ export default class IngameGameState extends GameState< }); if (this.fogOfWar) { + this.unitVisibilityRange = 1; this.publicVisibleRegions = []; this.entireGame.users.values.filter(u => u.connected).forEach(u => { this.entireGame.sendMessageToClients([u], { @@ -1658,7 +1660,7 @@ export default class IngameGameState extends GameState< return this.visibleRegionsPerPlayer.get(player); } - calculateVisibleRegionsForPlayer(player: Player | null, unitVisibilityRange = 1): Region[] { + calculateVisibleRegionsForPlayer(player: Player | null): Region[] { if (!this.fogOfWar || !player) { return []; } @@ -1676,7 +1678,7 @@ export default class IngameGameState extends GameState< const checkedRegions: Region[] = []; // Additionally we see regions adjacents to our regions with units - for(let i=0; i 1) { + if (this.unitVisibilityRange > 1) { regionsWithUnits.push(...additionalRegionsToCheck); regionsWithUnits = _.uniq(regionsWithUnits); } @@ -2306,6 +2308,7 @@ export default class IngameGameState extends GameState< ? this.visibleRegionsPerPlayer.entries.map(([p, regions]) => [p.user.id, regions.map(r => r.id)]) : this.visibleRegionsPerPlayer.entries.filter(([p, _regions]) => p.user == user).map(([p, regions]) => [p.user.id, regions.map(r => r.id)]), publicVisibleRegions: this.publicVisibleRegions.map(r => r.id), + unitVisibilityRange: this.unitVisibilityRange, oldPlayerIds: this.oldPlayerIds, replacerIds: this.replacerIds, timeoutPlayerIds: this.timeoutPlayerIds, @@ -2332,6 +2335,7 @@ export default class IngameGameState extends GameState< data.visibleRegionsPerPlayer.map(([uid, rids]) => [ingameGameState.players.get(entireGame.users.get(uid)), rids.map(rid => ingameGameState.world.regions.get(rid))]) ); ingameGameState.publicVisibleRegions = data.publicVisibleRegions.map(rid => ingameGameState.world.regions.get(rid)); + ingameGameState.unitVisibilityRange = data.unitVisibilityRange; ingameGameState.oldPlayerIds = data.oldPlayerIds; ingameGameState.replacerIds = data.replacerIds; ingameGameState.timeoutPlayerIds = data.timeoutPlayerIds; @@ -2378,6 +2382,7 @@ export interface SerializedIngameGameState { players: SerializedPlayer[]; visibleRegionsPerPlayer: [string, string[]][]; publicVisibleRegions: string[]; + unitVisibilityRange: number; oldPlayerIds: string[]; replacerIds: string[]; timeoutPlayerIds: string[]; diff --git a/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/createGame.ts b/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/createGame.ts index 0f81ed88b..eb03e0610 100644 --- a/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/createGame.ts +++ b/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/createGame.ts @@ -407,17 +407,9 @@ export default function createGame(ingame: IngameGameState, housesToCreate: stri // Load Westeros Cards let lastWesterosCardId = 0; - game.westerosDecks = baseGameData.westerosCards - .map(westerosDeckData => { + game.westerosDecks = baseGameData.westerosCards.map(westerosDeckData => { const cards: WesterosCard[] = []; - westerosDeckData - .filter((westerosCardData: WesterosCardData) => { - if (!gameSettings.fogOfWar) { - return westerosCardData.type !== "dense-fog" - } - return true - }) - .forEach((westerosCardData: WesterosCardData) => { + westerosDeckData.forEach((westerosCardData: WesterosCardData) => { const westerosCardType = westerosCardTypes.get(westerosCardData.type); const quantity = westerosCardData.quantity ? westerosCardData.quantity : 1; for (let i = 0;i < quantity;i++) { @@ -474,6 +466,12 @@ export default function createGame(ingame: IngameGameState, housesToCreate: stri game.westerosDecks[0] = cards; } + if (gameSettings.fogOfWar) { + const id = ++lastWesterosCardId; + game.westerosDecks[2].push(new WesterosCard(id, westerosCardTypes.get("dense-fog"))); + shuffleInPlace(game.westerosDecks[2]); + } + game.winterIsComingHappened = []; game.westerosDecks.forEach(_wd => game.winterIsComingHappened.push(false)); diff --git a/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/westeros-card/DenseFogWesterosCardType.ts b/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/westeros-card/DenseFogWesterosCardType.ts index 29c0dfeb5..79d8e2dbc 100644 --- a/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/westeros-card/DenseFogWesterosCardType.ts +++ b/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/westeros-card/DenseFogWesterosCardType.ts @@ -1,10 +1,10 @@ import WesterosCardType from "./WesterosCardType"; import WesterosGameState from "../../westeros-game-state/WesterosGameState"; -import {denseFog} from "./planning-restriction/planningRestrictions"; export default class DenseFogWesterosCardType extends WesterosCardType { execute(westeros: WesterosGameState): void { - westeros.planningRestrictions.push(denseFog); + westeros.ingame.unitVisibilityRange = 0; + westeros.ingame.updateVisibleRegions(true); westeros.onWesterosCardEnd(); } } \ No newline at end of file diff --git a/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/westeros-card/planning-restriction/planningRestrictions.ts b/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/westeros-card/planning-restriction/planningRestrictions.ts index a711d431d..15c43709d 100644 --- a/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/westeros-card/planning-restriction/planningRestrictions.ts +++ b/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/westeros-card/planning-restriction/planningRestrictions.ts @@ -13,15 +13,13 @@ export const noDefenseOrder = new PlanningRestriction("no-defense-order", orderT export const noSupportOrder = new PlanningRestriction("no-support-order", orderType => orderType instanceof SupportOrderType || orderType instanceof RaidSupportOrderType); export const noRaidOrder = new PlanningRestriction("no-raid-order", orderType => orderType instanceof RaidOrderType || orderType instanceof RaidSupportOrderType); export const noConsolidatePowerOrder = new PlanningRestriction("no-consolidate-power-order", orderType => orderType instanceof ConsolidatePowerOrderType); -export const denseFog = new PlanningRestriction("dense-fog", () => false); const planningRestrictions = new BetterMap([ [noMarchPlusOneOrder.id, noMarchPlusOneOrder], [noDefenseOrder.id, noDefenseOrder], [noSupportOrder.id, noSupportOrder], [noRaidOrder.id, noRaidOrder], - [noConsolidatePowerOrder.id, noConsolidatePowerOrder], - [denseFog.id, denseFog], + [noConsolidatePowerOrder.id, noConsolidatePowerOrder] ]); export default planningRestrictions; diff --git a/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/westeros-card/westerosCardTypes.ts b/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/westeros-card/westerosCardTypes.ts index 02b4ea1f5..64f4557c1 100644 --- a/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/westeros-card/westerosCardTypes.ts +++ b/agot-bg-game-server/src/common/ingame-game-state/game-data-structure/westeros-card/westerosCardTypes.ts @@ -60,7 +60,7 @@ export const stormOfSwords = new StormOfSwordsWesterosCardType("storm-of-swords" export const rainsOfAutumn = new RainsOfAutumnWesterosCardType("rains-of-autumn", "Rains\xa0of\xa0Autumn", "March +1 Orders cannot be played this Planning Phase.", "No\xa0M+1", 2); export const putToTheSword = new PutToTheSwordWesterosCardType("put-to-the-sword", "Put\xa0to\xa0the\xa0Sword", "The holder of the Valyrian Steel Blade chooses one of the following conditions for this Planning Phase: a) Defense Orders cannot be played b) March +1 Orders cannot be played, or c) no restrictions.", "VSB\xa0decides"); export const wildlingsAttack = new WildlingsAttackWesterosCardType("wildlings-attack", "Wildlings\xa0Attack", "The wildlings attack Westeros.", ""); -export const denseFog = new DenseFogWesterosCardType("dense-fog", "Dense\xa0Fog", "Visibility distance is reduced by one this round.", ""); +export const denseFog = new DenseFogWesterosCardType("dense-fog", "Dense\xa0Fog", "Visibility distance is reduced by one this round.", "", 2); export const domesticDisputes = new DomesticDisputesWesterosCardType("domestic-disputes", "Domestic\xa0Disputes", "The Targaryen player may discard 1 Power\xa0token to choose up to 4 other houses. Place 1 loyalty\xa0token on the home areas of those houses.", "Loyalty\xa0tokens in home areas", 0, ["storms-end"]); export const emptyPromises = new EmptyPromisesWesterosCardType("empty-promises", "Empty\xa0Promises", "The Targaryen player may discard 1 Power\xa0token to place a loyalty\xa0token on either: The Mountains of the Moon or Moat Cailin.", "Place loyalty\xa0tokens", 0, ["the-stony-shore"], ["the-mountains-of-the-moon", "moat-cailin"]); diff --git a/agot-bg-game-server/src/common/ingame-game-state/planning-game-state/PlanningGameState.ts b/agot-bg-game-server/src/common/ingame-game-state/planning-game-state/PlanningGameState.ts index 0c122a6d0..cbe49b7f1 100644 --- a/agot-bg-game-server/src/common/ingame-game-state/planning-game-state/PlanningGameState.ts +++ b/agot-bg-game-server/src/common/ingame-game-state/planning-game-state/PlanningGameState.ts @@ -121,7 +121,6 @@ export default class PlanningGameState extends GameState