From f35ec6bfab809c5f9981a69ddc26877b13423f69 Mon Sep 17 00:00:00 2001 From: friarsol Date: Mon, 10 Apr 2023 22:00:14 -0400 Subject: [PATCH] Battles need to exile then cast. Transformed backside require SpellPermanent for this to work --- .../java/forge/game/ability/AbilityUtils.java | 5 ++++- .../game/ability/effects/PlayEffect.java | 21 +++++++++++-------- .../java/forge/game/card/CardFactoryUtil.java | 9 ++++++-- .../res/cardsfolder/b/benevolent_hydra.txt | 2 +- .../res/cardsfolder/k/kenku_artificer.txt | 2 +- .../rebalanced/a-kenku_artificer.txt | 2 +- ...vasion_of_kylem__valors_reach_tag_team.txt | 19 +++++++++++++++++ ...nvasion_of_zendikar__awakened_skyclave.txt | 1 + .../rw_3_2_warrior_symbiotic_attack.txt | 8 +++++++ 9 files changed, 54 insertions(+), 15 deletions(-) create mode 100644 forge-gui/res/cardsfolder/upcoming/invasion_of_kylem__valors_reach_tag_team.txt create mode 100644 forge-gui/res/tokenscripts/rw_3_2_warrior_symbiotic_attack.txt diff --git a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java index 3b56e269ae4..fe1d0b147eb 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -2929,10 +2929,13 @@ public class AbilityUtils { } public static final List getBasicSpellsFromPlayEffect(final Card tgtCard, final Player controller) { + return getBasicSpellsFromPlayEffect(tgtCard, controller, CardStateName.Original); + } + public static final List getBasicSpellsFromPlayEffect(final Card tgtCard, final Player controller, CardStateName state) { List sas = new ArrayList<>(); List list = Lists.newArrayList(tgtCard.getBasicSpells()); + CardState original = tgtCard.getState(state); - CardState original = tgtCard.getState(CardStateName.Original); if (tgtCard.isFaceDown()) { list.addAll(Lists.newArrayList(tgtCard.getBasicSpells(original))); } else { diff --git a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java index e9f7931c3a9..f2e7ce9ba85 100644 --- a/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java +++ b/forge-game/src/main/java/forge/game/ability/effects/PlayEffect.java @@ -286,9 +286,20 @@ public class PlayEffect extends SpellAbilityEffect { } } + CardStateName state = CardStateName.Original; + + if (sa.hasParam("CastTransformed")) { + if (!tgtCard.changeToState(CardStateName.Transformed)) { + // Failed to transform. In the future, we might need to just remove this option and continue + amount--; + continue; + } + state = CardStateName.Transformed; + } + // TODO if cost isn't replaced should include alternative ones // get basic spells (no flashback, etc.) - List sas = AbilityUtils.getBasicSpellsFromPlayEffect(tgtCard, controller); + List sas = AbilityUtils.getBasicSpellsFromPlayEffect(tgtCard, controller, state); if (sa.hasParam("ValidSA")) { final String valid[] = sa.getParam("ValidSA").split(","); sas = Lists.newArrayList(Iterables.filter(sas, SpellAbilityPredicates.isValid(valid, controller , source, sa))); @@ -312,14 +323,6 @@ public class PlayEffect extends SpellAbilityEffect { // For Illusionary Mask effect tgtSA = CardFactoryUtil.abilityMorphDown(tgtCard.getCurrentState(), false); } else { - if (sa.hasParam("CastTransformed")) { - if (!tgtCard.changeToState(CardStateName.Transformed)) { - // Failed to transform. In the future, we might need to just remove this option and continue - amount--; - continue; - } - } - tgtSA = sa.getActivatingPlayer().getController().getAbilityToPlay(tgtCard, sas); } diff --git a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java index 0e76dff93bb..6e9dfdce067 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java @@ -3943,10 +3943,15 @@ public class CardFactoryUtil { triggerDefeated.append("Mode$ CounterRemovedOnce | ValidCard$ Card.Self | Secondary$ True | CounterType$ DEFENSE | Remaining$ 0 | TriggerZones$ Battlefield | "); triggerDefeated.append(" TriggerDescription$ When CARDNAME is defeated, exile it, then cast it transformed."); - String castDefeatedBattle = "DB$ Play | Defined$ Self | WithoutManaCost$ True | CastTransformed$ True"; + String castExileBattle = "DB$ ChangeZone | Defined$ Self | Origin$ Battlefield | Destination$ Exile | RememberChanged$ True"; + String castDefeatedBattle = "DB$ Play | Defined$ Remembered | WithoutManaCost$ True | CastTransformed$ True"; Trigger defeatedTrigger = TriggerHandler.parseTrigger(triggerDefeated.toString(), card, true); - defeatedTrigger.setOverridingAbility(AbilityFactory.getAbility(castDefeatedBattle, card)); + SpellAbility exileAbility = AbilityFactory.getAbility(castExileBattle, card); + AbilitySub castAbility = (AbilitySub)AbilityFactory.getAbility(castDefeatedBattle, card); + + exileAbility.setSubAbility(castAbility); + defeatedTrigger.setOverridingAbility(exileAbility); card.addTrigger(defeatedTrigger); } diff --git a/forge-gui/res/cardsfolder/b/benevolent_hydra.txt b/forge-gui/res/cardsfolder/b/benevolent_hydra.txt index ea8a2b98b21..e69682c7837 100644 --- a/forge-gui/res/cardsfolder/b/benevolent_hydra.txt +++ b/forge-gui/res/cardsfolder/b/benevolent_hydra.txt @@ -3,7 +3,7 @@ ManaCost:X G G Types:Creature Hydra PT:1/1 K:etbCounter:P1P1:X -R:Event$ AddCounter | ActiveZones$ Battlefield | ValidCard$ Creature.YouCtrl+inZoneBattlefield | ValidCounterType$ P1P1 | ReplaceWith$ AddOneMoreCounters | Description$ If one or more +1/+1 counters would be put on a creature you control, that many plus one +1/+1 counters are put on it instead. +R:Event$ AddCounter | ActiveZones$ Battlefield | ValidCard$ Creature.YouCtrl+inZoneBattlefield+Other | ValidCounterType$ P1P1 | ReplaceWith$ AddOneMoreCounters | Description$ If one or more +1/+1 counters would be put on another creature you control, that many plus one +1/+1 counters are put on it instead. SVar:AddOneMoreCounters:DB$ ReplaceCounter | ValidCounterType$ P1P1 | ChooseCounter$ True | Amount$ Y A:AB$ PutCounter | Cost$ T SubCounter<1/P1P1> | ValidTgts$ Creature.YouCtrl+Other | CounterType$ P1P1 | CounterNum$ 1 | SpellDescription$ Put a +1/+1 counter on another target creature you control. SVar:X:Count$xPaid diff --git a/forge-gui/res/cardsfolder/k/kenku_artificer.txt b/forge-gui/res/cardsfolder/k/kenku_artificer.txt index ecd87182438..a30f80809fe 100644 --- a/forge-gui/res/cardsfolder/k/kenku_artificer.txt +++ b/forge-gui/res/cardsfolder/k/kenku_artificer.txt @@ -3,7 +3,7 @@ ManaCost:2 U Types:Creature Bird Artificer PT:1/1 T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigPutCounter | TriggerDescription$ Homunculus Servant — When CARDNAME enters the battlefield, put three +1/+1 counters on up to one target noncreature artifact. That artifact becomes a 0/0 Homunculus artifact creature with flying. -SVar:TrigPutCounter:DB$ PutCounter | ValidTgts$ Artifact.nonCreature+YouCtrl | TgtPrompt$ Select up to one noncreature artifact | CounterType$ P1P1 | CounterNum$ 3 | MinTarget$ 0 | MaxTarget$ 1 | SubAbility$ TrigAnimate +SVar:TrigPutCounter:DB$ PutCounter | ValidTgts$ Artifact.nonCreature+YouCtrl | TgtPrompt$ Select up to one noncreature artifact | CounterType$ P1P1 | CounterNum$ 3 | TargetMin$ 0 | TargetMax$ 1 | SubAbility$ TrigAnimate SVar:TrigAnimate:DB$ Animate | Defined$ Targeted | Keywords$ Flying | Power$ 0 | Toughness$ 0 | Types$ Artifact,Creature,Homunculus | RemoveCreatureTypes$ True | Duration$ Permanent DeckHas:Ability$Counters & Type$Homunculus DeckNeeds:Type$Artifact diff --git a/forge-gui/res/cardsfolder/rebalanced/a-kenku_artificer.txt b/forge-gui/res/cardsfolder/rebalanced/a-kenku_artificer.txt index 22f3af976d1..6b47b026d5c 100644 --- a/forge-gui/res/cardsfolder/rebalanced/a-kenku_artificer.txt +++ b/forge-gui/res/cardsfolder/rebalanced/a-kenku_artificer.txt @@ -3,7 +3,7 @@ ManaCost:2 U Types:Creature Bird Artificer PT:1/3 T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigPutCounter | TriggerDescription$ Homunculus Servant — When CARDNAME enters the battlefield, put three +1/+1 counters on up to one target noncreature artifact. That artifact becomes a 0/0 Homunculus artifact creature with flying. -SVar:TrigPutCounter:DB$ PutCounter | ValidTgts$ Artifact.nonCreature+YouCtrl | TgtPrompt$ Select up to one noncreature artifact | CounterType$ P1P1 | CounterNum$ 3 | MinTarget$ 0 | MaxTarget$ 1 | SubAbility$ TrigAnimate +SVar:TrigPutCounter:DB$ PutCounter | ValidTgts$ Artifact.nonCreature+YouCtrl | TgtPrompt$ Select up to one noncreature artifact | CounterType$ P1P1 | CounterNum$ 3 | TargetMin$ 0 | TargetMax$ 1 | SubAbility$ TrigAnimate SVar:TrigAnimate:DB$ Animate | Defined$ Targeted | Keywords$ Flying | Power$ 0 | Toughness$ 0 | Types$ Artifact,Creature,Homunculus | RemoveCreatureTypes$ True | Duration$ Permanent DeckHas:Ability$Counters & Type$Homunculus DeckNeeds:Type$Artifact diff --git a/forge-gui/res/cardsfolder/upcoming/invasion_of_kylem__valors_reach_tag_team.txt b/forge-gui/res/cardsfolder/upcoming/invasion_of_kylem__valors_reach_tag_team.txt new file mode 100644 index 00000000000..40b7e3dba9c --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/invasion_of_kylem__valors_reach_tag_team.txt @@ -0,0 +1,19 @@ +Name:Invasion of Kylem +ManaCost:2 R W +Types:Battle Siege +Defense:5 +T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigSearch | TriggerDescription$ When CARDNAME enters the battlefield, up to two target creatures each get +2/+0 and gain vigilance and haste until end of turn. +SVar:TrigSearch:DB$ Pump | TargetMin$ 0 | TargetMax$ 2 | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumAtt$ 2 | KW$ Vigilance & Haste +Oracle:(As a Siege enters, choose an opponent to protect it. You and others can attack it. When it's defeated, exile it, then cast it transformed.) When Invasion of Kylem enters the battlefield, up to two target creatures each get +2/+0 and gain vigilance and haste until end of turn. + +AlternateMode:DoubleFaced + +ALTERNATE + +Name:Valor's Reach Tag Team +ManaCost:no cost +Colors:red,white +Types:Sorcery +A:SP$ Token | TokenAmount$ 1 | TokenScript$ rw_3_2_warrior_symbiotic_attack | TokenAmount$ 2 | TokenOwner$ You | SpellDescription$ Create two 3/2 red and white Warrior creature tokens with “Whenever this creature and at least one other creature token attack, put a +1/+1 counter on this creature.” +DeckHas:Ability$Token & Type$Warrior +Oracle:Create two 3/2 red and white Warrior creature tokens with “Whenever this creature and at least one other creature token attack, put a +1/+1 counter on this creature.” diff --git a/forge-gui/res/cardsfolder/upcoming/invasion_of_zendikar__awakened_skyclave.txt b/forge-gui/res/cardsfolder/upcoming/invasion_of_zendikar__awakened_skyclave.txt index 8bf4f8fe53f..1da2f318d66 100644 --- a/forge-gui/res/cardsfolder/upcoming/invasion_of_zendikar__awakened_skyclave.txt +++ b/forge-gui/res/cardsfolder/upcoming/invasion_of_zendikar__awakened_skyclave.txt @@ -15,6 +15,7 @@ ManaCost:no cost Colors:green Types:Creature Elemental PT:4/4 +A:SP$ PermanentCreature K:Vigilance K:Haste S:Mode$ Continuous | Affected$ Card.Self | AddType$ Land | Description$ As long as Awakened Skyclave is on the battlefield, it’s a land in addition to its other types. diff --git a/forge-gui/res/tokenscripts/rw_3_2_warrior_symbiotic_attack.txt b/forge-gui/res/tokenscripts/rw_3_2_warrior_symbiotic_attack.txt new file mode 100644 index 00000000000..30efa043d04 --- /dev/null +++ b/forge-gui/res/tokenscripts/rw_3_2_warrior_symbiotic_attack.txt @@ -0,0 +1,8 @@ +Name:Warrior Token +ManaCost:no cost +Colors:red,white +Types:Creature Warrior +PT:3/2 +T:Mode$ Attacks | ValidCard$ Card.Self | TriggerZones$ Battlefield | IsPresent$ Creature.attacking+token+Other | PresentCompare$ GE1 | Execute$ TrigPutCounter | TriggerDescription$ Whenever CARDNAME and at least one other creature token attack, put a +1/+1 counter on CARDNAME. +SVar:TrigPutCounter:DB$ PutCounter | Defined$ Self | CounterType$ P1P1 | CounterNum$ 1 +Oracle:Whenever this creature and at least one other creature token attack, put a +1/+1 counter on this creature. \ No newline at end of file