* The Chain Veil - Fixed that the intervening if clause was not implemented correctly.

This commit is contained in:
LevelX2 2016-01-03 10:27:06 +01:00
parent 4f2c21a146
commit eb1a41a077

View file

@ -34,10 +34,11 @@ import mage.abilities.Ability;
import mage.abilities.LoyaltyAbility; import mage.abilities.LoyaltyAbility;
import mage.abilities.common.BeginningOfEndStepTriggeredAbility; import mage.abilities.common.BeginningOfEndStepTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.condition.Condition;
import mage.abilities.costs.common.TapSourceCost; import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.ContinuousEffectImpl; import mage.abilities.effects.ContinuousEffectImpl;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.LoseLifeSourceControllerEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
@ -66,12 +67,13 @@ public class TheChainVeil extends CardImpl {
this.supertype.add("Legendary"); this.supertype.add("Legendary");
// At the beginning of your end step, if you didn't activate a loyalty ability of a planeswalker this turn, you lose 2 life. // At the beginning of your end step, if you didn't activate a loyalty ability of a planeswalker this turn, you lose 2 life.
this.addAbility(new BeginningOfEndStepTriggeredAbility(new TheChainVeilTriggeredEffect(), TargetController.YOU, false), new ActivatedLoyaltyAbilityWatcher()); this.addAbility(new BeginningOfEndStepTriggeredAbility(
Zone.BATTLEFIELD, new LoseLifeSourceControllerEffect(2), TargetController.YOU, TheChainVeilCondition.getInstance(), false), new ActivatedLoyaltyAbilityWatcher());
// {4}, {T}: For each planeswalker you control, you may activate one of its loyalty abilities once this turn as though none of its loyalty abilities had been activated this turn. // {4}, {T}: For each planeswalker you control, you may activate one of its loyalty abilities once this turn as though none of its loyalty abilities had been activated this turn.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD,
new TheChainVeilIncreaseLoyaltyUseEffect(), new TheChainVeilIncreaseLoyaltyUseEffect(),
new ManaCostsImpl("{4}")); new ManaCostsImpl("{4}"));
ability.addCost(new TapSourceCost()); ability.addCost(new TapSourceCost());
this.addAbility(ability); this.addAbility(ability);
@ -87,61 +89,29 @@ public class TheChainVeil extends CardImpl {
} }
} }
class TheChainVeilTriggeredEffect extends OneShotEffect {
public TheChainVeilTriggeredEffect() {
super(Outcome.LoseLife);
this.staticText = "if you didn't activate a loyalty ability of a planeswalker this turn, you lose 2 life";
}
public TheChainVeilTriggeredEffect(final TheChainVeilTriggeredEffect effect) {
super(effect);
}
@Override
public TheChainVeilTriggeredEffect copy() {
return new TheChainVeilTriggeredEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
ActivatedLoyaltyAbilityWatcher watcher = (ActivatedLoyaltyAbilityWatcher) game.getState().getWatchers().get("ActivatedLoyaltyAbilityWatcher");
if (watcher != null) {
if (!watcher.activatedLayaltyAbility(source.getControllerId())) {
controller.loseLife(2, game);
}
}
}
return false;
}
}
class ActivatedLoyaltyAbilityWatcher extends Watcher { class ActivatedLoyaltyAbilityWatcher extends Watcher {
private final Set<UUID> playerIds = new HashSet<>(); private final Set<UUID> playerIds = new HashSet<>();
public ActivatedLoyaltyAbilityWatcher() { public ActivatedLoyaltyAbilityWatcher() {
super("ActivatedLoyaltyAbilityWatcher", WatcherScope.GAME); super("ActivatedLoyaltyAbilityWatcher", WatcherScope.GAME);
} }
public ActivatedLoyaltyAbilityWatcher(final ActivatedLoyaltyAbilityWatcher watcher) { public ActivatedLoyaltyAbilityWatcher(final ActivatedLoyaltyAbilityWatcher watcher) {
super(watcher); super(watcher);
playerIds.addAll(watcher.playerIds); playerIds.addAll(watcher.playerIds);
} }
@Override @Override
public void watch(GameEvent event, Game game) { public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ACTIVATED_ABILITY ) { if (event.getType() == GameEvent.EventType.ACTIVATED_ABILITY) {
StackObject stackObject = game.getStack().getStackObject(event.getTargetId()); StackObject stackObject = game.getStack().getStackObject(event.getTargetId());
if (stackObject != null && if (stackObject != null
stackObject.getStackAbility() != null && && stackObject.getStackAbility() != null
stackObject.getStackAbility() instanceof LoyaltyAbility) { && stackObject.getStackAbility() instanceof LoyaltyAbility) {
playerIds.add(stackObject.getControllerId()); playerIds.add(stackObject.getControllerId());
} }
} }
} }
@Override @Override
@ -151,7 +121,7 @@ class ActivatedLoyaltyAbilityWatcher extends Watcher {
@Override @Override
public ActivatedLoyaltyAbilityWatcher copy() { public ActivatedLoyaltyAbilityWatcher copy() {
return new ActivatedLoyaltyAbilityWatcher(this); return new ActivatedLoyaltyAbilityWatcher(this);
} }
public boolean activatedLayaltyAbility(UUID playerId) { public boolean activatedLayaltyAbility(UUID playerId) {
@ -194,3 +164,30 @@ class TheChainVeilIncreaseLoyaltyUseEffect extends ContinuousEffectImpl {
return layer == Layer.RulesEffects; return layer == Layer.RulesEffects;
} }
} }
class TheChainVeilCondition implements Condition {
private static final TheChainVeilCondition fInstance = new TheChainVeilCondition();
public static Condition getInstance() {
return fInstance;
}
@Override
public boolean apply(Game game, Ability source) {
ActivatedLoyaltyAbilityWatcher watcher = (ActivatedLoyaltyAbilityWatcher) game.getState().getWatchers().get("ActivatedLoyaltyAbilityWatcher");
if (watcher != null) {
if (!watcher.activatedLayaltyAbility(source.getControllerId())) {
return true;
}
}
return false;
}
@Override
public String toString() {
return "if you didn't activate a loyalty ability of a planeswalker this turn";
}
}