-
Notifications
You must be signed in to change notification settings - Fork 18
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
25 changed files
with
460 additions
and
358 deletions.
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,77 @@ | ||
import type BaseCard from '../../basecard'; | ||
import { AbilityTypes, Locations, CardTypes, EffectNames } from '../../Constants'; | ||
import EffectBuilder from '../EffectBuilder'; | ||
import EffectValue from '../EffectValue'; | ||
import GainAbility from '../GainAbility'; | ||
|
||
class CopyCard extends EffectValue { | ||
actions: Array<GainAbility>; | ||
reactions: Array<GainAbility>; | ||
persistentEffects: Array<any>; | ||
abilitiesForTargets = new WeakMap< | ||
BaseCard, | ||
{ | ||
actions: Array<GainAbility>; | ||
reactions: Array<GainAbility>; | ||
} | ||
>(); | ||
|
||
constructor(card: BaseCard) { | ||
super(card); | ||
this.actions = card.abilities.actions.map((action) => new GainAbility(AbilityTypes.Action, action)); | ||
this.reactions = card.abilities.reactions.map((ability) => new GainAbility(ability.abilityType, ability)); | ||
this.persistentEffects = card.abilities.persistentEffects.map((effect) => Object.assign({}, effect)); | ||
} | ||
|
||
apply(target: BaseCard) { | ||
this.abilitiesForTargets.set(target, { | ||
actions: this.actions.map((value) => { | ||
value.apply(target); | ||
return value.getValue(); | ||
}), | ||
reactions: this.reactions.map((value) => { | ||
value.apply(target); | ||
return value.getValue(); | ||
}) | ||
}); | ||
for (const effect of this.persistentEffects) { | ||
if ( | ||
effect.location === Locations.Any || | ||
(target.getType() === CardTypes.Character && effect.location === Locations.PlayArea) || | ||
(target.getType() === CardTypes.Holding && effect.location === Locations.Provinces) | ||
) { | ||
effect.ref = target.addEffectToEngine(effect); | ||
} | ||
} | ||
} | ||
|
||
unapply(target: BaseCard) { | ||
for (const value of this.getReactions(target)) { | ||
// @ts-ignore | ||
value.unregisterEvents(); | ||
} | ||
for (const effect of this.persistentEffects) { | ||
if (effect.ref) { | ||
target.removeEffectFromEngine(effect.ref); | ||
delete effect.ref; | ||
} | ||
} | ||
this.abilitiesForTargets.delete(target); | ||
} | ||
|
||
getActions(target: BaseCard) { | ||
return this.abilitiesForTargets.get(target)?.actions ?? []; | ||
} | ||
|
||
getReactions(target: BaseCard) { | ||
return this.abilitiesForTargets.get(target)?.reactions ?? []; | ||
} | ||
|
||
getPersistentEffects() { | ||
return this.persistentEffects; | ||
} | ||
} | ||
|
||
export function copyCard(character: BaseCard) { | ||
return EffectBuilder.card.static(EffectNames.CopyCharacter, new CopyCard(character)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
import { type AbilityTypes, EffectNames } from '../../Constants'; | ||
import type { | ||
ActionProps, | ||
PersistentEffectProps, | ||
TriggeredAbilityProps, | ||
TriggeredAbilityWhenProps | ||
} from '../../Interfaces'; | ||
import type CardEffect from '../CardEffect'; | ||
import EffectBuilder from '../EffectBuilder'; | ||
import GainAbility from '../GainAbility'; | ||
|
||
type Res = (game: any, source: any, props: any) => CardEffect; | ||
export function gainAbility(abilityType: AbilityTypes.Action, properties: ActionProps): Res; | ||
export function gainAbility(abilityType: AbilityTypes.DuelReaction, properties: TriggeredAbilityWhenProps): Res; | ||
export function gainAbility(abilityType: AbilityTypes.Persistent, properties: PersistentEffectProps): Res; | ||
export function gainAbility(abilityType: AbilityTypes.Reaction, properties: TriggeredAbilityProps): Res; | ||
export function gainAbility(abilityType: AbilityTypes.WouldInterrupt, properties: TriggeredAbilityProps): Res; | ||
export function gainAbility(abilityType: AbilityTypes.Interrupt, properties: TriggeredAbilityProps): Res; | ||
export function gainAbility(abilityType: AbilityTypes.ForcedReaction, properties: TriggeredAbilityProps): Res; | ||
export function gainAbility(abilityType: AbilityTypes.ForcedInterrupt, properties: TriggeredAbilityProps): Res; | ||
export function gainAbility( | ||
abilityType: AbilityTypes, | ||
properties: ActionProps | TriggeredAbilityWhenProps | TriggeredAbilityProps | PersistentEffectProps | ||
) { | ||
return EffectBuilder.card.static(EffectNames.GainAbility, new GainAbility(abilityType, properties)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
import AbilityDsl from '../../abilitydsl'; | ||
import { CardTypes, Locations, Players } from '../../Constants'; | ||
import DrawCard from '../../drawcard'; | ||
import type { TriggeredAbilityContext } from '../../TriggeredAbilityContext'; | ||
|
||
export default class MiyakosUndertaking extends DrawCard { | ||
static id = 'miyako-s-undertaking'; | ||
|
||
setupCardAbilities() { | ||
this.action({ | ||
title: 'Make a character a copy', | ||
condition: (context) => context.game.isDuringConflict(), | ||
targets: { | ||
cardToCopy: { | ||
cardType: CardTypes.Character, | ||
controller: Players.Opponent, | ||
location: Locations.DynastyDiscardPile, | ||
cardCondition: (card) => !card.isUnique() | ||
}, | ||
myCharacter: { | ||
dependsOn: 'cardToCopy', | ||
cardType: CardTypes.Character, | ||
controller: Players.Self, | ||
cardCondition: (card) => card.isParticipating(), | ||
gameAction: AbilityDsl.actions.cardLastingEffect((context) => ({ | ||
effect: AbilityDsl.effects.copyCard(context.targets.cardToCopy) | ||
})) | ||
} | ||
}, | ||
effect: 'make {1} into a copy of {2}', | ||
effectArgs: (context) => [context.targets.myCharacter, context.targets.cardToCopy] | ||
}); | ||
} | ||
|
||
canPlay(context: TriggeredAbilityContext) { | ||
return context.player.honor <= 6 && super.canPlay(context); | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.