mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
* The Chain Veil - Fixed that the intervening if clause was not implemented correctly.
This commit is contained in:
parent
4f2c21a146
commit
eb1a41a077
1 changed files with 45 additions and 48 deletions
|
@ -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,7 +67,8 @@ 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,
|
||||||
|
@ -87,38 +89,6 @@ 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<>();
|
||||||
|
@ -136,9 +106,9 @@ class ActivatedLoyaltyAbilityWatcher extends Watcher {
|
||||||
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());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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";
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in a new issue