reused common effect for playing additional land (removed duplication)

This commit is contained in:
North 2013-05-02 10:09:30 +03:00
parent c519a1a3a0
commit e290838584
2 changed files with 7 additions and 72 deletions

View file

@ -28,15 +28,13 @@
package mage.sets.urzassaga; package mage.sets.urzassaga;
import java.util.UUID; import java.util.UUID;
import mage.Constants;
import mage.Constants.CardType; import mage.Constants.CardType;
import mage.Constants.Duration;
import mage.Constants.Rarity; import mage.Constants.Rarity;
import mage.abilities.Ability; import mage.Constants.Zone;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.common.continious.PlayAdditionalLandsControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.game.Game;
import mage.players.Player;
/** /**
* *
@ -51,7 +49,8 @@ public class Exploration extends CardImpl<Exploration> {
this.color.setGreen(true); this.color.setGreen(true);
// You may play an additional land on each of your turns. // 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) { public Exploration(final Exploration card) {
@ -63,33 +62,3 @@ public class Exploration extends CardImpl<Exploration> {
return new Exploration(this); return new Exploration(this);
} }
} }
class ExplorationEffect extends ContinuousEffectImpl<ExplorationEffect> {
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;
}
}

View file

@ -30,21 +30,15 @@ package mage.sets.zendikar;
import mage.Constants.CardType; import mage.Constants.CardType;
import mage.Constants.Duration; import mage.Constants.Duration;
import mage.Constants.Layer;
import mage.Constants.Outcome;
import mage.Constants.Rarity; import mage.Constants.Rarity;
import mage.Constants.SubLayer;
import mage.Constants.Zone; import mage.Constants.Zone;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; 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.PlayTheTopCardEffect;
import mage.abilities.effects.common.continious.PlayWithTheTopCardRevealedEffect; import mage.abilities.effects.common.continious.PlayWithTheTopCardRevealedEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.filter.common.FilterLandCard; import mage.filter.common.FilterLandCard;
import mage.game.Game;
import mage.players.Player;
import java.util.UUID; import java.util.UUID;
@ -65,7 +59,7 @@ public class OracleOfMulDaya extends CardImpl<OracleOfMulDaya> {
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// You may play an additional land on each of your turns. // 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. // Play with the top card of your library revealed.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PlayWithTheTopCardRevealedEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new PlayWithTheTopCardRevealedEffect()));
// You may play the top card of your library if it's a land card. // You may play the top card of your library if it's a land card.
@ -82,31 +76,3 @@ public class OracleOfMulDaya extends CardImpl<OracleOfMulDaya> {
} }
} }
class OracleOfMulDayaEffect1 extends ContinuousEffectImpl<OracleOfMulDayaEffect1> {
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);
}
}