Skip to content

Commit

Permalink
[*] Various TODOs
Browse files Browse the repository at this point in the history
  • Loading branch information
LeCodex committed Dec 20, 2024
1 parent bc26ef2 commit 0d9a766
Show file tree
Hide file tree
Showing 13 changed files with 91 additions and 79 deletions.
2 changes: 1 addition & 1 deletion src/oath/game/actions/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ export abstract class OathEffect<T = never> extends ModifiableAction {

abstract resolve(): void;

serialize(): Record<string, any> | undefined {
serialize() {
const data = {
...super.serialize(),
effect: this.constructor.name,
Expand Down
56 changes: 34 additions & 22 deletions src/oath/game/actions/effects.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { ExileBoard, OathPlayer } from "../player";
import { OathPower, WhenPlayed } from "../powers/powers";
import { Favor, OathResource, OathResourceType, ResourceCost, ResourcesAndWarbands, Secret } from "../resources";
import { Banner, FavorBank, PeoplesFavor } from "../banks";
import { OwnableObject, WithPowers } from "../interfaces";
import { OwnableObject, RecoverActionTarget, WithPowers } from "../interfaces";
import { OathGame } from "../game";
import { OathGameObject } from "../gameObject";
import { BuildOrRepairEdificeAction, ChooseNewCitizensAction, VowOathAction, RestAction, WakeAction, CampaignResult, SearchDiscardAction, SearchPlayOrDiscardAction, ChooseSuitsAction, ChooseNumberAction } from "./actions";
Expand Down Expand Up @@ -108,7 +108,7 @@ export class PutResourcesOnTargetEffect extends OathEffect<number> {
}
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
target: this.target?.id,
Expand Down Expand Up @@ -148,7 +148,7 @@ export class MoveResourcesToTargetEffect extends OathEffect<number> {
this.result = resources.length;
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
source: this.source?.key,
Expand Down Expand Up @@ -298,7 +298,7 @@ export class FlipSecretsEffect extends OathEffect<number> {
this.result = this.amount;
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
source: this.source?.name,
Expand Down Expand Up @@ -327,7 +327,7 @@ export class MoveWarbandsToEffect extends OathEffect<number> {
this.result = this.amount;
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
owner: this.owner.name,
Expand Down Expand Up @@ -355,7 +355,7 @@ export class MoveOwnWarbandsEffect extends PlayerEffect<number> {
this.result = this.amount;
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
owner: this.executor.name,
Expand Down Expand Up @@ -387,7 +387,7 @@ export class PutPawnAtSiteEffect extends PlayerEffect {
for (const relic of this.site.relics) new PeekAtCardEffect(this.executor, relic).doNext();
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
site: this.site.name
Expand Down Expand Up @@ -594,7 +594,7 @@ export class MoveWorldCardToAdvisersEffect extends OathEffect {
new CheckCapacityEffect(this.target, [this.target]).doNext();
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
card: this.card.name,
Expand Down Expand Up @@ -622,7 +622,7 @@ export class MoveDenizenToSiteEffect extends OathEffect {
new CheckCapacityEffect(this.executor || this.game.currentPlayer, [this.target]).doNext();
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
card: this.card.name,
Expand Down Expand Up @@ -660,7 +660,6 @@ export class CheckCapacityEffect extends PlayerEffect {
origins: Set<OathPlayer | Site>;
discardOptions?: DiscardOptions<any>;

// TODO: Interface for elements that house cards?
constructor(player: OathPlayer, origins: Iterable<OathPlayer | Site>, discardOptions?: DiscardOptions<any>) {
super(player);
this.origins = new Set(origins);
Expand Down Expand Up @@ -722,14 +721,27 @@ export class TakeOwnableObjectEffect extends OathEffect {
new ParentToTargetEffect(this.game, this.executor, [this.target]).doNext();
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
target: (this.target as unknown as ResourcesAndWarbands).name,
target: this.target.name,
};
}
}

export class RecoverTargetEffect extends PlayerEffect {
target: RecoverActionTarget;

constructor(player: OathPlayer, target: RecoverActionTarget) {
super(player);
this.target = target;
}

resolve(): void {
new TakeOwnableObjectEffect(this.game, this.player, this.target).doNext();
}
}

export class RollDiceEffect extends OathEffect<RollResult> {
die: typeof Die;
amount: number;
Expand All @@ -747,7 +759,7 @@ export class RollDiceEffect extends OathEffect<RollResult> {
this.result.roll(this.die, this.amount);
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
die: this.die.name,
Expand Down Expand Up @@ -807,7 +819,7 @@ export class PaySupplyEffect extends PlayerEffect<boolean> {
this.result = true;
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
amount: this.amount
Expand All @@ -829,7 +841,7 @@ export class GainSupplyEffect extends PlayerEffect {
this.executor.supply += this.amount;
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
amount: this.amount
Expand All @@ -850,7 +862,7 @@ export class ChangePhaseEffect extends OathEffect {
this.game.checkForOathkeeper();
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
phase: this.phase
Expand Down Expand Up @@ -949,7 +961,7 @@ export class PutDenizenIntoDispossessedEffect extends OathEffect {
this.game.dispossessed.add(this.denizen.key);
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
card: this.denizen.name
Expand All @@ -967,7 +979,7 @@ export class GetRandomCardFromDispossessed extends OathEffect<Denizen> {
return this.denizen;
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
card: this.denizen.name
Expand Down Expand Up @@ -995,7 +1007,7 @@ export class SetPeoplesFavorMobState extends OathEffect {
this.banner.isMob = this.state;
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
state: this.state
Expand Down Expand Up @@ -1125,7 +1137,7 @@ export class TakeReliquaryRelicEffect extends PlayerEffect {
new TakeOwnableObjectEffect(this.game, this.executor, this.relic).doNext();
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
relic: this.relic?.name
Expand Down Expand Up @@ -1178,7 +1190,7 @@ export class BuildEdificeFromDenizenEffect extends OathEffect {
new ParentToTargetEffect(this.game, this.executor, [this.denizen], site.region?.discard).doNext();
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
denizen: this.denizen.name,
Expand Down Expand Up @@ -1211,7 +1223,7 @@ export class FlipEdificeEffect extends OathEffect {
this.edifice.prune();
}

serialize(): Record<string, any> {
serialize() {
return {
...super.serialize(),
edifice: this.edifice.name,
Expand Down
4 changes: 2 additions & 2 deletions src/oath/game/banks.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { ChooseSuitsAction, RecoverAction, RecoverBannerPitchAction } from "./actions/actions";
import { RecoverActionTarget, CampaignActionTarget, WithPowers, OwnableObject } from "./interfaces";
import { TakeOwnableObjectEffect, SetPeoplesFavorMobState, ParentToTargetEffect, BurnResourcesEffect, MoveResourcesToTargetEffect } from "./actions/effects";
import { TakeOwnableObjectEffect, SetPeoplesFavorMobState, ParentToTargetEffect, BurnResourcesEffect, MoveResourcesToTargetEffect, RecoverTargetEffect } from "./actions/effects";
import { isEnumKey, OathSuit } from "./enums";
import { OathPlayer } from "./player";
import { PeoplesFavorSearch, PeoplesFavorWake, DarkestSecretPower } from "./powers/banners";
Expand Down Expand Up @@ -49,7 +49,7 @@ export abstract class Banner<T extends OathResource = OathResource> extends Cont
// Banner-specific logic
new ParentToTargetEffect(this.game, player, player.byClass(this.cls).max(amount), this).doNext();
this.handleRecovery(player);
new TakeOwnableObjectEffect(this.game, player, this).doNext();
new RecoverTargetEffect(player, this).doNext();
}

seize(player: OathPlayer) {
Expand Down
4 changes: 2 additions & 2 deletions src/oath/game/cards/cards.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { CampaignSeizeSiteAction, RecoverAction } from "../actions/actions";
import { RecoverActionTarget, WithPowers, AtSite, CampaignActionTarget, OwnableObject, HiddenInformation } from "../interfaces";
import { Region } from "../map";
import { DiscardCardEffect, FlipSecretsEffect, MoveOwnWarbandsEffect, MoveResourcesToTargetEffect, ParentToTargetEffect, PayCostToBankEffect, RevealCardEffect, TakeOwnableObjectEffect } from "../actions/effects";
import { DiscardCardEffect, FlipSecretsEffect, MoveOwnWarbandsEffect, MoveResourcesToTargetEffect, ParentToTargetEffect, PayCostToBankEffect, RecoverTargetEffect, RevealCardEffect, TakeOwnableObjectEffect } from "../actions/effects";
import { CardRestriction, OathSuit, OathType, OathTypeVisionName, PlayerColor, RegionKey } from "../enums";
import { Oath } from "../oaths";
import { OathPlayer } from "../player";
Expand Down Expand Up @@ -204,7 +204,7 @@ export class Relic extends OwnableCard implements RecoverActionTarget, CampaignA
const cost = this.site.recoverCost;
new PayCostToBankEffect(this.game, player, cost, this.site.recoverSuit).doNext(success => {
if (!success) throw cost.cannotPayError;
new TakeOwnableObjectEffect(this.game, player, this).doNext();
new RecoverTargetEffect(player, this).doNext();
})
}

Expand Down
6 changes: 3 additions & 3 deletions src/oath/game/interfaces.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,18 @@ export interface OwnableObject extends OathGameObject {
setOwner(player?: OathPlayer): void;
}

export function isOwnable(obj: object): obj is OwnableObject {
export function isOwnable(obj: OathGameObject): obj is OwnableObject {
return "owner" in obj;
}


export interface CampaignActionTarget extends WithOriginal {
export interface CampaignActionTarget extends OathGameObject {
defense: number;
force: ResourcesAndWarbands<any> | undefined;
seize(player: OathPlayer): void;
}

export interface RecoverActionTarget extends WithOriginal {
export interface RecoverActionTarget extends OathGameObject, OwnableObject {
canRecover(action: RecoverAction): boolean;
recover(player: OathPlayer): void;
}
Expand Down
11 changes: 5 additions & 6 deletions src/oath/game/powers/denizens/arcane.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
import { CampaignAttackAction, CampaignDefenseAction, TakeFavorFromBankAction, TradeAction, TravelAction, MakeDecisionAction, RestAction, ChooseCardsAction, SearchPlayOrDiscardAction, ChoosePlayersAction, ChooseSitesAction, ChooseNumberAction, SearchAction, KillWarbandsOnTargetAction, MusterAction, RecoverAction, RecoverBannerPitchAction, ChooseTsAction, ChooseRnWsAction } from "../../actions/actions";
import { CampaignAttackAction, CampaignDefenseAction, TakeFavorFromBankAction, TradeAction, TravelAction, MakeDecisionAction, RestAction, ChooseCardsAction, SearchPlayOrDiscardAction, ChoosePlayersAction, ChooseSitesAction, ChooseNumberAction, SearchAction, KillWarbandsOnTargetAction, MusterAction, RecoverBannerPitchAction, ChooseRnWsAction } from "../../actions/actions";
import { InvalidActionResolution } from "../../actions/base";
import { Conspiracy, Denizen, Edifice, Relic, Site, WorldCard } from "../../cards/cards";
import { DiscardOptions } from "../../cards/decks";
import { AttackDie, DefenseDie, DieSymbol, RollResult } from "../../dice";
import { RegionDiscardEffect, PutResourcesOnTargetEffect, RollDiceEffect, BecomeCitizenEffect, DiscardCardEffect, PeekAtCardEffect, MoveResourcesToTargetEffect, PutDenizenIntoDispossessedEffect, GetRandomCardFromDispossessed, MoveWorldCardToAdvisersEffect, ParentToTargetEffect, BurnResourcesEffect } from "../../actions/effects";
import { RegionDiscardEffect, PutResourcesOnTargetEffect, RollDiceEffect, BecomeCitizenEffect, DiscardCardEffect, PeekAtCardEffect, MoveResourcesToTargetEffect, PutDenizenIntoDispossessedEffect, GetRandomCardFromDispossessed, MoveWorldCardToAdvisersEffect, ParentToTargetEffect, BurnResourcesEffect, RecoverTargetEffect } from "../../actions/effects";
import { BannerKey, OathSuit } from "../../enums";
import { ExileBoard, OathPlayer } from "../../player";
import { Favor, OathResourceType, ResourceCost, ResourcesAndWarbands, Secret } from "../../resources";
Expand Down Expand Up @@ -477,12 +477,12 @@ export class VowOfSilence extends AccessedActionModifier<Denizen, ParentToTarget
this.action.objects.delete(object);
}
}
export class VowOfSilenceRecover extends AccessedActionModifier<Denizen, RecoverAction> {
modifiedAction = RecoverAction;
export class VowOfSilenceRecover extends AccessedActionModifier<Denizen, RecoverTargetEffect> {
modifiedAction = RecoverTargetEffect;
mustUse = true;

applyBefore(): void {
if (this.action.targetProxy === this.gameProxy.banners.get(BannerKey.DarkestSecret))
if (this.action.target === this.gameProxy.banners.get(BannerKey.DarkestSecret)?.original)
throw new InvalidActionResolution("Cannot recover the Darkest Secret with the Vow of Silence");
}
}
Expand Down Expand Up @@ -536,7 +536,6 @@ export class GreatSpire extends AccessedActionModifier<Edifice, SearchAction> {
new PutDenizenIntoDispossessedEffect(this.game, this.action.player, card).doNext();
new PeekAtCardEffect(this.action.player, newCard).doNext();

// TODO: Put this in an effect
this.action.cards.delete(card);
this.action.cards.add(newCard);
});
Expand Down
10 changes: 5 additions & 5 deletions src/oath/game/powers/denizens/discord.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
import { MakeDecisionAction, ChooseCardsAction, ChooseRegionAction, TakeFavorFromBankAction, TakeResourceFromPlayerAction, ChooseSuitsAction, SearchPlayOrDiscardAction, MusterAction, TravelAction, CampaignAction, KillWarbandsOnTargetAction, CampaignAttackAction, CampaignEndAction, RecoverAction, TakeReliquaryRelicAction, ChooseNumberAction, StartBindingExchangeAction, FestivalDistrictOfferAction } from "../../actions/actions";
import { MakeDecisionAction, ChooseCardsAction, ChooseRegionAction, TakeFavorFromBankAction, TakeResourceFromPlayerAction, ChooseSuitsAction, SearchPlayOrDiscardAction, MusterAction, TravelAction, CampaignAction, KillWarbandsOnTargetAction, CampaignAttackAction, CampaignEndAction, TakeReliquaryRelicAction, ChooseNumberAction, StartBindingExchangeAction, FestivalDistrictOfferAction } from "../../actions/actions";
import { InvalidActionResolution, ModifiableAction } from "../../actions/base";
import { FavorBank, PeoplesFavor } from "../../banks";
import { Region } from "../../map";
import { Denizen, Edifice, OathCard, Relic, Site, Vision, WorldCard } from "../../cards/cards";
import { D6, DefenseDie } from "../../dice";
import { TakeOwnableObjectEffect, PutResourcesOnTargetEffect, MoveResourcesToTargetEffect, SetNewOathkeeperEffect, RollDiceEffect, DiscardCardEffect, BecomeCitizenEffect, PayCostToTargetEffect, PeekAtCardEffect, WinGameEffect, DrawFromDeckEffect, MoveWorldCardToAdvisersEffect, ParentToTargetEffect, BurnResourcesEffect } from "../../actions/effects";
import { TakeOwnableObjectEffect, PutResourcesOnTargetEffect, MoveResourcesToTargetEffect, SetNewOathkeeperEffect, RollDiceEffect, DiscardCardEffect, BecomeCitizenEffect, PayCostToTargetEffect, PeekAtCardEffect, WinGameEffect, DrawFromDeckEffect, MoveWorldCardToAdvisersEffect, ParentToTargetEffect, BurnResourcesEffect, RecoverTargetEffect } from "../../actions/effects";
import { BannerKey, OathSuit } from "../../enums";
import { ExileBoard, OathPlayer } from "../../player";
import { Favor, ResourceCost, Secret } from "../../resources";
Expand Down Expand Up @@ -516,12 +516,12 @@ export class VowOfRenewal extends ActionModifier<Denizen, BurnResourcesEffect> {
new PutResourcesOnTargetEffect(this.game, this.sourceProxy.ruler.original, Favor, this.action.result).doNext();
}
}
export class VowOfRenewalRecover extends AccessedActionModifier<Denizen, RecoverAction> {
modifiedAction = RecoverAction;
export class VowOfRenewalRecover extends AccessedActionModifier<Denizen, RecoverTargetEffect> {
modifiedAction = RecoverTargetEffect;
mustUse = true;

applyBefore(): void {
if (this.action.targetProxy === this.gameProxy.banners.get(BannerKey.PeoplesFavor))
if (this.action.target === this.gameProxy.banners.get(BannerKey.PeoplesFavor)?.original)
throw new InvalidActionResolution("Cannot recover the People's Favor with the Vow of Renewal");
}
}
Expand Down
11 changes: 5 additions & 6 deletions src/oath/game/powers/denizens/hearth.ts
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import { TradeAction, TakeResourceFromPlayerAction, TakeFavorFromBankAction, CampaignEndAction, MakeDecisionAction, CampaignAttackAction, RecoverAction, ChooseSuitsAction, ChooseCardsAction, MusterAction, SearchPlayOrDiscardAction, MayDiscardACardAction, SearchAction, SearchChooseAction, KillWarbandsOnTargetAction, TinkersFairOfferAction, StartBindingExchangeAction, DeedWriterOfferAction } from "../../actions/actions";
import { TradeAction, TakeResourceFromPlayerAction, TakeFavorFromBankAction, CampaignEndAction, MakeDecisionAction, CampaignAttackAction, ChooseSuitsAction, ChooseCardsAction, MusterAction, SearchPlayOrDiscardAction, MayDiscardACardAction, SearchAction, SearchChooseAction, KillWarbandsOnTargetAction, TinkersFairOfferAction, StartBindingExchangeAction, DeedWriterOfferAction } from "../../actions/actions";
import { ModifiableAction, InvalidActionResolution } from "../../actions/base";
import { Denizen, Edifice, Relic, WorldCard } from "../../cards/cards";
import { DieSymbol } from "../../dice";
import { PlayVisionEffect, PlayWorldCardEffect, PeekAtCardEffect, DiscardCardEffect, BecomeCitizenEffect, SetPeoplesFavorMobState, GainSupplyEffect, DrawFromDeckEffect, TakeOwnableObjectEffect, MoveDenizenToSiteEffect, ParentToTargetEffect, PutResourcesOnTargetEffect } from "../../actions/effects";
import { PlayVisionEffect, PlayWorldCardEffect, PeekAtCardEffect, DiscardCardEffect, BecomeCitizenEffect, SetPeoplesFavorMobState, GainSupplyEffect, DrawFromDeckEffect, TakeOwnableObjectEffect, MoveDenizenToSiteEffect, ParentToTargetEffect, PutResourcesOnTargetEffect, RecoverTargetEffect } from "../../actions/effects";
import { BannerKey, OathSuit, ALL_OATH_SUITS } from "../../enums";
import { WithPowers } from "../../interfaces";
import { Favor, ResourceCost, Secret } from "../../resources";
Expand Down Expand Up @@ -80,7 +80,6 @@ export class HeartsAndMinds extends DefenderBattlePlan<Denizen> {
cost = new ResourceCost([[Favor, 3]]);

applyWhenApplied(): boolean {
// TODO: Put this in an effect
this.action.campaignResult.successful = false;
this.action.next.doNext();

Expand Down Expand Up @@ -440,12 +439,12 @@ export class HallOfDebate extends ActionModifier<Edifice, CampaignAttackAction>
}
}

export class HallOfMockery extends ActionModifier<Edifice, RecoverAction> {
modifiedAction = RecoverAction;
export class HallOfMockery extends ActionModifier<Edifice, RecoverTargetEffect> {
modifiedAction = RecoverTargetEffect;
mustUse = true;

applyAfter(): void {
if (this.action.targetProxy === this.gameProxy.banners.get(BannerKey.PeoplesFavor))
if (this.action.target === this.gameProxy.banners.get(BannerKey.PeoplesFavor)?.original)
new SetPeoplesFavorMobState(this.game, undefined, true).doNext();
}
}
Loading

0 comments on commit 0d9a766

Please sign in to comment.