diff --git a/Mage.Sets/src/mage/cards/b/BlizzardBrawl.java b/Mage.Sets/src/mage/cards/b/BlizzardBrawl.java index 44e37d37f7..cb627678be 100644 --- a/Mage.Sets/src/mage/cards/b/BlizzardBrawl.java +++ b/Mage.Sets/src/mage/cards/b/BlizzardBrawl.java @@ -1,39 +1,61 @@ package mage.cards.b; -import mage.abilities.Ability; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.condition.Condition; +import mage.abilities.condition.common.PermanentsOnTheBattlefieldCondition; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.common.AddContinuousEffectToGame; +import mage.abilities.effects.common.FightTargetsEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.abilities.effects.common.continuous.GainAbilityTargetEffect; import mage.abilities.keyword.IndestructibleAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; +import mage.constants.ComparisonType; import mage.constants.SuperType; import mage.filter.FilterPermanent; import mage.filter.StaticFilters; -import mage.filter.common.FilterControlledPermanent; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import mage.target.common.TargetControlledCreaturePermanent; -import mage.target.targetpointer.FixedTarget; import java.util.UUID; /** - * @author TheElk801 + * @author awjackson */ public final class BlizzardBrawl extends CardImpl { + private static final FilterPermanent filter = new FilterPermanent("you control three or more snow permanents"); + + static { + filter.add(SuperType.SNOW.getPredicate()); + } + + private static final Condition condition = new PermanentsOnTheBattlefieldCondition(filter, ComparisonType.MORE_THAN, 2); + public BlizzardBrawl(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{G}"); this.addSuperType(SuperType.SNOW); - // Choose target creature you control and target creature you don't control. If you control three or more snow permanents, the creature you control gets +1/+0 and gains indestructible until end of turn. Then those creatures fight each other. - this.getSpellAbility().addEffect(new BlizzardBrawlEffect()); + // Choose target creature you control and target creature you don't control. + // If you control three or more snow permanents, the creature you control gets +1/+0 and gains indestructible until end of turn. + this.getSpellAbility().addEffect( + new ConditionalOneShotEffect( + new AddContinuousEffectToGame(new BoostTargetEffect(1, 0)), + condition, + "Choose target creature you control and target creature you don't control. " + + "If you control three or more snow permanents, the creature you control gets +1/+0 " + + "and gains indestructible until end of turn." + ).addEffect( + new AddContinuousEffectToGame(new GainAbilityTargetEffect(IndestructibleAbility.getInstance())) + ) + ); + + // Then those creatures fight each other. + this.getSpellAbility().addEffect(new FightTargetsEffect() + .setText("Then those creatures fight each other. (Each deals damage equal to its power to the other.)") + ); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetPermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL)); } @@ -47,52 +69,3 @@ public final class BlizzardBrawl extends CardImpl { return new BlizzardBrawl(this); } } - -class BlizzardBrawlEffect extends OneShotEffect { - - private static final FilterPermanent filter = new FilterControlledPermanent(); - - static { - filter.add(SuperType.SNOW.getPredicate()); - } - - BlizzardBrawlEffect() { - super(Outcome.Benefit); - staticText = "Choose target creature you control and target creature you don't control. " + - "If you control three or more snow permanents, the creature you control gets +1/+0 " + - "and gains indestructible until end of turn. " + - "Then those creatures fight each other. " + - "(Each deals damage equal to its power to the other.)"; - } - - private BlizzardBrawlEffect(final BlizzardBrawlEffect effect) { - super(effect); - } - - @Override - public BlizzardBrawlEffect copy() { - return new BlizzardBrawlEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent creature1 = game.getPermanent(source.getTargets().get(0).getFirstTarget()); - Permanent creature2 = game.getPermanent(source.getTargets().get(1).getFirstTarget()); - if (creature1 == null) { - return false; - } - if (game.getBattlefield().count(filter, source.getControllerId(), source, game) >= 3) { - game.addEffect(new BoostTargetEffect( - 1, 0, Duration.EndOfTurn - ).setTargetPointer(new FixedTarget(creature1.getId(), game)), source); - game.addEffect(new GainAbilityTargetEffect( - IndestructibleAbility.getInstance(), Duration.EndOfTurn - ).setTargetPointer(new FixedTarget(creature1.getId(), game)), source); - } - if (creature2 == null) { - return true; - } - game.getState().processAction(game); - return creature1.fight(creature2, source, game); - } -} diff --git a/Mage.Sets/src/mage/cards/j/Joust.java b/Mage.Sets/src/mage/cards/j/Joust.java index 7fa44d822b..5578b02033 100644 --- a/Mage.Sets/src/mage/cards/j/Joust.java +++ b/Mage.Sets/src/mage/cards/j/Joust.java @@ -1,34 +1,44 @@ package mage.cards.j; -import mage.abilities.Ability; -import mage.abilities.effects.ContinuousEffect; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.condition.Condition; +import mage.abilities.condition.common.TargetHasSubtypeCondition; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.common.AddContinuousEffectToGame; +import mage.abilities.effects.common.FightTargetsEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Outcome; import mage.constants.SubType; import mage.filter.StaticFilters; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.TargetPermanent; import mage.target.common.TargetControlledCreaturePermanent; -import mage.target.targetpointer.FixedTarget; import java.util.UUID; /** - * @author TheElk801 + * @author awjackson */ public final class Joust extends CardImpl { + private static final Condition condition = new TargetHasSubtypeCondition(SubType.KNIGHT); + public Joust(UUID ownerId, CardSetInfo setInfo) { super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{R}"); - // Choose target creature you control and target creature you don't control. The creature you control gets +2/+1 until end of turn if it's a Knight. Then those creatures fight each other. - this.getSpellAbility().addEffect(new JoustEffect()); + // Choose target creature you control and target creature you don't control. + // The creature you control gets +2/+1 until end of turn if it's a Knight. + this.getSpellAbility().addEffect(new ConditionalOneShotEffect( + new AddContinuousEffectToGame(new BoostTargetEffect(2, 1)), + condition, + "Choose target creature you control and target creature you don't control. " + + "The creature you control gets +2/+1 until end of turn if it's a Knight." + )); + + // Then those creatures fight each other. + this.getSpellAbility().addEffect(new FightTargetsEffect() + .setText("Then those creatures fight each other. (Each deals damage equal to its power to the other.)") + ); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetPermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL)); } @@ -42,41 +52,3 @@ public final class Joust extends CardImpl { return new Joust(this); } } - -class JoustEffect extends OneShotEffect { - - JoustEffect() { - super(Outcome.Benefit); - staticText = "Choose target creature you control and target creature you don't control. " + - "The creature you control gets +2/+1 until end of turn if it's a Knight. " + - "Then those creatures fight each other. (Each deals damage equal to its power to the other.)"; - } - - private JoustEffect(final JoustEffect effect) { - super(effect); - } - - @Override - public JoustEffect copy() { - return new JoustEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Permanent creature1 = game.getPermanent(source.getTargets().get(0).getFirstTarget()); - Permanent creature2 = game.getPermanent(source.getTargets().get(1).getFirstTarget()); - if (creature1 == null) { - return false; - } - if (creature1.hasSubtype(SubType.KNIGHT, game)) { - ContinuousEffect effect = new BoostTargetEffect(2, 1, Duration.EndOfTurn); - effect.setTargetPointer(new FixedTarget(creature1.getId(), game)); - game.addEffect(effect, source); - } - if (creature2 == null) { - return true; - } - game.getState().processAction(game); - return creature1.fight(creature2, source, game); - } -} diff --git a/Mage.Sets/src/mage/cards/t/TailSwipe.java b/Mage.Sets/src/mage/cards/t/TailSwipe.java index 2b179d8008..919f7fbf47 100644 --- a/Mage.Sets/src/mage/cards/t/TailSwipe.java +++ b/Mage.Sets/src/mage/cards/t/TailSwipe.java @@ -2,25 +2,21 @@ package mage.cards.t; import java.util.UUID; -import mage.abilities.Ability; import mage.abilities.condition.common.AddendumCondition; -import mage.abilities.effects.OneShotEffect; +import mage.abilities.decorator.ConditionalOneShotEffect; +import mage.abilities.effects.common.AddContinuousEffectToGame; +import mage.abilities.effects.common.FightTargetsEffect; import mage.abilities.effects.common.continuous.BoostTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; import mage.constants.CardType; -import mage.constants.Outcome; import mage.filter.StaticFilters; -import mage.game.Game; -import mage.game.permanent.Permanent; import mage.target.TargetPermanent; -import mage.target.Targets; import mage.target.common.TargetControlledCreaturePermanent; -import mage.target.targetpointer.FixedTarget; /** * - * @author weirddan455 + * @author awjackson */ public final class TailSwipe extends CardImpl { @@ -29,8 +25,17 @@ public final class TailSwipe extends CardImpl { // Choose target creature you control and target creature you don't control. // If you cast this spell during your main phase, the creature you control gets +1/+1 until end of turn. + this.getSpellAbility().addEffect(new ConditionalOneShotEffect( + new AddContinuousEffectToGame(new BoostTargetEffect(1, 1)), + AddendumCondition.instance, + "Choose target creature you control and target creature you don't control. " + + "If you cast this spell during your main phase, the creature you control gets +1/+1 until end of turn." + )); + // Then those creatures fight each other. - this.getSpellAbility().addEffect(new TailSwipeEffect()); + this.getSpellAbility().addEffect(new FightTargetsEffect() + .setText("Then those creatures fight each other. (Each deals damage equal to its power to the other.)") + ); this.getSpellAbility().addTarget(new TargetControlledCreaturePermanent()); this.getSpellAbility().addTarget(new TargetPermanent(StaticFilters.FILTER_CREATURE_YOU_DONT_CONTROL)); } @@ -44,44 +49,3 @@ public final class TailSwipe extends CardImpl { return new TailSwipe(this); } } - -class TailSwipeEffect extends OneShotEffect { - - public TailSwipeEffect() { - super(Outcome.Benefit); - this.staticText = "Choose target creature you control and target creature you don't control. " + - "If you cast this spell during your main phase, the creature you control gets +1/+1 until end of turn. " + - "Then those creatures fight each other. " + - "(Each deals damage equal to its power to the other.)"; - } - - private TailSwipeEffect(final TailSwipeEffect effect) { - super(effect); - } - - @Override - public TailSwipeEffect copy() { - return new TailSwipeEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Targets targets = source.getTargets(); - if (targets.size() < 2) { - return false; - } - Permanent creature1 = game.getPermanent(targets.get(0).getFirstTarget()); - Permanent creature2 = game.getPermanent(targets.get(1).getFirstTarget()); - if (creature1 == null) { - return false; - } - if (AddendumCondition.instance.apply(game, source)) { - game.addEffect(new BoostTargetEffect(1, 1) - .setTargetPointer(new FixedTarget(creature1, game)), source); - } - if (creature2 != null) { - creature1.fight(creature2, source, game); - } - return true; - } -}