From 74d2c68b12604d723c0005103423b69a455e7cf0 Mon Sep 17 00:00:00 2001 From: Bug Hunter Date: Mon, 31 Jan 2022 12:25:47 +0000 Subject: [PATCH] Presence fixes --- .../java/forge/game/ability/AbilityUtils.java | 28 +++++++++++-------- .../java/forge/game/card/CardProperty.java | 2 ++ .../spellability/SpellAbilityCondition.java | 2 +- forge-gui/res/cardsfolder/a/aether_burst.txt | 2 +- forge-gui/res/cardsfolder/j/jaws_of_stone.txt | 6 ++-- forge-gui/res/cardsfolder/r/reap.txt | 2 +- forge-gui/res/cardsfolder/s/spoils_of_war.txt | 2 +- .../cardsfolder/upcoming/lethal_exploit.txt | 2 +- forge-gui/res/cardsfolder/v/volcanic_wind.txt | 2 +- 9 files changed, 27 insertions(+), 21 deletions(-) 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 0c9a5baf237..2cbbe654454 100644 --- a/forge-game/src/main/java/forge/game/ability/AbilityUtils.java +++ b/forge-game/src/main/java/forge/game/ability/AbilityUtils.java @@ -1849,11 +1849,14 @@ public class AbilityUtils { if (sq[0].startsWith("LastStateBattlefield")) { final String[] k = l[0].split(" "); - CardCollectionView list = null; - if (sa.getLastStateBattlefield() != null) { - list = sa.getLastStateBattlefield(); - } else { // LastState is Empty - return doXMath(0, expr, c, ctb); + CardCollectionView list = sa.getLastStateBattlefield(); + if (list == null || list.isEmpty()) { + // LastState is Empty + if (sq[0].contains("WithFallback")) { + list = game.getCardsIn(ZoneType.Battlefield); + } else { + return doXMath(0, expr, c, ctb); + } } list = CardLists.getValidCards(list, k[1].split(","), sa.getActivatingPlayer(), c, sa); if (k[0].contains("TotalToughness")) { @@ -1864,11 +1867,14 @@ public class AbilityUtils { if (sq[0].startsWith("LastStateGraveyard")) { final String[] k = l[0].split(" "); - CardCollectionView list = null; - if (sa.getLastStateGraveyard() != null) { - list = sa.getLastStateGraveyard(); - } else { // LastState is Empty - return doXMath(0, expr, c, ctb); + CardCollectionView list = sa.getLastStateGraveyard(); + if (sa.getLastStateGraveyard() == null || list.isEmpty()) { + // LastState is Empty + if (sq[0].contains("WithFallback")) { + list = game.getCardsIn(ZoneType.Graveyard); + } else { + return doXMath(0, expr, c, ctb); + } } list = CardLists.getValidCards(list, k[1].split(","), sa.getActivatingPlayer(), c, sa); return doXMath(list.size(), expr, c, ctb); @@ -2125,7 +2131,7 @@ public class AbilityUtils { boolean found = false; if (c.getCastFrom() != null && c.getCastSA() != null) { int revealed = calculateAmount(c, "Revealed$Valid " + type, c.getCastSA()); - int ctrl = calculateAmount(c, "Count$Valid " + type + ".inZoneBattlefield+YouCtrl", c.getCastSA()); + int ctrl = calculateAmount(c, "Count$LastStateBattlefield " + type + ".YouCtrl", c.getCastSA()); if (revealed + ctrl >= 1) { found = true; } diff --git a/forge-game/src/main/java/forge/game/card/CardProperty.java b/forge-game/src/main/java/forge/game/card/CardProperty.java index 0c9147c419d..5dbeeb00428 100644 --- a/forge-game/src/main/java/forge/game/card/CardProperty.java +++ b/forge-game/src/main/java/forge/game/card/CardProperty.java @@ -54,11 +54,13 @@ public class CardProperty { // by name can also have color names, so needs to happen before colors. if (property.startsWith("named")) { String name = TextUtil.fastReplace(property.substring(5), ";", ","); // workaround for card name with "," + name = TextUtil.fastReplace(name, "_", " "); if (!card.sharesNameWith(name)) { return false; } } else if (property.startsWith("notnamed")) { String name = TextUtil.fastReplace(property.substring(8), ";", ","); // workaround for card name with "," + name = TextUtil.fastReplace(name, "_", " "); if (card.sharesNameWith(name)) { return false; } diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java index f80cfee20f1..124a9633c7e 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbilityCondition.java @@ -277,7 +277,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables { final String type = this.getPresenceCondition(); int revealed = AbilityUtils.calculateAmount(host, "Revealed$Valid " + type, host.getCastSA()); - int ctrl = AbilityUtils.calculateAmount(host, "Count$Valid " + type + ".inZoneBattlefield+YouCtrl", host.getCastSA()); + int ctrl = AbilityUtils.calculateAmount(host, "Count$LastStateBattlefield " + type + ".YouCtrl", host.getCastSA()); if (revealed + ctrl == 0) { return false; diff --git a/forge-gui/res/cardsfolder/a/aether_burst.txt b/forge-gui/res/cardsfolder/a/aether_burst.txt index ad2a144b5fd..4c808c58a66 100644 --- a/forge-gui/res/cardsfolder/a/aether_burst.txt +++ b/forge-gui/res/cardsfolder/a/aether_burst.txt @@ -2,6 +2,6 @@ Name:Aether Burst ManaCost:1 U Types:Instant A:SP$ ChangeZone | Cost$ 1 U | ValidTgts$ Creature | TargetMin$ 0 | TargetMax$ X | TgtPrompt$ Select target creature | Origin$ Battlefield | Destination$ Hand | SpellDescription$ Return up to X target creatures to their owners' hands, where X is one plus the number of cards named Aether Burst in all graveyards as you cast CARDNAME. -SVar:X:Count$NamedInAllYards.Aether Burst/Plus.1 +SVar:X:Count$LastStateGraveyardWithFallback Card.namedAether_Burst/Plus.1 DeckHints:Name$Aether Burst Oracle:Return up to X target creatures to their owners' hands, where X is one plus the number of cards named Aether Burst in all graveyards as you cast this spell. diff --git a/forge-gui/res/cardsfolder/j/jaws_of_stone.txt b/forge-gui/res/cardsfolder/j/jaws_of_stone.txt index 056653fa0f8..7031797fd57 100644 --- a/forge-gui/res/cardsfolder/j/jaws_of_stone.txt +++ b/forge-gui/res/cardsfolder/j/jaws_of_stone.txt @@ -2,8 +2,6 @@ Name:Jaws of Stone ManaCost:5 R Types:Sorcery A:SP$ DealDamage | Cost$ 5 R | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target to distribute damage to | NumDmg$ OrigMountains | TargetMin$ Min | TargetMax$ OrigMountains | DividedAsYouChoose$ OrigMountains | SpellDescription$ CARDNAME deals X damage divided as you choose among any number of targets, where X is the number of Mountains you control as you cast this spell. -T:Mode$ SpellCast | ValidCard$ Card.Self | Static$ True | Execute$ CountMountainsAtCast -SVar:CountMountainsAtCast:DB$ StoreSVar | SVar$ OrigMountains | Type$ Count | Expression$ Valid Mountain.YouCtrl -SVar:OrigMountains:Count$Valid Mountain.YouCtrl -SVar:Min:SVar$OrigMountains/LimitMax.1 +SVar:OrigMountains:Count$LastStateBattlefieldWithFallback Mountain.YouCtrl +SVar:Min:Count$Valid Mountain.YouCtrl/LimitMax.1 Oracle:Jaws of Stone deals X damage divided as you choose among any number of targets, where X is the number of Mountains you control as you cast this spell. diff --git a/forge-gui/res/cardsfolder/r/reap.txt b/forge-gui/res/cardsfolder/r/reap.txt index de0645fb210..001e1201676 100644 --- a/forge-gui/res/cardsfolder/r/reap.txt +++ b/forge-gui/res/cardsfolder/r/reap.txt @@ -3,7 +3,7 @@ ManaCost:1 G Types:Instant A:SP$ Pump | Cost$ 1 G | TgtPrompt$ Select target Opponent | ValidTgts$ Opponent | SubAbility$ GraveReap | StackDescription$ Select target opponent. | SpellDescription$ Return up to X target cards from your graveyard to your hand, where X is the number of black permanents target opponent controls as you cast this spell. SVar:GraveReap:DB$ ChangeZone | Origin$ Graveyard | Destination$ Hand | TargetMin$ 0 | TargetMax$ NrBlackAtCasting | TgtPrompt$ Choose target card in your graveyard | ValidTgts$ Card.YouCtrl -SVar:NrBlackAtCasting:Count$Valid Permanent.Black+TargetedPlayerCtrl +SVar:NrBlackAtCasting:Count$LastStateBattlefieldWithFallback Permanent.Black+TargetedPlayerCtrl SVar:AIPlayForSub:True AI:RemoveDeck:Random Oracle:Return up to X target cards from your graveyard to your hand, where X is the number of black permanents target opponent controls as you cast this spell. diff --git a/forge-gui/res/cardsfolder/s/spoils_of_war.txt b/forge-gui/res/cardsfolder/s/spoils_of_war.txt index e43b0db7f9a..5118efde777 100644 --- a/forge-gui/res/cardsfolder/s/spoils_of_war.txt +++ b/forge-gui/res/cardsfolder/s/spoils_of_war.txt @@ -3,6 +3,6 @@ ManaCost:X B Types:Sorcery Text:X is the number of artifact and/or creature cards in an opponent's graveyard as you cast this spell. A:SP$ PutCounter | Cost$ X B | ValidTgts$ Creature | TgtPrompt$ Select target creature to distribute counters to | CounterType$ P1P1 | CounterNum$ X | TargetMin$ 1 | TargetMax$ X | DividedAsYouChoose$ X | SpellDescription$ Distribute X +1/+1 counters among any number of target creatures. -SVar:X:Count$ValidGraveyard Creature.OppCtrl,Artifact.OppCtrl +SVar:X:Count$LastStateBattlefieldWithFallback Creature.OppCtrl,Artifact.OppCtrl AI:RemoveDeck:All Oracle:X is the number of artifact and/or creature cards in an opponent's graveyard as you cast this spell.\nDistribute X +1/+1 counters among any number of target creatures. diff --git a/forge-gui/res/cardsfolder/upcoming/lethal_exploit.txt b/forge-gui/res/cardsfolder/upcoming/lethal_exploit.txt index f74225eb429..09a18cb50f4 100644 --- a/forge-gui/res/cardsfolder/upcoming/lethal_exploit.txt +++ b/forge-gui/res/cardsfolder/upcoming/lethal_exploit.txt @@ -2,6 +2,6 @@ Name:Lethal Exploit ManaCost:1 B Types:Instant A:SP$ Pump | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumAtt$ -X | NumDef$ -X | IsCurse$ True | SpellDescription$ Target creature gets -2/-2 until end of turn. It gets an additional -1/-1 until end of turn for each modified creature you controlled as you cast this spell. (Equipment, Auras you control, and counters are modifications.) -SVar:X:Count$Valid Creature.modified+YouCtrl/Plus.2 +SVar:X:Count$LastStateBattlefieldWithFallback Creature.modified+YouCtrl/Plus.2 DeckHints:Type$Aura|Equipment & Ability$Counters Oracle:Target creature gets -2/-2 until end of turn. It gets an additional -1/-1 until end of turn for each modified creature you controlled as you cast this spell. (Equipment, Auras you control, and counters are modifications.) diff --git a/forge-gui/res/cardsfolder/v/volcanic_wind.txt b/forge-gui/res/cardsfolder/v/volcanic_wind.txt index c54d0fa1b7a..dfa37bb47a1 100644 --- a/forge-gui/res/cardsfolder/v/volcanic_wind.txt +++ b/forge-gui/res/cardsfolder/v/volcanic_wind.txt @@ -2,5 +2,5 @@ Name:Volcanic Wind ManaCost:4 R R Types:Sorcery A:SP$ DealDamage | Cost$ 4 R R | ValidTgts$ Creature | TgtPrompt$ Select target creature to distribute damage to | NumDmg$ NumCreatures | TargetMin$ 1 | TargetMax$ NumCreatures | DividedAsYouChoose$ NumCreatures | SpellDescription$ CARDNAME deals X damage divided as you choose among any number of target creatures, where X is the number of creatures on the battlefield as you cast this spell. -SVar:NumCreatures:Count$Valid Creature +SVar:NumCreatures:Count$LastStateBattlefieldWithFallback Creature Oracle:Volcanic Wind deals X damage divided as you choose among any number of target creatures, where X is the number of creatures on the battlefield as you cast this spell.