* Ensnaring Bridge - changed replacement effect to restriction effect.

This commit is contained in:
LevelX2 2014-03-25 23:56:38 +01:00
parent 8c7dcf275e
commit a5454aab6d

View file

@ -28,15 +28,15 @@
package mage.sets.stronghold; package mage.sets.stronghold;
import java.util.UUID; import java.util.UUID;
import mage.constants.*;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.RestrictionEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Rarity;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
@ -51,7 +51,7 @@ public class EnsnaringBridge extends CardImpl<EnsnaringBridge> {
this.expansionSetCode = "STH"; this.expansionSetCode = "STH";
// Creatures with power greater than the number of cards in your hand can't attack. // Creatures with power greater than the number of cards in your hand can't attack.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new EnsnaringBridgeEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new EnsnaringBridgeRestrictionEffect()));
} }
public EnsnaringBridge(final EnsnaringBridge card) { public EnsnaringBridge(final EnsnaringBridge card) {
@ -64,49 +64,35 @@ public class EnsnaringBridge extends CardImpl<EnsnaringBridge> {
} }
} }
class EnsnaringBridgeEffect extends ReplacementEffectImpl<EnsnaringBridgeEffect> {
class EnsnaringBridgeRestrictionEffect extends RestrictionEffect<EnsnaringBridgeRestrictionEffect> {
public EnsnaringBridgeEffect() { public EnsnaringBridgeRestrictionEffect() {
super(Duration.WhileOnBattlefield, Outcome.Detriment); super(Duration.WhileOnBattlefield);
staticText = "Creatures with power greater than the number of cards in your hand can't attack"; this.staticText = "Creatures with power greater than the number of cards in your hand can't attack";
} }
public EnsnaringBridgeEffect(final EnsnaringBridgeEffect effect) { public EnsnaringBridgeRestrictionEffect(final EnsnaringBridgeRestrictionEffect effect) {
super(effect); super(effect);
} }
@Override @Override
public boolean apply(Game game, Ability source) { public boolean applies(Permanent permanent, Ability source, Game game) {
return true;
}
@Override
public EnsnaringBridgeEffect copy() {
return new EnsnaringBridgeEffect(this);
}
@Override
public boolean replaceEvent(GameEvent event, Ability source, Game game) {
return true;
}
@Override
public boolean applies(GameEvent event, Ability source, Game game) {
if (event.getType() == EventType.DECLARE_ATTACKER) {
Permanent permanent = game.getPermanent(event.getSourceId());
if (permanent != null) {
Player player = game.getPlayer(source.getControllerId());
if (player != null && player.getInRange().contains(permanent.getControllerId())) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
int cardInHand = controller.getHand().size(); if (controller != null) {
if (permanent.getPower().getValue() > cardInHand){ return permanent.getPower().getValue() > controller.getHand().size();
return true;
}
}
}
} }
return false; return false;
} }
@Override
public boolean canAttack(Game game) {
return false;
}
@Override
public EnsnaringBridgeRestrictionEffect copy() {
return new EnsnaringBridgeRestrictionEffect(this);
}
} }