Skip to content

Commit 8ecb285

Browse files
tool4EvErtool4EvEr
authored andcommitted
Return as Aura trickery
1 parent d5095a2 commit 8ecb285

File tree

9 files changed

+48
-47
lines changed

9 files changed

+48
-47
lines changed

forge-game/src/main/java/forge/game/GameAction.java

Lines changed: 32 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -128,33 +128,6 @@ private Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer
128128
CardCollectionView lastBattlefield = getLastState(AbilityKey.LastStateBattlefield, cause, params, false);
129129
CardCollectionView lastGraveyard = getLastState(AbilityKey.LastStateGraveyard, cause, params, false);
130130

131-
// Aura entering indirectly
132-
// need to check before it enters
133-
if (c.isAura() && !c.isAttachedToEntity() && toBattlefield && (zoneFrom == null || !zoneFrom.is(ZoneType.Stack))) {
134-
boolean found = false;
135-
if (game.getPlayers().stream().anyMatch(PlayerPredicates.canBeAttached(c, null))) {
136-
found = true;
137-
}
138-
139-
if (!found) {
140-
if (lastBattlefield.anyMatch(CardPredicates.canBeAttached(c, null))) {
141-
found = true;
142-
}
143-
}
144-
145-
if (!found) {
146-
if (lastGraveyard.anyMatch(CardPredicates.canBeAttached(c, null))) {
147-
found = true;
148-
}
149-
}
150-
if (!found) {
151-
c.clearControllers();
152-
if (cause != null) {
153-
}
154-
return c;
155-
}
156-
}
157-
158131
//717.6. If a card with an Astrotorium card back would be put into a zone other than the battlefield, exile,
159132
//or the command zone from anywhere, instead its owner puts it into the junkyard.
160133
if ((c.getGamePieceType() == GamePieceType.ATTRACTION || c.getGamePieceType() == GamePieceType.CONTRAPTION)
@@ -393,6 +366,33 @@ private Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer
393366

394367
copied.getOwner().removeInboundToken(copied);
395368

369+
handleStaticEffect(copied, cause);
370+
371+
// Aura entering indirectly
372+
// need to check before it enters
373+
if (copied.isAura() && !copied.isAttachedToEntity() && toBattlefield && (zoneFrom == null || !zoneFrom.is(ZoneType.Stack))) {
374+
boolean found = false;
375+
if (game.getPlayers().stream().anyMatch(PlayerPredicates.canBeAttached(copied, null))) {
376+
found = true;
377+
}
378+
379+
if (!found) {
380+
if (lastBattlefield.anyMatch(CardPredicates.canBeAttached(copied, null))) {
381+
found = true;
382+
}
383+
}
384+
385+
if (!found) {
386+
if (lastGraveyard.anyMatch(CardPredicates.canBeAttached(copied, null))) {
387+
found = true;
388+
}
389+
}
390+
if (!found) {
391+
c.clearControllers();
392+
return c;
393+
}
394+
}
395+
396396
// Aura entering as Copy from stack
397397
// without targets it is sent to graveyard
398398
if (copied.isAura() && !copied.isAttachedToEntity() && toBattlefield) {
@@ -575,7 +575,6 @@ private Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer
575575
copied.setChosenColorID(ImmutableSet.copyOf(c.getChosenColorID()));
576576
}
577577

578-
// update state for view
579578
copied.updateStateForView();
580579

581580
if (fromBattlefield) {
@@ -587,8 +586,6 @@ private Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer
587586
}
588587
}
589588

590-
handleStaticEffect(copied, cause);
591-
592589
if (!table.isEmpty()) {
593590
// we don't want always trigger before counters are placed
594591
game.getTriggerHandler().suppressMode(TriggerType.Always);
@@ -727,6 +724,7 @@ private Card changeZone(final Zone zoneFrom, Zone zoneTo, final Card c, Integer
727724
}
728725

729726
private void handleStaticEffect(Card copied, SpellAbility cause) {
727+
// CR 611.2e
730728
if (cause == null || !cause.hasParam("StaticEffect") || !copied.isPermanent()) {
731729
return;
732730
}
@@ -765,11 +763,15 @@ private void handleStaticEffect(Card copied, SpellAbility cause) {
765763
eff.setRenderForUI(false);
766764
StaticAbility stAb = eff.addStaticAbility(AbilityUtils.getSVar(cause, cause.getParam("StaticEffect")));
767765
stAb.putParam("EffectZone", "Command");
766+
stAb.putParam("AffectedZone", "Battlefield,Hand,Graveyard,Exile,Stack,Library,Command");
768767
SpellAbilityEffect.addForgetOnMovedTrigger(copied, "Battlefield");
769768
game.getAction().moveToCommand(eff, cause);
770769
}
771770

772771
eff.addRemembered(copied);
772+
773+
// refresh needed for effects like Bronzehide Lion
774+
game.getAction().checkStaticAbilities(false, Sets.newHashSet(copied), new CardCollection(copied));
773775
}
774776

775777
private void storeChangesZoneAll(Card c, Zone zoneFrom, Zone zoneTo, Map<AbilityKey, Object> params) {

forge-game/src/main/java/forge/game/staticability/StaticAbilityContinuous.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -792,9 +792,7 @@ public static CardCollectionView applyContinuousAbility(final StaticAbility stAb
792792
final String costcmc = Integer.toString(affectedCard.getCMC());
793793
ability = TextUtil.fastReplace(ability, "ConvertedManaCost", costcmc);
794794
}
795-
if (ability.startsWith("AB") || ability.startsWith("ST")) { // grant the ability
796-
addedAbilities.add(affectedCard.getSpellAbilityForStaticAbility(ability, stAb));
797-
}
795+
addedAbilities.add(affectedCard.getSpellAbilityForStaticAbility(ability, stAb));
798796
}
799797
}
800798

forge-gui/res/adventure/common/custom_cards/garruk_boss_effect_phasetwo.txt

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,9 @@ SVar:TrigConjure:DB$ MakeCard | Conjure$ True | Zone$ Hand | AtRandom$ True | Sp
99
T:Mode$ SpellCast | ValidCard$ Card.nonCreature | ValidActivatingPlayer$ Opponent | Execute$ DBPump | TriggerZones$ Command | TriggerDescription$ Whenever an opponent casts a noncreature spell, perpetually increase the power and toughness of creatures you control and creature cards in your hand, library, and graveyard by 1.
1010
SVar:DBPump:DB$ PumpAll | ValidCards$ Creature.YouCtrl | PumpZone$ Battlefield,Hand,Graveyard,Library | NumAtt$ 1 | NumDef$ 1 | Duration$ Perpetual
1111
T:Mode$ Phase | Phase$ End of Turn | ValidPlayer$ You | TriggerZones$ Command | Execute$ TrigReanimate | TriggerDescription$ At the beginning of your end step, return a random creature card from your graveyard to the battlefield. It gains "If this creature would leave the battlefield, exile it instead."
12-
SVar:TrigReanimate:DB$ ChangeZone | ChangeType$ Creature.YouOwn | ChangeNum$ 1 | Hidden$ True | Origin$ Graveyard | AtRandom$ True | Destination$ Battlefield | AnimateSubAbility$ DBAnimate
13-
SVar:DBAnimate:DB$ Animate | Replacements$ ReplaceDies | Defined$ Remembered | Duration$ Permanent
12+
SVar:TrigReanimate:DB$ ChangeZone | ChangeType$ Creature.YouOwn | ChangeNum$ 1 | Hidden$ True | Origin$ Graveyard | AtRandom$ True | Destination$ Battlefield | RememberChanged$ True | SubAbility$ DBAnimate
13+
SVar:DBAnimate:DB$ Animate | Replacements$ ReplaceDies | Defined$ Remembered | Duration$ Permanent | SubAbility$ DBCleanup
14+
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
1415
SVar:ReplaceDies:Event$ Moved | ActiveZones$ Battlefield | Origin$ Battlefield | ValidCard$ Card.Self | ReplaceWith$ Exile | Description$ If this creature would leave the battlefield, exile it instead.
1516
SVar:Exile:DB$ ChangeZone | Origin$ Battlefield | Destination$ Exile | Defined$ ReplacedCard
1617
Oracle:Each Forest you control is a Swamp in addition to its other land types.\nBeast creatures you control get +3/+3 and have trample and deathtouch.\nAt the beginning of your upkeep, conjure a card from Garruk's Phase 2 spellbook into your hand.\nWhenever an opponent casts a noncreature spell, perpetually increase the power and toughness of creatures you control and creature cards in your hand, library, and graveyard by 1.\nAt the beginning of your end step, return a random creature card from your graveyard to the battlefield. That creature gains "If this creature would leave the battlefield, exile it instead."

forge-gui/res/cardsfolder/a/abuelos_awakening.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
Name:Abuelo's Awakening
22
ManaCost:X 3 W
33
Types:Sorcery
4-
A:SP$ ChangeZone | Origin$ Graveyard | Destination$ Battlefield | ValidTgts$ Artifact.YouOwn,Enchantment.nonAura+YouOwn | TgtPrompt$ Select an Artifact or non-Aura enchantment | AnimateSubAbility$ DBAnimate | WithCountersType$ P1P1 | WithCountersAmount$ X | SpellDescription$ Return target artifact or non-Aura enchantment card from your graveyard to the battlefield with X additional +1/+1 counters on it. It's a 1/1 Spirit creature with flying in addition to its other types.
5-
SVar:DBAnimate:DB$ Animate | Defined$ Remembered | Power$ 1 | Toughness$ 1 | Keywords$ Flying | Types$ Creature,Spirit | Duration$ Permanent
4+
A:SP$ ChangeZone | Origin$ Graveyard | Destination$ Battlefield | ValidTgts$ Artifact.YouOwn,Enchantment.nonAura+YouOwn | TgtPrompt$ Select an Artifact or non-Aura enchantment | StaticEffect$ Animate | WithCountersType$ P1P1 | WithCountersAmount$ X | SpellDescription$ Return target artifact or non-Aura enchantment card from your graveyard to the battlefield with X additional +1/+1 counters on it. It's a 1/1 Spirit creature with flying in addition to its other types.
5+
SVar:Animate:Mode$ Continuous | Affected$ Card.IsRemembered | AddType$ Creature & Spirit | SetPower$ 1 | SetToughness$ 1 | AddKeyword$ Flying
66
SVar:X:Count$xPaid
77
DeckHas:Ability$Graveyard|Counters & Type$Spirit
88
DeckHints:Ability$Mill & Type$Artifact|Enchantment

forge-gui/res/cardsfolder/a/admiral_brass_unsinkable.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,8 @@ PT:3/3
55
T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | Execute$ TrigMill | TriggerDescription$ When CARDNAME enters, mill four cards.
66
SVar:TrigMill:DB$ Mill | NumCards$ 4 | Defined$ You
77
T:Mode$ Phase | Phase$ BeginCombat | ValidPlayer$ You | TriggerZones$ Battlefield | Execute$ TrigReturn | TriggerDescription$ At the beginning of combat on your turn, you may return target Pirate creature card from your graveyard to the battlefield with a finality counter on it. It has base power and toughness 4/4. It gains haste until end of turn. (If a creature with a finality counter on it would die, exile it instead.)
8-
SVar:TrigReturn:DB$ ChangeZone | Origin$ Graveyard | Destination$ Battlefield | WithCountersType$ FINALITY | ValidTgts$ Pirate.YouOwn | Optional$ True | TgtPrompt$ Select target pirate in your graveyard | SubAbility$ DBPump | RememberChanged$ True | AnimateSubAbility$ DBAnimate
9-
SVar:DBAnimate:DB$ Animate | Power$ 4 | Toughness$ 4 | Duration$ Permanent | Defined$ Remembered
8+
SVar:TrigReturn:DB$ ChangeZone | Origin$ Graveyard | Destination$ Battlefield | WithCountersType$ FINALITY | ValidTgts$ Pirate.YouOwn | Optional$ True | TgtPrompt$ Select target pirate in your graveyard | SubAbility$ DBPump | RememberChanged$ True | StaticEffect$ Animate
9+
SVar:Animate:Mode$ Continuous | Affected$ Card.IsRemembered | SetPower$ 4 | SetToughness$ 4
1010
SVar:DBPump:DB$ Pump | KW$ Haste | Defined$ Remembered | SubAbility$ DBCleanup
1111
SVar:DBCleanup:DB$ Cleanup | ClearRemembered$ True
1212
DeckHas:Ability$Mill|Graveyard|Counters

forge-gui/res/cardsfolder/a/arbiter_of_the_ideal.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,6 @@ Types:Creature Sphinx
44
PT:4/5
55
K:Flying
66
T:Mode$ Untaps | ValidCard$ Card.Self | TriggerZones$ Battlefield | Execute$ TrigReveal | TriggerDescription$ Inspired — Whenever CARDNAME becomes untapped, reveal the top card of your library. If it's an artifact, creature, or land card, you may put it onto the battlefield with a manifestation counter on it. That permanent is an enchantment in addition to its other types.
7-
SVar:TrigReveal:DB$ Dig | DigNum$ 1 | Reveal$ True | Optional$ True | ChangeValid$ Artifact,Creature,Land | DestinationZone$ Battlefield | LibraryPosition2$ 0 | WithCounters$ MANIFESTATION | AnimateSubAbility$ Enchantment
8-
SVar:Enchantment:DB$ Animate | Defined$ Remembered | Types$ Enchantment | Duration$ Permanent
7+
SVar:TrigReveal:DB$ Dig | DigNum$ 1 | Reveal$ True | Optional$ True | ChangeValid$ Artifact,Creature,Land | DestinationZone$ Battlefield | LibraryPosition2$ 0 | WithCounters$ MANIFESTATION | StaticEffect$ Enchantment
8+
SVar:Enchantment:Mode$ Continuous | Affected$ Card.IsRemembered | AddType$ Enchantment
99
Oracle:Flying\nInspired — Whenever Arbiter of the Ideal becomes untapped, reveal the top card of your library. If it's an artifact, creature, or land card, you may put it onto the battlefield with a manifestation counter on it. That permanent is an enchantment in addition to its other types.

forge-gui/res/cardsfolder/a/ascent_of_the_worthy.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ SVar:DBChoose:DB$ ChooseCard | Choices$ Creature.YouCtrl | Mandatory$ True | Sub
66
SVar:DBEffect:DB$ Effect | ReplacementEffects$ DamageEvent | ExileOnMoved$ Battlefield | RememberObjects$ ChosenCard | Duration$ UntilYourNextTurn
77
SVar:DamageEvent:Event$ DamageDone | ActiveZones$ Command | ValidTarget$ Creature.YouCtrl | ReplaceWith$ GideonSac | DamageTarget$ Remembered | Description$ All damage that would be dealt this turn to creatures you control is dealt to the chosen creature instead (if it's still on the battlefield).
88
SVar:GideonSac:DB$ ReplaceEffect | VarName$ Affected | VarValue$ Remembered | VarType$ Card
9-
SVar:DBChangeZone:DB$ ChangeZone | Origin$ Graveyard | Destination$ Battlefield | TgtPrompt$ Choose target creature card in your graveyard | ValidTgts$ Creature.YouOwn | WithCountersType$ Flying | AnimateSubAbility$ Animate | SpellDescription$ Return target creature card from your graveyard to the battlefield with a flying counter on it. That creature is an Angel Warrior in addition to its other types.
10-
SVar:Animate:DB$ Animate | Defined$ Remembered | Types$ Angel,Warrior | Duration$ Permanent
9+
SVar:DBChangeZone:DB$ ChangeZone | Origin$ Graveyard | Destination$ Battlefield | TgtPrompt$ Choose target creature card in your graveyard | ValidTgts$ Creature.YouOwn | WithCountersType$ Flying | StaticEffect$ Animate | SpellDescription$ Return target creature card from your graveyard to the battlefield with a flying counter on it. That creature is an Angel Warrior in addition to its other types.
10+
SVar:Animate:Mode$ Continuous | Affected$ Card.IsRemembered | AddType$ Angel & Warrior
1111
Oracle:(As this Saga enters and after your draw step, add a lore counter. Sacrifice after III.)\nI, II — Choose a creature you control. Until your next turn, all damage that would be dealt to creatures you control is dealt to that creature instead.\nIII — Return target creature card from your graveyard to the battlefield with a flying counter on it. That creature is an Angel Warrior in addition to its other types.

forge-gui/res/cardsfolder/a/ashiok_nightmare_weaver.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Types:Legendary Planeswalker Ashiok
44
Loyalty:3
55
A:AB$ Dig | Cost$ AddCounter<2/LOYALTY> | Planeswalker$ True | ValidTgts$ Opponent | DigNum$ 3 | ChangeNum$ All | DestinationZone$ Exile | SpellDescription$ Exile the top three cards of target opponent's library.
66
A:AB$ ChooseCard | Cost$ SubCounter<X/LOYALTY> | Choices$ Creature.cmcEQX+ExiledWithSource | ChoiceZone$ Exile | Planeswalker$ True | SubAbility$ DBChangeZone | AILogic$ Ashiok | SpellDescription$ Put a creature card with mana value X exiled with CARDNAME onto the battlefield under your control. That creature is a Nightmare in addition to its other types.
7-
SVar:DBChangeZone:DB$ ChangeZone | Defined$ ChosenCard | Origin$ Exile | Destination$ Battlefield | GainControl$ True | AnimateSubAbility$ DBAnimate | SubAbility$ DBCleanMinus
8-
SVar:DBAnimate:DB$ Animate | Defined$ Remembered | Types$ Nightmare | Duration$ Permanent
7+
SVar:DBChangeZone:DB$ ChangeZone | Defined$ ChosenCard | Origin$ Exile | Destination$ Battlefield | GainControl$ True | StaticEffect$ Animate | SubAbility$ DBCleanMinus
8+
SVar:Animate:Mode$ Continuous | Affected$ Card.IsRemembered | AddType$ Nightmare
99
SVar:DBCleanMinus:DB$ Cleanup | ClearChosenCard$ True
1010
SVar:X:Count$xPaid
1111
A:AB$ ChangeZoneAll | Cost$ SubCounter<10/LOYALTY> | ChangeType$ Card.OppCtrl | Origin$ Graveyard,Hand | Destination$ Exile | RememberChanged$ True | Planeswalker$ True | Ultimate$ True | SpellDescription$ Exile all cards from all opponents' hands and graveyards.

forge-gui/res/cardsfolder/b/bronzehide_lion.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,8 @@ Types:Creature Cat
44
PT:3/3
55
A:AB$ Pump | Cost$ G W | KW$ Indestructible | Defined$ Self | SpellDescription$ CARDNAME gains indestructible until end of turn.
66
T:Mode$ ChangesZone | Origin$ Battlefield | Destination$ Graveyard | ValidCard$ Card.Self | Execute$ DBReturn | TriggerDescription$ When CARDNAME dies, return it to the battlefield. It's an Aura enchantment with enchant creature you control and "{G}{W}: Enchanted creature gains indestructible until end of turn," and it loses all other abilities.
7-
SVar:DBReturn:DB$ ChangeZone | Defined$ TriggeredNewCardLKICopy | Origin$ Graveyard | Destination$ Battlefield | GainControl$ True | AnimateSubAbility$ DBAnimate
8-
SVar:DBAnimate:DB$ Animate | Defined$ Remembered | Types$ Enchantment,Aura | RemoveCardTypes$ True | RemoveAllAbilities$ True | Keywords$ Enchant creature you control | Abilities$ SPAttach,ABPump | Duration$ Permanent
7+
SVar:DBReturn:DB$ ChangeZone | Defined$ TriggeredNewCardLKICopy | Origin$ Graveyard | Destination$ Battlefield | GainControl$ True | StaticEffect$ Animate
8+
SVar:Animate:Mode$ Continuous | Affected$ Card.IsRemembered | AddType$ Aura & Enchantment | RemoveCardTypes$ True | RemoveAllAbilities$ True | AddKeyword$ Enchant creature you control | AddAbility$ SPAttach & ABPump
99
SVar:SPAttach:SP$ Attach | Cost$ 0 | ValidTgts$ Creature.YouCtrl | AILogic$ Pump
1010
SVar:ABPump:AB$ Pump | Cost$ G W | KW$ Indestructible | Defined$ Enchanted | SpellDescription$ Enchanted creature gains indestructible until end of turn.
1111
Oracle:{G}{W}: Bronzehide Lion gains indestructible until end of turn.\nWhen Bronzehide Lion dies, return it to the battlefield. It's an Aura enchantment with enchant creature you control and "{G}{W}: Enchanted creature gains indestructible until end of turn," and it loses all other abilities.

0 commit comments

Comments
 (0)