From 1eec7475fe2f3bc864eea8fbd6068aa848bc1353 Mon Sep 17 00:00:00 2001 From: Tim Mocny Date: Fri, 5 Feb 2021 16:24:24 +0000 Subject: [PATCH] KHM: Codespell Cleric and support --- .../game/trigger/TriggerChangesZone.java | 21 ++++++++++++++++--- .../cardsfolder/upcoming/codespell_cleric.txt | 9 ++++++++ 2 files changed, 27 insertions(+), 3 deletions(-) create mode 100644 forge-gui/res/cardsfolder/upcoming/codespell_cleric.txt diff --git a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java index 960dac7d775..f1fbf8ac5d4 100644 --- a/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java +++ b/forge-game/src/main/java/forge/game/trigger/TriggerChangesZone.java @@ -17,16 +17,17 @@ */ package forge.game.trigger; +import com.google.common.base.Predicates; +import com.google.common.collect.Iterables; import forge.game.ability.AbilityKey; import forge.game.ability.AbilityUtils; -import forge.game.card.Card; -import forge.game.card.CardFactoryUtil; -import forge.game.card.CardUtil; +import forge.game.card.*; import forge.game.spellability.SpellAbility; import forge.game.zone.ZoneType; import forge.util.Expressions; import java.util.EnumSet; +import java.util.List; import java.util.Map; import forge.util.Localizer; @@ -171,6 +172,20 @@ public class TriggerChangesZone extends Trigger { } } + /* this trigger only activates for the nth spell you cast this turn */ + if (hasParam("ConditionYouCastThisTurn")) { + final String compare = getParam("ConditionYouCastThisTurn"); + List thisTurnCast = CardUtil.getThisTurnCast("Card", getHostCard()); + thisTurnCast = CardLists.filterControlledByAsList(thisTurnCast, getHostCard().getController()); + + // checks which card this spell was the castSA + int left = Iterables.indexOf(thisTurnCast, CardPredicates.castSA(Predicates.equalTo(getHostCard().getCastSA()))); + int right = Integer.parseInt(compare.substring(2)); + if (!Expressions.compare(left + 1, compare, right)) { + return false; + } + } + return true; } diff --git a/forge-gui/res/cardsfolder/upcoming/codespell_cleric.txt b/forge-gui/res/cardsfolder/upcoming/codespell_cleric.txt new file mode 100644 index 00000000000..c2b922109ae --- /dev/null +++ b/forge-gui/res/cardsfolder/upcoming/codespell_cleric.txt @@ -0,0 +1,9 @@ +Name:Codespell Cleric +ManaCost:W +Types:Creature Human Cleric +PT:1/1 +K:Vigilance +T:Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | ConditionYouCastThisTurn$ EQ2 | Execute$ TrigPutCounter | TriggerDescription$ When CARDNAME enters the battlefield, if it was the second spell you cast this turn, put a +1/+1 counter on target creature. +SVar:TrigPutCounter:DB$ PutCounter | ValidTgts$ Creature | TgtPrompt$ Select target creature | CounterType$ P1P1 | CounterNum$ 1 +DeckHas:Ability$Counters +Oracle:Vigilance\nWhen Codespell Cleric enters the battlefield, if it was the second spell you cast this turn, put a +1/+1 counter on target creature.