Skip to content

Commit

Permalink
Finalize Dense Fog
Browse files Browse the repository at this point in the history
  • Loading branch information
gereon77 committed Jul 6, 2024
1 parent 3cbf12e commit a1ffc19
Show file tree
Hide file tree
Showing 8 changed files with 18 additions and 24 deletions.
3 changes: 0 additions & 3 deletions agot-bg-game-server/data/baseGameData.json
Original file line number Diff line number Diff line change
Expand Up @@ -1790,9 +1790,6 @@
{
"type": "wildlings-attack",
"quantity": 3
},
{
"type": "dense-fog"
}
]
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ export default class PlaceOrdersComponent extends Component<GameStateComponentPr
[noDefenseOrder, { deckId: 2, westerosCardType: stormOfSwords }],
[noSupportOrder, { deckId: 2, westerosCardType: webOfLies }],
[noRaidOrder, { deckId: 2, westerosCardType: seaOfStorms }],
[noConsolidatePowerOrder, { deckId: 2, westerosCardType: feastForCrows }],
[noConsolidatePowerOrder, { deckId: 2, westerosCardType: feastForCrows }]
]);

modifyRegionsOnMapCallback: any;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,7 @@ export default class IngameGameState extends GameState<
@observable ordersOnBoard: BetterMap<Region, Order> = new BetterMap();
@observable visibleRegionsPerPlayer: BetterMap<Player, Region[]> = new BetterMap();
@observable publicVisibleRegions: Region[] = [];
unitVisibilityRange = 1;

votes: BetterMap<string, Vote> = new BetterMap();
@observable paused: Date | null = null;
Expand Down Expand Up @@ -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], {
Expand Down Expand Up @@ -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 [];
}
Expand All @@ -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<unitVisibilityRange; i++) {
for(let i=0; i < this.unitVisibilityRange; i++) {
const additionalRegionsToCheck: Region[] = [];
for (let j=0; j<regionsWithUnits.length; j++) {
const region = regionsWithUnits[j];
Expand All @@ -1689,7 +1691,7 @@ export default class IngameGameState extends GameState<
}
}

if (unitVisibilityRange > 1) {
if (this.unitVisibilityRange > 1) {
regionsWithUnits.push(...additionalRegionsToCheck);
regionsWithUnits = _.uniq(regionsWithUnits);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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));

Expand Down
Original file line number Diff line number Diff line change
@@ -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();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, PlanningRestriction>([
[noMarchPlusOneOrder.id, noMarchPlusOneOrder],
[noDefenseOrder.id, noDefenseOrder],
[noSupportOrder.id, noSupportOrder],
[noRaidOrder.id, noRaidOrder],
[noConsolidatePowerOrder.id, noConsolidatePowerOrder],
[denseFog.id, denseFog],
[noConsolidatePowerOrder.id, noConsolidatePowerOrder]
]);

export default planningRestrictions;
Original file line number Diff line number Diff line change
Expand Up @@ -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"]);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ export default class PlanningGameState extends GameState<IngameGameState, PlaceO
]
)
);

planningGameState.childGameState = planningGameState.deserializeChildGameState(data.childGameState);

return planningGameState;
Expand Down

0 comments on commit a1ffc19

Please sign in to comment.