From a2840cd148ae203991498e3ed86bbc9fa0203e94 Mon Sep 17 00:00:00 2001 From: Zzooouhh Date: Thu, 7 Dec 2017 22:49:18 +0100 Subject: [PATCH] Doom Cannon fix --- Mage.Sets/src/mage/cards/d/DoomCannon.java | 36 +++++++++++++++++++--- 1 file changed, 32 insertions(+), 4 deletions(-) diff --git a/Mage.Sets/src/mage/cards/d/DoomCannon.java b/Mage.Sets/src/mage/cards/d/DoomCannon.java index 33ae3a9b366..383bf31b35b 100644 --- a/Mage.Sets/src/mage/cards/d/DoomCannon.java +++ b/Mage.Sets/src/mage/cards/d/DoomCannon.java @@ -39,10 +39,12 @@ import mage.abilities.effects.common.DamageTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; +import mage.constants.SubType; import mage.constants.Outcome; import mage.constants.Zone; import mage.filter.common.FilterControlledCreaturePermanent; -import mage.filter.predicate.mageobject.ChosenSubtypePredicate; +import mage.game.Game; +import mage.game.permanent.Permanent; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.common.TargetCreatureOrPlayer; @@ -59,11 +61,9 @@ public class DoomCannon extends CardImpl { this.addAbility(new AsEntersBattlefieldAbility(new ChooseCreatureTypeEffect(Outcome.Sacrifice))); // {3}, {T}, Sacrifice a creature of the chosen type: Doom Cannon deals 3 damage to target creature or player. - FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("a creature of the chosen type"); - filter.add(new ChosenSubtypePredicate(this.getId())); Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(3), new GenericManaCost(3)); ability.addCost(new TapSourceCost()); - ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(filter))); + ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(new DoomCannonFilter()))); ability.addTarget(new TargetCreatureOrPlayer()); this.addAbility(ability); } @@ -77,3 +77,31 @@ public class DoomCannon extends CardImpl { return new DoomCannon(this); } } + +class DoomCannonFilter extends FilterControlledCreaturePermanent { + + public DoomCannonFilter() { + super("a creature of the chosen type"); + } + + public DoomCannonFilter(final DoomCannonFilter filter) { + super(filter); + } + + @Override + public DoomCannonFilter copy() { + return new DoomCannonFilter(this); + } + + @Override + public boolean match(Permanent permanent, UUID sourceId, UUID playerId, Game game) { + if (super.match(permanent, sourceId, playerId, game)) { + SubType subtype = (SubType) game.getState().getValue(sourceId + "_type"); + if (subtype != null && permanent.hasSubtype(subtype, game)) { + return true; + } + } + return false; + } + +}