From 4a24ab0ba8720a8e4135564b8de7e2b55d266ddf Mon Sep 17 00:00:00 2001 From: Evan Kranzler Date: Fri, 4 Jan 2019 15:39:23 -0500 Subject: [PATCH] Implemented Titanic Brawl --- Mage.Sets/src/mage/cards/s/SavageStomp.java | 33 +++---- Mage.Sets/src/mage/cards/t/TitanicBrawl.java | 87 +++++++++++++++++++ .../src/mage/sets/RavnicaAllegiance.java | 1 + 3 files changed, 102 insertions(+), 19 deletions(-) create mode 100644 Mage.Sets/src/mage/cards/t/TitanicBrawl.java diff --git a/Mage.Sets/src/mage/cards/s/SavageStomp.java b/Mage.Sets/src/mage/cards/s/SavageStomp.java index 8a080176193..38dfe0ebf84 100644 --- a/Mage.Sets/src/mage/cards/s/SavageStomp.java +++ b/Mage.Sets/src/mage/cards/s/SavageStomp.java @@ -1,8 +1,6 @@ package mage.cards.s; -import java.util.Iterator; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; import mage.abilities.condition.Condition; @@ -18,7 +16,6 @@ import mage.constants.TargetController; import mage.constants.Zone; import mage.counters.CounterType; import mage.filter.common.FilterCreaturePermanent; -import mage.filter.predicate.mageobject.SubtypePredicate; import mage.filter.predicate.permanent.ControllerPredicate; import mage.game.Game; import mage.game.permanent.Permanent; @@ -27,13 +24,16 @@ import mage.target.Target; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreaturePermanent; +import java.util.Iterator; +import java.util.UUID; + /** - * * @author TheElk801 */ public final class SavageStomp extends CardImpl { - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature you don't control"); + private static final FilterCreaturePermanent filter + = new FilterCreaturePermanent("creature you don't control"); static { filter.add(new ControllerPredicate(TargetController.NOT_YOU)); @@ -70,23 +70,19 @@ public final class SavageStomp extends CardImpl { enum SavageStompCondition implements Condition { instance; - private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("Dinosaur you control"); - - static { - filter.add(new SubtypePredicate(SubType.DINOSAUR)); - filter.add(new ControllerPredicate(TargetController.YOU)); - } @Override public boolean apply(Game game, Ability source) { StackObject sourceSpell = game.getStack().getStackObject(source.getSourceId()); - if (sourceSpell != null) { - Iterator targets = sourceSpell.getStackAbility().getTargets().iterator(); - while (targets.hasNext()) { - Permanent permanent = game.getPermanentOrLKIBattlefield(targets.next().getFirstTarget()); - if (permanent != null && filter.match(permanent, game) && permanent.isControlledBy(source.getControllerId())) { - return true; - } + if (sourceSpell == null) { + return false; + } + Iterator targets = sourceSpell.getStackAbility().getTargets().iterator(); + while (targets.hasNext()) { + Permanent permanent = game.getPermanentOrLKIBattlefield(targets.next().getFirstTarget()); + if (permanent != null && permanent.hasSubtype(SubType.DINOSAUR, game) + && permanent.isControlledBy(source.getControllerId())) { + return true; } } return false; @@ -96,5 +92,4 @@ enum SavageStompCondition implements Condition { public String toString() { return "it targets a Dinosaur you control"; } - } diff --git a/Mage.Sets/src/mage/cards/t/TitanicBrawl.java b/Mage.Sets/src/mage/cards/t/TitanicBrawl.java new file mode 100644 index 00000000000..0e097fdc1d4 --- /dev/null +++ b/Mage.Sets/src/mage/cards/t/TitanicBrawl.java @@ -0,0 +1,87 @@ +package mage.cards.t; + +import mage.abilities.Ability; +import mage.abilities.common.SimpleStaticAbility; +import mage.abilities.condition.Condition; +import mage.abilities.effects.common.FightTargetsEffect; +import mage.abilities.effects.common.cost.SpellCostReductionSourceEffect; +import mage.cards.CardImpl; +import mage.cards.CardSetInfo; +import mage.constants.CardType; +import mage.constants.TargetController; +import mage.constants.Zone; +import mage.counters.CounterType; +import mage.filter.common.FilterCreaturePermanent; +import mage.filter.predicate.permanent.ControllerPredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; +import mage.game.stack.StackObject; +import mage.target.Target; +import mage.target.common.TargetControlledCreaturePermanent; +import mage.target.common.TargetCreaturePermanent; + +import java.util.Iterator; +import java.util.UUID; + +/** + * @author TheElk801 + */ +public final class TitanicBrawl extends CardImpl { + + private static final FilterCreaturePermanent filter + = new FilterCreaturePermanent("creature you don't control"); + + static { + filter.add(new ControllerPredicate(TargetController.NOT_YOU)); + } + + public TitanicBrawl(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{1}{G}"); + + // This spell costs {1} less to cast if it targets a creature you control with a +1/+1 counter on it. + this.addAbility(new SimpleStaticAbility(Zone.STACK, + new SpellCostReductionSourceEffect(1, TitanicBrawlCondition.instance)) + .setRuleAtTheTop(true)); + + // Target creature you control fights target creature you don't control. + this.getSpellAbility().addEffect(new FightTargetsEffect()); + this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); + this.getSpellAbility().addTarget(new TargetCreaturePermanent(filter)); + } + + private TitanicBrawl(final TitanicBrawl card) { + super(card); + } + + @Override + public TitanicBrawl copy() { + return new TitanicBrawl(this); + } +} + +enum TitanicBrawlCondition implements Condition { + instance; + + @Override + public boolean apply(Game game, Ability source) { + StackObject sourceSpell = game.getStack().getStackObject(source.getSourceId()); + if (sourceSpell == null) { + return false; + } + Iterator targets = sourceSpell.getStackAbility().getTargets().iterator(); + while (targets.hasNext()) { + Permanent permanent = game.getPermanentOrLKIBattlefield(targets.next().getFirstTarget()); + if (permanent != null && permanent.getCounters(game).containsKey(CounterType.P1P1) + && permanent.isControlledBy(source.getControllerId())) { + return true; + } + } + return false; + } + + @Override + public String toString() { + return "it targets a creature you control with a +1/+1 counter on it"; + } + +} diff --git a/Mage.Sets/src/mage/sets/RavnicaAllegiance.java b/Mage.Sets/src/mage/sets/RavnicaAllegiance.java index 73f73c57191..02a18566392 100644 --- a/Mage.Sets/src/mage/sets/RavnicaAllegiance.java +++ b/Mage.Sets/src/mage/sets/RavnicaAllegiance.java @@ -107,6 +107,7 @@ public final class RavnicaAllegiance extends ExpansionSet { cards.add(new SetCardInfo("Stomping Ground", 259, Rarity.RARE, mage.cards.s.StompingGround.class)); cards.add(new SetCardInfo("Teysa Karlov", 212, Rarity.RARE, mage.cards.t.TeysaKarlov.class)); cards.add(new SetCardInfo("The Haunt of Hightower", 273, Rarity.MYTHIC, mage.cards.t.TheHauntOfHightower.class)); + cards.add(new SetCardInfo("Titanic Brawl", 146, Rarity.COMMON, mage.cards.t.TitanicBrawl.class)); cards.add(new SetCardInfo("Tithe Taker", 27, Rarity.RARE, mage.cards.t.TitheTaker.class)); cards.add(new SetCardInfo("Wilderness Reclamation", 149, Rarity.UNCOMMON, mage.cards.w.WildernessReclamation.class)); cards.add(new SetCardInfo("Zegana, Utopian Speaker", 214, Rarity.RARE, mage.cards.z.ZeganaUtopianSpeaker.class));