From ac12fa5b6f0d359f46a89cca0918b49f161e6b83 Mon Sep 17 00:00:00 2001 From: Hans Mackowiak Date: Sun, 21 Jan 2024 11:49:47 +0100 Subject: [PATCH] cleanup meetsManaRestrictions --- .../src/main/java/forge/game/ForgeScript.java | 8 +++++ .../src/main/java/forge/game/card/Card.java | 1 + .../java/forge/game/card/CardFactoryUtil.java | 2 +- .../game/spellability/AbilityManaPart.java | 30 ------------------- .../forge/game/spellability/SpellAbility.java | 2 +- .../res/cardsfolder/a/adarkar_unicorn.txt | 4 +-- .../res/cardsfolder/b/battery_bearer.txt | 2 +- ...genious_scientist_jetfire_air_guardian.txt | 2 +- .../cardsfolder/k/karn_legacy_reforged.txt | 2 +- forge-gui/res/cardsfolder/s/snowfall.txt | 4 +-- .../t/the_mightstone_and_weakstone.txt | 2 +- forge-gui/res/cardsfolder/t/thran_turbine.txt | 2 +- .../res/cardsfolder/u/unblinking_observer.txt | 2 +- forge-gui/res/tokenscripts/c_a_powerstone.txt | 2 +- 14 files changed, 22 insertions(+), 43 deletions(-) diff --git a/forge-game/src/main/java/forge/game/ForgeScript.java b/forge-game/src/main/java/forge/game/ForgeScript.java index 11e7c7e68b6..820dff98e3c 100644 --- a/forge-game/src/main/java/forge/game/ForgeScript.java +++ b/forge-game/src/main/java/forge/game/ForgeScript.java @@ -221,6 +221,8 @@ public class ForgeScript { return sa.isCycling(); } else if (property.equals("Dash")) { return sa.isDash(); + } else if (property.equals("Disturb")) { + return sa.isDisturb(); } else if (property.equals("Flashback")) { return sa.isFlashBackAbility(); } else if (property.equals("Jumpstart")) { @@ -235,6 +237,10 @@ public class ForgeScript { return sa.isAftermath(); } else if (property.equals("MorphUp")) { return sa.isMorphUp(); + } else if (property.equals("ManifestUp")) { + return sa.isManifestUp(); + } else if (property.equals("isCastFaceDown")) { + return sa.isCastFaceDown(); } else if (property.equals("Modular")) { return sa.hasParam("Modular"); } else if (property.equals("Equip")) { @@ -264,6 +270,8 @@ public class ForgeScript { if (sa.getChapter() == sa.getHostCard().getCounters(CounterEnumType.LORE)) { return false; } + } else if (property.equals("CumulativeUpkeep")) { + return sa.isCumulativeUpkeep(); } else if (property.equals("LastChapter")) { return sa.isLastChapter(); } else if (property.startsWith("ManaSpent")) { diff --git a/forge-game/src/main/java/forge/game/card/Card.java b/forge-game/src/main/java/forge/game/card/Card.java index 69a891eba83..78e13d5c662 100644 --- a/forge-game/src/main/java/forge/game/card/Card.java +++ b/forge-game/src/main/java/forge/game/card/Card.java @@ -7053,6 +7053,7 @@ public class Card extends GameEntity implements Comparable, IHasSVars { if (sa.isCastFaceDown()) { turnFaceDown(true); + CardFactoryUtil.setFaceDownState(this, sa); } } 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 e568b3cb2ab..096c58d02c2 100644 --- a/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java +++ b/forge-game/src/main/java/forge/game/card/CardFactoryUtil.java @@ -111,7 +111,6 @@ public class CardFactoryUtil { if (!hostCard.isFaceDown()) { hostCard.setOriginalStateAsFaceDown(); } - CardFactoryUtil.setFaceDownState(hostCard, this); final Game game = hostCard.getGame(); CardZoneTable table = new CardZoneTable(game.copyLastStateBattlefield(), game.copyLastStateBattlefield()); @@ -4058,6 +4057,7 @@ public class CardFactoryUtil { faceDown.setType(new CardType(Arrays.asList(sa.getParam("FaceDownSetType").split(" & ")), false)); } if (sa.hasParam("FaceDownKeyword")) { + faceDown.setIntrinsicKeywords(Lists.newArrayList(), false); faceDown.addIntrinsicKeywords(Arrays.asList(sa.getParam("FaceDownKeyword").split(" & "))); } diff --git a/forge-game/src/main/java/forge/game/spellability/AbilityManaPart.java b/forge-game/src/main/java/forge/game/spellability/AbilityManaPart.java index b4e5934d3cd..3b11f77e8d9 100644 --- a/forge-game/src/main/java/forge/game/spellability/AbilityManaPart.java +++ b/forge-game/src/main/java/forge/game/spellability/AbilityManaPart.java @@ -366,17 +366,6 @@ public class AbilityManaPart implements java.io.Serializable { // Loop over restrictions for (String restriction : restrictions.split(",")) { - if (restriction.equals("nonSpell")) { - return !sa.isSpell(); - } - - if (restriction.equals("CumulativeUpkeep")) { - if (sa.isCumulativeupkeep()) { - return true; - } - continue; - } - if (restriction.startsWith("CostContains")) { if (restriction.endsWith("X") && sa.costHasManaX()) { return true; @@ -387,21 +376,6 @@ public class AbilityManaPart implements java.io.Serializable { continue; } - if (restriction.equals("Disturb")) { - if (sa.isDisturb()) { - return true; - } - continue; - } - - if (restriction.equals("MorphOrManifest")) { - if ((sa.isSpell() && sa.getHostCard().isCreature() && sa.isCastFaceDown()) - || sa.isManifestUp() || sa.isMorphUp()) { - return true; - } - continue; - } - //handled in meetsManaShardRestrictions if (restriction.equals("CantPayGenericCosts")) { return true; @@ -422,10 +396,6 @@ public class AbilityManaPart implements java.io.Serializable { } } - if (restriction.equals("CantCastNonArtifactSpells")) { - return !sa.isSpell() || sa.getHostCard().isArtifact(); - } - // the payment is for a resolving SA, currently no other restrictions would allow that if (getSourceCard().getGame().getStack().getInstanceMatchingSpellAbilityID(sa.getRootAbility()) != null) { return false; diff --git a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java index c3f3fc9205e..c17c631be07 100644 --- a/forge-game/src/main/java/forge/game/spellability/SpellAbility.java +++ b/forge-game/src/main/java/forge/game/spellability/SpellAbility.java @@ -557,7 +557,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit return this.hasParam("Ninjutsu"); } - public boolean isCumulativeupkeep() { + public boolean isCumulativeUpkeep() { return hasParam("CumulativeUpkeep"); } diff --git a/forge-gui/res/cardsfolder/a/adarkar_unicorn.txt b/forge-gui/res/cardsfolder/a/adarkar_unicorn.txt index ed102f3d46c..5195f816011 100644 --- a/forge-gui/res/cardsfolder/a/adarkar_unicorn.txt +++ b/forge-gui/res/cardsfolder/a/adarkar_unicorn.txt @@ -2,8 +2,8 @@ Name:Adarkar Unicorn ManaCost:1 W W Types:Creature Unicorn PT:2/2 -A:AB$ Mana | Cost$ T | Produced$ C U | RestrictValid$ CumulativeUpkeep | SpellDescription$ Add {C}{U}. Spend this mana only to pay cumulative upkeep costs. -A:AB$ Mana | Cost$ T | Produced$ U | RestrictValid$ CumulativeUpkeep | SpellDescription$ Add {U}. Spend this mana only to pay cumulative upkeep costs. +A:AB$ Mana | Cost$ T | Produced$ C U | RestrictValid$ Trigger.CumulativeUpkeep | SpellDescription$ Add {C}{U}. Spend this mana only to pay cumulative upkeep costs. +A:AB$ Mana | Cost$ T | Produced$ U | RestrictValid$ Trigger.CumulativeUpkeep | SpellDescription$ Add {U}. Spend this mana only to pay cumulative upkeep costs. AI:RemoveDeck:All AI:RemoveDeck:Random Oracle:{T}: Add {U} or {C}{U}. Spend this mana only to pay cumulative upkeep costs. diff --git a/forge-gui/res/cardsfolder/b/battery_bearer.txt b/forge-gui/res/cardsfolder/b/battery_bearer.txt index 8b5a7c0bf3c..9123a820a59 100644 --- a/forge-gui/res/cardsfolder/b/battery_bearer.txt +++ b/forge-gui/res/cardsfolder/b/battery_bearer.txt @@ -3,7 +3,7 @@ ManaCost:2 G U Types:Creature Human Artificer PT:3/4 S:Mode$ Continuous | Affected$ Creature.YouCtrl | AddAbility$ AnyMana | Description$ Creatures you control have "{T}: add {C}. This mana can't be spent to cast a nonartifact spell." -SVar:AnyMana:AB$ Mana | Cost$ T | Produced$ C | Amount$ 1 | RestrictValid$ CantCastNonArtifactSpells | SpellDescription$ add {C}. This mana can't be spent to cast a nonartifact spell. +SVar:AnyMana:AB$ Mana | Cost$ T | Produced$ C | Amount$ 1 | RestrictValid$ !Spell.!Artifact | SpellDescription$ add {C}. This mana can't be spent to cast a nonartifact spell. T:Mode$ SpellCast | ValidCard$ Artifact.cmcGE6 | ValidActivatingPlayer$ You | TriggerZones$ Battlefield | Execute$ DBDraw | TriggerDescription$ Whenever you cast an artifact spell with mana value 6 or greater, draw a card. SVar:DBDraw:DB$ Draw DeckNeeds:Type$Artifact diff --git a/forge-gui/res/cardsfolder/j/jetfire_ingenious_scientist_jetfire_air_guardian.txt b/forge-gui/res/cardsfolder/j/jetfire_ingenious_scientist_jetfire_air_guardian.txt index ec3840254a4..50f9a5e4d40 100644 --- a/forge-gui/res/cardsfolder/j/jetfire_ingenious_scientist_jetfire_air_guardian.txt +++ b/forge-gui/res/cardsfolder/j/jetfire_ingenious_scientist_jetfire_air_guardian.txt @@ -4,7 +4,7 @@ Types:Legendary Artifact Creature Robot PT:3/4 K:More Than Meets the Eye:3 U K:Flying -A:AB$ Mana | Cost$ RemoveAnyCounter | XMin$ 1 | ValidTgts$ Player | Produced$ C | Amount$ X | AmountDesc$ for each counter removed | RestrictValid$ CantCastNonArtifactSpells | SubAbility$ DBConvert | SpellDescription$ Target player adds that much {C}. This mana can't be spent to cast nonartifact spells. +A:AB$ Mana | Cost$ RemoveAnyCounter | XMin$ 1 | ValidTgts$ Player | Produced$ C | Amount$ X | AmountDesc$ for each counter removed | RestrictValid$ !Spell.!Artifact | SubAbility$ DBConvert | SpellDescription$ Target player adds that much {C}. This mana can't be spent to cast nonartifact spells. SVar:DBConvert:DB$ SetState | Mode$ Transform | StackDescription$ SpellDescription | SpellDescription$ Convert NICKNAME. SVar:X:Count$xPaid AlternateMode:DoubleFaced diff --git a/forge-gui/res/cardsfolder/k/karn_legacy_reforged.txt b/forge-gui/res/cardsfolder/k/karn_legacy_reforged.txt index f5c3420a193..73265191c3f 100644 --- a/forge-gui/res/cardsfolder/k/karn_legacy_reforged.txt +++ b/forge-gui/res/cardsfolder/k/karn_legacy_reforged.txt @@ -4,7 +4,7 @@ Types:Legendary Artifact Creature Golem PT:*/* S:Mode$ Continuous | EffectZone$ All | CharacteristicDefining$ True | SetPower$ X | SetToughness$ X | Description$ CARDNAME's power and toughness are each equal to the greatest mana value among artifacts you control. T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | Execute$ ArtifactMana | TriggerZones$ Battlefield | TriggerDescription$ At the beginning of your upkeep, add {C} for each artifact you control. This mana can't be spent to cast nonartifact spells. Until end of turn, you don't lose this mana as steps and phases end. -SVar:ArtifactMana:DB$ Mana | Produced$ C | Amount$ Y | PersistentMana$ True | RestrictValid$ CantCastNonArtifactSpells +SVar:ArtifactMana:DB$ Mana | Produced$ C | Amount$ Y | PersistentMana$ True | RestrictValid$ !Spell.!Artifact SVar:X:Count$Valid Artifact.YouCtrl$GreatestCMC SVar:Y:Count$Valid Artifact.YouCtrl SVar:BuffedBy:Artifact diff --git a/forge-gui/res/cardsfolder/s/snowfall.txt b/forge-gui/res/cardsfolder/s/snowfall.txt index d6ef2cb6c5b..dc80c011964 100644 --- a/forge-gui/res/cardsfolder/s/snowfall.txt +++ b/forge-gui/res/cardsfolder/s/snowfall.txt @@ -3,8 +3,8 @@ ManaCost:2 U Types:Enchantment K:Cumulative upkeep:U T:Mode$ TapsForMana | ValidCard$ Island | Execute$ TrigMana | Static$ True | TriggerZones$ Battlefield | OptionalDecider$ TriggeredCardController | TriggerDescription$ Whenever an Island is tapped for mana, its controller may add an additional {U}. If that Island is snow, its controller may add an additional {U}{U} instead. Spend this mana only to pay cumulative upkeep costs. -SVar:TrigMana:DB$ Mana | Produced$ U | Amount$ 1 | Defined$ TriggeredCardController | RestrictValid$ CumulativeUpkeep | ConditionDefined$ TriggeredCard | ConditionPresent$ Land.Snow | ConditionCompare$ EQ0 | SubAbility$ DBMana -SVar:DBMana:DB$ Mana | Produced$ U | Amount$ 2 | Defined$ TriggeredCardController | RestrictValid$ CumulativeUpkeep | ConditionDefined$ TriggeredCard | ConditionPresent$ Land.Snow | ConditionCompare$ GE1 +SVar:TrigMana:DB$ Mana | Produced$ U | Amount$ 1 | Defined$ TriggeredCardController | RestrictValid$ Trigger.CumulativeUpkeep | ConditionDefined$ TriggeredCard | ConditionPresent$ Land.Snow | ConditionCompare$ EQ0 | SubAbility$ DBMana +SVar:DBMana:DB$ Mana | Produced$ U | Amount$ 2 | Defined$ TriggeredCardController | RestrictValid$ Trigger.CumulativeUpkeep | ConditionDefined$ TriggeredCard | ConditionPresent$ Land.Snow | ConditionCompare$ GE1 AI:RemoveDeck:Random AI:RemoveDeck:All Oracle:Cumulative upkeep {U} (At the beginning of your upkeep, put an age counter on this permanent, then sacrifice it unless you pay its upkeep cost for each age counter on it.)\nWhenever an Island is tapped for mana, its controller may add an additional {U}. If that Island is snow, its controller may add an additional {U}{U} instead. Spend this mana only to pay cumulative upkeep costs. diff --git a/forge-gui/res/cardsfolder/t/the_mightstone_and_weakstone.txt b/forge-gui/res/cardsfolder/t/the_mightstone_and_weakstone.txt index 86eb04dbe61..b7d57cd157f 100644 --- a/forge-gui/res/cardsfolder/t/the_mightstone_and_weakstone.txt +++ b/forge-gui/res/cardsfolder/t/the_mightstone_and_weakstone.txt @@ -5,7 +5,7 @@ T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.S SVar:TrigCharm:DB$ Charm | Choices$ DBDraw,DBPump SVar:DBDraw:DB$ Draw | Defined$ You | NumCards$ 2 | SpellDescription$ Draw two cards. SVar:DBPump:DB$ Pump | IsCurse$ True | ValidTgts$ Creature | TgtPrompt$ Select target creature | NumAtt$ -5 | NumDef$ -5 | SpellDescription$ Target creature gets -5/-5 until end of turn. -A:AB$ Mana | Cost$ T | Produced$ C | Amount$ 2 | RestrictValid$ CantCastNonArtifactSpells | SpellDescription$ Add {C}{C}. This mana can't be spent to cast nonartifact spells. +A:AB$ Mana | Cost$ T | Produced$ C | Amount$ 2 | RestrictValid$ !Spell.!Artifact | SpellDescription$ Add {C}{C}. This mana can't be spent to cast nonartifact spells. DeckHints:Name$Urza, Lord Protector MeldPair:Urza, Lord Protector AlternateMode:Meld diff --git a/forge-gui/res/cardsfolder/t/thran_turbine.txt b/forge-gui/res/cardsfolder/t/thran_turbine.txt index a80274d1663..f4788c737d8 100644 --- a/forge-gui/res/cardsfolder/t/thran_turbine.txt +++ b/forge-gui/res/cardsfolder/t/thran_turbine.txt @@ -2,6 +2,6 @@ Name:Thran Turbine ManaCost:1 Types:Artifact T:Mode$ Phase | Phase$ Upkeep | ValidPlayer$ You | OptionalDecider$ You | TriggerZones$ Battlefield | Execute$ DBMana | TriggerDescription$ At the beginning of your upkeep, you may add {C}{C}. You can't spend this mana to cast spells. -SVar:DBMana:DB$ Mana | Amount$ 2 | Produced$ C | RestrictValid$ nonSpell +SVar:DBMana:DB$ Mana | Amount$ 2 | Produced$ C | RestrictValid$ !Spell AI:RemoveDeck:Random Oracle:At the beginning of your upkeep, you may add {C}{C}. You can't spend this mana to cast spells. diff --git a/forge-gui/res/cardsfolder/u/unblinking_observer.txt b/forge-gui/res/cardsfolder/u/unblinking_observer.txt index d85d793d93d..e4536759a36 100644 --- a/forge-gui/res/cardsfolder/u/unblinking_observer.txt +++ b/forge-gui/res/cardsfolder/u/unblinking_observer.txt @@ -2,7 +2,7 @@ Name:Unblinking Observer ManaCost:1 U Types:Creature Homunculus PT:2/1 -A:AB$ Mana | Cost$ T | Produced$ U | RestrictValid$ Disturb,Spell.Instant,Spell.Sorcery | SpellDescription$ Add {U}. Spend this mana only to pay a disturb cost or cast an instant or sorcery spell. +A:AB$ Mana | Cost$ T | Produced$ U | RestrictValid$ Spell.Disturb,Spell.Instant,Spell.Sorcery | SpellDescription$ Add {U}. Spend this mana only to pay a disturb cost or cast an instant or sorcery spell. DeckNeeds:Type$Instant|Sorcery DeckHints:Keyword$Disturb Oracle:{T}: Add {U}. Spend this mana only to pay a disturb cost or cast an instant or sorcery spell. diff --git a/forge-gui/res/tokenscripts/c_a_powerstone.txt b/forge-gui/res/tokenscripts/c_a_powerstone.txt index 12f067bf94e..3e666568200 100644 --- a/forge-gui/res/tokenscripts/c_a_powerstone.txt +++ b/forge-gui/res/tokenscripts/c_a_powerstone.txt @@ -2,6 +2,6 @@ Name:Powerstone token ManaCost:no cost Types:Artifact Powerstone Colors:colorless -A:AB$ Mana | Cost$ T | Produced$ C | RestrictValid$ CantCastNonArtifactSpells | SpellDescription$ Add {C}. This mana can't be spent to cast a nonartifact spell. +A:AB$ Mana | Cost$ T | Produced$ C | RestrictValid$ !Spell.!Artifact | SpellDescription$ Add {C}. This mana can't be spent to cast a nonartifact spell. Oracle:{T}: Add {C}. This mana can't be spent to cast a nonartifact spell.