Merge pull request #2934 from spjspj/master

spjspj - Implement Land Equilibrium (LEG, ME3)
This commit is contained in:
spjspj 2017-03-07 01:21:19 +11:00 committed by GitHub
commit 134d1b5872

View file

@ -28,12 +28,10 @@
package mage.cards.l; package mage.cards.l;
import java.util.UUID; import java.util.UUID;
import static jdk.nashorn.internal.objects.NativeRegExp.source;
import mage.abilities.TriggeredAbilityImpl; import mage.abilities.TriggeredAbilityImpl;
import mage.abilities.effects.common.SacrificeEffect; import mage.abilities.effects.common.SacrificeEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import static mage.cards.m.ManaVortex.filter;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.common.FilterLandPermanent; import mage.filter.common.FilterLandPermanent;
@ -50,7 +48,7 @@ public class LandEquilibrium extends CardImpl {
public LandEquilibrium(UUID ownerId, CardSetInfo setInfo) { public LandEquilibrium(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}{U}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{U}{U}");
// If an opponent who controls at least as many lands as you do would put a land onto the battlefield, that player instead puts that land onto the battlefield then sacrifices a land. // If an opponent who controls at least as many lands as you do would put a land onto the battlefield, that player instead puts that land onto the battlefield then sacrifices a land.
this.addAbility(new LandEquilibriumAbility()); this.addAbility(new LandEquilibriumAbility());
} }
@ -67,6 +65,8 @@ public class LandEquilibrium extends CardImpl {
class LandEquilibriumAbility extends TriggeredAbilityImpl { class LandEquilibriumAbility extends TriggeredAbilityImpl {
private static final FilterLandPermanent filter = new FilterLandPermanent("land");
public LandEquilibriumAbility() { public LandEquilibriumAbility() {
super(Zone.BATTLEFIELD, new SacrificeEffect(new FilterLandPermanent(), 1, ""), false); super(Zone.BATTLEFIELD, new SacrificeEffect(new FilterLandPermanent(), 1, ""), false);
} }
@ -88,11 +88,12 @@ class LandEquilibriumAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
int numMyLands = game.getBattlefield().countAll(filter, this.getControllerId(), game); int numMyLands = game.getBattlefield().countAll(filter, this.getControllerId(), game);
if (numMyLands < game.getBattlefield().countAll(filter, event.getPlayerId(), game)) { int theirLands = game.getBattlefield().countAll(filter, event.getPlayerId(), game);
if (numMyLands < theirLands) {
this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId()));
return true; return true;
} }
return false; return false;
} }
@Override @Override