mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
fixed BlocksTriggeredAbility
This commit is contained in:
parent
032a261e5f
commit
11b692fa47
3 changed files with 18 additions and 44 deletions
|
@ -31,16 +31,11 @@ package mage.sets.magic2010;
|
|||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Rarity;
|
||||
import mage.Constants.Zone;
|
||||
import mage.MageInt;
|
||||
import mage.abilities.TriggeredAbilityImpl;
|
||||
import mage.abilities.common.BlocksTriggeredAbility;
|
||||
import mage.abilities.effects.common.SkipNextUntapTargetEffect;
|
||||
import mage.abilities.keyword.DefenderAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -57,7 +52,8 @@ public class WallOfFrost extends CardImpl<WallOfFrost> {
|
|||
this.toughness = new MageInt(7);
|
||||
|
||||
this.addAbility(DefenderAbility.getInstance());
|
||||
this.addAbility(new WallOfFrostAbility());
|
||||
// Whenever Wall of Frost blocks a creature, that creature doesn't untap during its controller's next untap step.
|
||||
this.addAbility(new BlocksTriggeredAbility(new SkipNextUntapTargetEffect(), false, true));
|
||||
}
|
||||
|
||||
public WallOfFrost(final WallOfFrost card) {
|
||||
|
@ -70,35 +66,3 @@ public class WallOfFrost extends CardImpl<WallOfFrost> {
|
|||
}
|
||||
|
||||
}
|
||||
|
||||
class WallOfFrostAbility extends TriggeredAbilityImpl<WallOfFrostAbility> {
|
||||
|
||||
public WallOfFrostAbility() {
|
||||
super(Zone.BATTLEFIELD, new SkipNextUntapTargetEffect(), false);
|
||||
}
|
||||
|
||||
public WallOfFrostAbility(final WallOfFrostAbility ability) {
|
||||
super(ability);
|
||||
}
|
||||
|
||||
@Override
|
||||
public WallOfFrostAbility copy() {
|
||||
return new WallOfFrostAbility(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.BLOCKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
|
||||
this.addTarget(new TargetCreaturePermanent());
|
||||
this.getTargets().get(0).add(event.getTargetId(), game);
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever {this} blocks a creature, that creature doesn't untap during its controller's next untap step";
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -57,7 +57,7 @@ public class LoyalSentry extends CardImpl<LoyalSentry> {
|
|||
this.power = new MageInt(1);
|
||||
this.toughness = new MageInt(1);
|
||||
|
||||
this.addAbility(new BlocksTriggeredAbility(new LoyalSentryEffect(), false));
|
||||
this.addAbility(new BlocksTriggeredAbility(new LoyalSentryEffect(), false, true));
|
||||
}
|
||||
|
||||
public LoyalSentry (final LoyalSentry card) {
|
||||
|
|
|
@ -33,7 +33,7 @@ import mage.abilities.effects.Effect;
|
|||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.GameEvent.EventType;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -41,9 +41,15 @@ import mage.target.common.TargetCreaturePermanent;
|
|||
*/
|
||||
public class BlocksTriggeredAbility extends TriggeredAbilityImpl<BlocksTriggeredAbility> {
|
||||
|
||||
private boolean fixedTargetPointer;
|
||||
|
||||
public BlocksTriggeredAbility(Effect effect, boolean optional) {
|
||||
this(effect, optional, false);
|
||||
}
|
||||
|
||||
public BlocksTriggeredAbility(Effect effect, boolean optional, boolean fixedTargetPointer) {
|
||||
super(Zone.BATTLEFIELD, effect, optional);
|
||||
this.addTarget(new TargetCreaturePermanent());
|
||||
this.fixedTargetPointer = fixedTargetPointer;
|
||||
}
|
||||
|
||||
public BlocksTriggeredAbility(final BlocksTriggeredAbility ability) {
|
||||
|
@ -53,7 +59,11 @@ public class BlocksTriggeredAbility extends TriggeredAbilityImpl<BlocksTriggered
|
|||
@Override
|
||||
public boolean checkTrigger(GameEvent event, Game game) {
|
||||
if (event.getType() == EventType.BLOCKER_DECLARED && event.getSourceId().equals(this.getSourceId())) {
|
||||
this.getTargets().get(0).add(event.getTargetId(), game);
|
||||
if (fixedTargetPointer) {
|
||||
for (Effect effect : this.getEffects()) {
|
||||
effect.setTargetPointer(new FixedTarget(event.getTargetId()));
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
|
@ -61,7 +71,7 @@ public class BlocksTriggeredAbility extends TriggeredAbilityImpl<BlocksTriggered
|
|||
|
||||
@Override
|
||||
public String getRule() {
|
||||
return "Whenever {this} blocks, " + super.getRule();
|
||||
return "Whenever {this} blocks" + (fixedTargetPointer ? " a creature" : "") + ", " + super.getRule();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in a new issue