From e2908385844a07470e49e52c9a07f92f5b7297ae Mon Sep 17 00:00:00 2001 From: North Date: Thu, 2 May 2013 10:09:30 +0300 Subject: [PATCH] reused common effect for playing additional land (removed duplication) --- .../src/mage/sets/urzassaga/Exploration.java | 41 +++---------------- .../mage/sets/zendikar/OracleOfMulDaya.java | 38 +---------------- 2 files changed, 7 insertions(+), 72 deletions(-) diff --git a/Mage.Sets/src/mage/sets/urzassaga/Exploration.java b/Mage.Sets/src/mage/sets/urzassaga/Exploration.java index 1dfaf31804..1cb8d9d05d 100644 --- a/Mage.Sets/src/mage/sets/urzassaga/Exploration.java +++ b/Mage.Sets/src/mage/sets/urzassaga/Exploration.java @@ -28,15 +28,13 @@ package mage.sets.urzassaga; import java.util.UUID; -import mage.Constants; import mage.Constants.CardType; +import mage.Constants.Duration; import mage.Constants.Rarity; -import mage.abilities.Ability; +import mage.Constants.Zone; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.continious.PlayAdditionalLandsControllerEffect; import mage.cards.CardImpl; -import mage.game.Game; -import mage.players.Player; /** * @@ -51,7 +49,8 @@ public class Exploration extends CardImpl { this.color.setGreen(true); // You may play an additional land on each of your turns. - this.addAbility(new SimpleStaticAbility(Constants.Zone.BATTLEFIELD, new ExplorationEffect())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, + new PlayAdditionalLandsControllerEffect(1, Duration.WhileOnBattlefield))); } public Exploration(final Exploration card) { @@ -63,33 +62,3 @@ public class Exploration extends CardImpl { return new Exploration(this); } } - -class ExplorationEffect extends ContinuousEffectImpl { - - public ExplorationEffect() { - super(Constants.Duration.WhileOnBattlefield, Constants.Layer.PlayerEffects, Constants.SubLayer.NA, Constants.Outcome.Benefit); - staticText = "You may play an additional land on each of your turns"; - } - - public ExplorationEffect(final ExplorationEffect effect) { - super(effect); - } - - @Override - public ExplorationEffect copy() { - return new ExplorationEffect(this); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null && game.getActivePlayerId().equals(source.getControllerId())) { - player.setLandsPerTurn(player.getLandsPerTurn() + 1); - return true; - } - return true; - } - - - -} \ No newline at end of file diff --git a/Mage.Sets/src/mage/sets/zendikar/OracleOfMulDaya.java b/Mage.Sets/src/mage/sets/zendikar/OracleOfMulDaya.java index bc8de67d90..10e67bd6d9 100644 --- a/Mage.Sets/src/mage/sets/zendikar/OracleOfMulDaya.java +++ b/Mage.Sets/src/mage/sets/zendikar/OracleOfMulDaya.java @@ -30,21 +30,15 @@ package mage.sets.zendikar; import mage.Constants.CardType; import mage.Constants.Duration; -import mage.Constants.Layer; -import mage.Constants.Outcome; import mage.Constants.Rarity; -import mage.Constants.SubLayer; import mage.Constants.Zone; import mage.MageInt; -import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; -import mage.abilities.effects.ContinuousEffectImpl; +import mage.abilities.effects.common.continious.PlayAdditionalLandsControllerEffect; import mage.abilities.effects.common.continious.PlayTheTopCardEffect; import mage.abilities.effects.common.continious.PlayWithTheTopCardRevealedEffect; import mage.cards.CardImpl; import mage.filter.common.FilterLandCard; -import mage.game.Game; -import mage.players.Player; import java.util.UUID; @@ -65,7 +59,7 @@ public class OracleOfMulDaya extends CardImpl { this.toughness = new MageInt(2); // You may play an additional land on each of your turns. - this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new OracleOfMulDayaEffect1())); + this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PlayAdditionalLandsControllerEffect(1, Duration.WhileOnBattlefield))); // Play with the top card of your library revealed. this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PlayWithTheTopCardRevealedEffect())); // You may play the top card of your library if it's a land card. @@ -82,31 +76,3 @@ public class OracleOfMulDaya extends CardImpl { } } - -class OracleOfMulDayaEffect1 extends ContinuousEffectImpl { - - public OracleOfMulDayaEffect1() { - super(Duration.WhileOnBattlefield, Layer.PlayerEffects, SubLayer.NA, Outcome.PutLandInPlay); - staticText = "You may play an additional land on each of your turns"; - } - - public OracleOfMulDayaEffect1(final OracleOfMulDayaEffect1 effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); - if (player != null) { - player.setLandsPerTurn(player.getLandsPerTurn() + 1); - return true; - } - return false; - } - - @Override - public OracleOfMulDayaEffect1 copy() { - return new OracleOfMulDayaEffect1(this); - } - -} \ No newline at end of file