From a264344485561c25fbe7d4f2741f42afc0087b1e Mon Sep 17 00:00:00 2001 From: Northmoc Date: Sat, 29 Oct 2022 18:20:43 -0400 Subject: [PATCH] DMU: Defiler cycle and support --- .../main/java/forge/game/GameActionUtil.java | 36 +++++++++++++++++++ .../java/forge/game/cost/CostAdjustment.java | 17 +++++++++ .../forge/game/spellability/OptionalCost.java | 5 +++ .../game/spellability/OptionalCostValue.java | 3 +- .../res/cardsfolder/d/defiler_of_dreams.txt | 10 ++++++ .../res/cardsfolder/d/defiler_of_faith.txt | 11 ++++++ .../res/cardsfolder/d/defiler_of_flesh.txt | 10 ++++++ .../res/cardsfolder/d/defiler_of_instinct.txt | 10 ++++++ .../res/cardsfolder/d/defiler_of_vigor.txt | 11 ++++++ 9 files changed, 112 insertions(+), 1 deletion(-) create mode 100644 forge-gui/res/cardsfolder/d/defiler_of_dreams.txt create mode 100644 forge-gui/res/cardsfolder/d/defiler_of_faith.txt create mode 100644 forge-gui/res/cardsfolder/d/defiler_of_flesh.txt create mode 100644 forge-gui/res/cardsfolder/d/defiler_of_instinct.txt create mode 100644 forge-gui/res/cardsfolder/d/defiler_of_vigor.txt diff --git a/forge-game/src/main/java/forge/game/GameActionUtil.java b/forge-game/src/main/java/forge/game/GameActionUtil.java index a9271c3cadc..e1f4bd077b3 100644 --- a/forge-game/src/main/java/forge/game/GameActionUtil.java +++ b/forge-game/src/main/java/forge/game/GameActionUtil.java @@ -23,6 +23,7 @@ import java.util.Map; import com.google.common.collect.*; import forge.game.card.*; +import forge.game.staticability.StaticAbility; import forge.util.Aggregates; import org.apache.commons.lang3.StringUtils; @@ -446,6 +447,41 @@ public final class GameActionUtil { game.getAction().checkStaticAbilities(false, Sets.newHashSet(source), preList); } + for (final Card ca : game.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES)) { + for (final StaticAbility stAb : ca.getStaticAbilities()) { + if (!stAb.getParam("Mode").equals("OptionalCost") || stAb.isSuppressed() || !stAb.checkConditions()) { + continue; + } + + if (!stAb.matchesValidParam("ValidCard", source)) { + continue; + } + if (!stAb.matchesValidParam("ValidSA", sa)) { + continue; + } + if (!stAb.matchesValidParam("Activator", sa.getActivatingPlayer())) { + continue; + } + + final Cost cost = new Cost(stAb.getParam("Cost"), false); + if (stAb.hasParam("ReduceColor")) { + if (stAb.getParam("ReduceColor").equals("W")) { + costs.add(new OptionalCostValue(OptionalCost.ReduceW, cost)); + } else if (stAb.getParam("ReduceColor").equals("U")) { + costs.add(new OptionalCostValue(OptionalCost.ReduceU, cost)); + } else if (stAb.getParam("ReduceColor").equals("B")) { + costs.add(new OptionalCostValue(OptionalCost.ReduceB, cost)); + } else if (stAb.getParam("ReduceColor").equals("R")) { + costs.add(new OptionalCostValue(OptionalCost.ReduceR, cost)); + } else if (stAb.getParam("ReduceColor").equals("G")) { + costs.add(new OptionalCostValue(OptionalCost.ReduceG, cost)); + } + } else { + costs.add(new OptionalCostValue(OptionalCost.AltCost, cost)); + } + } + } + for (KeywordInterface inst : source.getKeywords()) { final String keyword = inst.getOriginal(); if (keyword.startsWith("Buyback")) { diff --git a/forge-game/src/main/java/forge/game/cost/CostAdjustment.java b/forge-game/src/main/java/forge/game/cost/CostAdjustment.java index 1a3b41df03e..acf85b5d268 100644 --- a/forge-game/src/main/java/forge/game/cost/CostAdjustment.java +++ b/forge-game/src/main/java/forge/game/cost/CostAdjustment.java @@ -4,6 +4,7 @@ import java.util.List; import java.util.Map; import java.util.Map.Entry; +import forge.game.spellability.OptionalCost; import org.apache.commons.lang3.StringUtils; import com.google.common.base.Strings; @@ -208,6 +209,22 @@ public class CostAdjustment { // need to reduce generic extra because of 2 hybrid mana cost.decreaseGenericMana(sumGeneric); + if (sa.isSpell() && sa.isOptionalCostPaid(OptionalCost.ReduceW)) { + cost.decreaseShard(ManaCostShard.parseNonGeneric("W"), 1); + } + if (sa.isSpell() && sa.isOptionalCostPaid(OptionalCost.ReduceU)) { + cost.decreaseShard(ManaCostShard.parseNonGeneric("U"), 1); + } + if (sa.isSpell() && sa.isOptionalCostPaid(OptionalCost.ReduceB)) { + cost.decreaseShard(ManaCostShard.parseNonGeneric("B"), 1); + } + if (sa.isSpell() && sa.isOptionalCostPaid(OptionalCost.ReduceR)) { + cost.decreaseShard(ManaCostShard.parseNonGeneric("R"), 1); + } + if (sa.isSpell() && sa.isOptionalCostPaid(OptionalCost.ReduceG)) { + cost.decreaseShard(ManaCostShard.parseNonGeneric("G"), 1); + } + if (sa.isSpell() && sa.isOffering()) { // cost reduction from offerings adjustCostByOffering(cost, sa); } diff --git a/forge-game/src/main/java/forge/game/spellability/OptionalCost.java b/forge-game/src/main/java/forge/game/spellability/OptionalCost.java index 536edca813f..73c2053de80 100644 --- a/forge-game/src/main/java/forge/game/spellability/OptionalCost.java +++ b/forge-game/src/main/java/forge/game/spellability/OptionalCost.java @@ -11,6 +11,11 @@ public enum OptionalCost { Kicker2("Kicker"), Retrace("Retrace"), Jumpstart("Jump-start"), + ReduceW("(to reduce white mana)"), + ReduceU("(to reduce blue mana)"), + ReduceB("(to reduce black mana)"), + ReduceR("(to reduce red mana)"), + ReduceG("(to reduce green mana)"), AltCost(""), Flash("Flash"), // used for Pay Extra for Flash Generic("Generic"); // used by "Dragon Presence" and pseudo-kicker cards diff --git a/forge-game/src/main/java/forge/game/spellability/OptionalCostValue.java b/forge-game/src/main/java/forge/game/spellability/OptionalCostValue.java index bd38678c8bb..aa2e20e6851 100644 --- a/forge-game/src/main/java/forge/game/spellability/OptionalCostValue.java +++ b/forge-game/src/main/java/forge/game/spellability/OptionalCostValue.java @@ -51,11 +51,12 @@ public class OptionalCostValue implements Serializable { @Override public String toString() { StringBuilder sb = new StringBuilder(); - if (type != OptionalCost.Generic) { + if (type != OptionalCost.Generic && !type.getName().startsWith("(to reduce")) { sb.append(type.getName()); sb.append(" "); } sb.append(cost.toSimpleString()); + sb.append(type.getName().startsWith("(to reduce") ? " " + type.getName() : ""); return sb.toString(); } } diff --git a/forge-gui/res/cardsfolder/d/defiler_of_dreams.txt b/forge-gui/res/cardsfolder/d/defiler_of_dreams.txt new file mode 100644 index 00000000000..95c7b94935a --- /dev/null +++ b/forge-gui/res/cardsfolder/d/defiler_of_dreams.txt @@ -0,0 +1,10 @@ +Name:Defiler of Dreams +ManaCost:3 U U +Types:Creature Phyrexian Sphinx +PT:4/3 +K:Flying +S:Mode$ OptionalCost | ValidCard$ Permanent.Blue | ValidSA$ Spell | Activator$ You | Cost$ PayLife<2> | ReduceColor$ U | Description$ As an additional cost to cast blue permanent spells, you may pay 2 life. Those spells cost {U} less to cast if you paid life this way. This effect reduces only the amount of blue mana you pay. +T:Mode$ SpellCast | ValidCard$ Permanent.Blue | ValidActivatingPlayer$ You | Execute$ TrigDraw | TriggerZones$ Battlefield | TriggerDescription$ Whenever you cast a blue permanent spell, draw a card. +SVar:TrigDraw:DB$ Draw +SVar:BuffedBy:Permanent.Blue +Oracle:Flying\nAs an additional cost to cast blue permanent spells, you may pay 2 life. Those spells cost {U} less to cast if you paid life this way. This effect reduces only the amount of blue mana you pay.\nWhenever you cast a blue permanent spell, draw a card. diff --git a/forge-gui/res/cardsfolder/d/defiler_of_faith.txt b/forge-gui/res/cardsfolder/d/defiler_of_faith.txt new file mode 100644 index 00000000000..cf62fd8cc2f --- /dev/null +++ b/forge-gui/res/cardsfolder/d/defiler_of_faith.txt @@ -0,0 +1,11 @@ +Name:Defiler of Faith +ManaCost:3 W W +Types:Creature Phyrexian Human +PT:5/5 +K:Vigilance +S:Mode$ OptionalCost | ValidCard$ Permanent.White | ValidSA$ Spell | Activator$ You | Cost$ PayLife<2> | ReduceColor$ W | Description$ As an additional cost to cast white permanent spells, you may pay 2 life. Those spells cost {W} less to cast if you paid life this way. This effect reduces only the amount of white mana you pay. +T:Mode$ SpellCast | ValidCard$ Permanent.White | ValidActivatingPlayer$ You | Execute$ TrigToken | TriggerZones$ Battlefield | TriggerDescription$ Whenever you cast a white permanent spell, create a 1/1 white Soldier creature token. +SVar:TrigToken:DB$ Token | TokenScript$ w_1_1_soldier +DeckHas:Ability$Token & Type$Soldier +SVar:BuffedBy:Permanent.White +Oracle:Vigilance\nAs an additional cost to cast white permanent spells, you may pay 2 life. Those spells cost {W} less to cast if you paid life this way. This effect reduces only the amount of white mana you pay.\nWhenever you cast a white permanent spell, create a 1/1 white Soldier creature token. diff --git a/forge-gui/res/cardsfolder/d/defiler_of_flesh.txt b/forge-gui/res/cardsfolder/d/defiler_of_flesh.txt new file mode 100644 index 00000000000..5e6ffd6c8f7 --- /dev/null +++ b/forge-gui/res/cardsfolder/d/defiler_of_flesh.txt @@ -0,0 +1,10 @@ +Name:Defiler of Flesh +ManaCost:2 B B +Types:Creature Phyrexian Horror +PT:4/4 +K:Menace +S:Mode$ OptionalCost | ValidCard$ Permanent.Black | ValidSA$ Spell | Activator$ You | Cost$ PayLife<2> | ReduceColor$ B | Description$ As an additional cost to cast black permanent spells, you may pay 2 life. Those spells cost {B} less to cast if you paid life this way. This effect reduces only the amount of black mana you pay. +T:Mode$ SpellCast | ValidCard$ Permanent.Black | ValidActivatingPlayer$ You | Execute$ TrigPump | TriggerZones$ Battlefield | TriggerDescription$ Whenever you cast a black permanent spell, target creature you control gets +1/+1 and gains menace until end of turn. +SVar:TrigPump:DB$ Pump | ValidTgts$ Creature.YouCtrl | TgtPrompt$ Select target creature you control | NumAtt$ 1 | NumDef$ 1 | KW$ Menace +SVar:BuffedBy:Permanent.Black +Oracle:Menace\nAs an additional cost to cast black permanent spells, you may pay 2 life. Those spells cost {B} less to cast if you paid life this way. This effect reduces only the amount of black mana you pay.\nWhenever you cast a black permanent spell, target creature you control gets +1/+1 and gains menace until end of turn. diff --git a/forge-gui/res/cardsfolder/d/defiler_of_instinct.txt b/forge-gui/res/cardsfolder/d/defiler_of_instinct.txt new file mode 100644 index 00000000000..8cb5c8ad3f7 --- /dev/null +++ b/forge-gui/res/cardsfolder/d/defiler_of_instinct.txt @@ -0,0 +1,10 @@ +Name:Defiler of Instinct +ManaCost:2 R R +Types:Creature Phyrexian Kavu +PT:4/4 +K:First Strike +S:Mode$ OptionalCost | ValidCard$ Permanent.Red | ValidSA$ Spell | Activator$ You | Cost$ PayLife<2> | ReduceColor$ R | Description$ As an additional cost to cast red permanent spells, you may pay 2 life. Those spells cost {R} less to cast if you paid life this way. This effect reduces only the amount of red mana you pay. +T:Mode$ SpellCast | ValidCard$ Permanent.Red | ValidActivatingPlayer$ You | Execute$ TrigDamage | TriggerZones$ Battlefield | TriggerDescription$ Whenever you cast a red permanent spell, CARDNAME deals 1 damage to any target. +SVar:TrigDamage:DB$ DealDamage | ValidTgts$ Creature,Player,Planeswalker | TgtPrompt$ Select any target | NumDmg$ 1 +SVar:BuffedBy:Permanent.Red +Oracle:First strike\nAs an additional cost to cast red permanent spells, you may pay 2 life. Those spells cost {R} less to cast if you paid life this way. This effect reduces only the amount of red mana you pay.\nWhenever you cast a red permanent spell, Defiler of Instinct deals 1 damage to any target. diff --git a/forge-gui/res/cardsfolder/d/defiler_of_vigor.txt b/forge-gui/res/cardsfolder/d/defiler_of_vigor.txt new file mode 100644 index 00000000000..bc19394eb31 --- /dev/null +++ b/forge-gui/res/cardsfolder/d/defiler_of_vigor.txt @@ -0,0 +1,11 @@ +Name:Defiler of Vigor +ManaCost:3 G G +Types:Creature Phyrexian Wurm +PT:6/6 +K:Trample +S:Mode$ OptionalCost | ValidCard$ Permanent.Green | ValidSA$ Spell | Activator$ You | Cost$ PayLife<2> | ReduceColor$ G | Description$ As an additional cost to cast green permanent spells, you may pay 2 life. Those spells cost {G} less to cast if you paid life this way. This effect reduces only the amount of green mana you pay. +T:Mode$ SpellCast | ValidCard$ Permanent.Green | ValidActivatingPlayer$ You | Execute$ TrigCounters | TriggerZones$ Battlefield | TriggerDescription$ Whenever you cast a green permanent spell, put a +1/+1 counter on each creature you control. +SVar:TrigCounters:DB$ PutCounterAll | ValidCards$ Creature.YouCtrl | CounterType$ P1P1 +DeckHas:Ability$Counters +SVar:BuffedBy:Permanent.Green +Oracle:Trample\nAs an additional cost to cast green permanent spells, you may pay 2 life. Those spells cost {G} less to cast if you paid life this way. This effect reduces only the amount of green mana you pay.\nWhenever you cast a green permanent spell, put a +1/+1 counter on each creature you control.