From e4acf7affb868f5029c035b71784119b32c8f43c Mon Sep 17 00:00:00 2001 From: 18ths <13023067+18ths@users.noreply.github.com> Date: Sat, 6 Jun 2020 06:01:36 +0200 Subject: [PATCH] fixed #6540 qasali ambusher (#6573) * Qasali Ambusher - fixed that it can't be casted without mana cost and with flash (#6540) --- .../src/mage/cards/q/QasaliAmbusher.java | 90 ++++++------------- 1 file changed, 29 insertions(+), 61 deletions(-) diff --git a/Mage.Sets/src/mage/cards/q/QasaliAmbusher.java b/Mage.Sets/src/mage/cards/q/QasaliAmbusher.java index 9fa8d530231..32f19ddb9e2 100644 --- a/Mage.Sets/src/mage/cards/q/QasaliAmbusher.java +++ b/Mage.Sets/src/mage/cards/q/QasaliAmbusher.java @@ -2,16 +2,22 @@ package mage.cards.q; import java.util.UUID; import mage.MageInt; -import mage.abilities.ActivatedAbilityImpl; -import mage.abilities.costs.mana.ManaCostsImpl; +import mage.abilities.Ability; +import mage.abilities.condition.CompoundCondition; +import mage.abilities.condition.Condition; +import mage.abilities.condition.common.AttackedThisStepCondition; +import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; +import mage.abilities.costs.AlternativeCostSourceAbility; +import mage.abilities.decorator.ConditionalAsThoughEffect; import mage.abilities.effects.common.continuous.CastAsThoughItHadFlashSourceEffect; import mage.abilities.keyword.ReachAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.*; import mage.filter.common.FilterControlledLandPermanent; -import mage.game.Game; -import mage.game.combat.CombatGroup; +import mage.filter.common.FilterControlledPermanent; +import mage.filter.predicate.Predicates; +import mage.watchers.common.PlayerAttackedStepWatcher; /** * @@ -19,6 +25,18 @@ import mage.game.combat.CombatGroup; */ public final class QasaliAmbusher extends CardImpl { + private static final FilterControlledPermanent filterForest = new FilterControlledPermanent(); + private static final FilterControlledPermanent filterPlains = new FilterControlledPermanent(); + + static { + filterForest.add(SubType.FOREST.getPredicate()); + filterPlains.add(SubType.PLAINS.getPredicate()); + } + + private static final Condition condition = + new CompoundCondition("If a creature is attacking you and you control a Forest and a Plains", + AttackedThisStepCondition.instance, new PermanentsOnTheBattlefieldCondition(filterForest), new PermanentsOnTheBattlefieldCondition(filterPlains)); + public QasaliAmbusher(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{G}{W}"); this.subtype.add(SubType.CAT); @@ -30,10 +48,13 @@ public final class QasaliAmbusher extends CardImpl { // Reach this.addAbility(ReachAbility.getInstance()); - // If a creature is attacking you and you control a Forest and a Plains, + // If a creature is attacking you and you control a Forest and a Plains, // you may cast Qasali Ambusher without paying its mana cost and as though it had flash. - this.addAbility(new QasaliAmbusherAbility()); - + Ability ability = new AlternativeCostSourceAbility(null, condition); + ability.addEffect(new ConditionalAsThoughEffect(new CastAsThoughItHadFlashSourceEffect(Duration.EndOfGame), condition) + .setText("you may cast {this} without paying its mana cost and as though it had flash")); + ability.addWatcher(new PlayerAttackedStepWatcher()); + this.addAbility(ability); } public QasaliAmbusher(final QasaliAmbusher card) { @@ -44,57 +65,4 @@ public final class QasaliAmbusher extends CardImpl { public QasaliAmbusher copy() { return new QasaliAmbusher(this); } -} - -class QasaliAmbusherAbility extends ActivatedAbilityImpl { - - private static final FilterControlledLandPermanent filterPlains = new FilterControlledLandPermanent(); - private static final FilterControlledLandPermanent filterForest = new FilterControlledLandPermanent(); - - static { - filterPlains.add(SubType.PLAINS.getPredicate()); - filterForest.add(SubType.FOREST.getPredicate()); - } - - public QasaliAmbusherAbility() { - super(Zone.HAND, new CastAsThoughItHadFlashSourceEffect(Duration.EndOfGame), new ManaCostsImpl()); - this.timing = TimingRule.INSTANT; - this.usesStack = false; - } - - public QasaliAmbusherAbility(final QasaliAmbusherAbility ability) { - super(ability); - } - - @Override - public QasaliAmbusherAbility copy() { - return new QasaliAmbusherAbility(this); - } - - @Override - public ActivationStatus canActivate(UUID playerId, Game game) { - if (!game.getBattlefield().getActivePermanents(filterPlains, - this.getControllerId(), this.getSourceId(), game).isEmpty() - && !game.getBattlefield().getActivePermanents(filterForest, - this.getControllerId(), this.getSourceId(), game).isEmpty()) { - for (CombatGroup group : game.getCombat().getGroups()) { - if (isControlledBy(group.getDefenderId())) { - return super.canActivate(playerId, game); - } - } - } - return ActivationStatus.getFalse(); - } - - @Override - public String getRule(boolean all) { - return this.getRule(); - } - - @Override - public String getRule() { - return "If a creature is attacking you and you control a Forest and " - + "a Plains, you may cast {this} without paying its mana " - + "cost and as though it had flash."; - } -} +} \ No newline at end of file