Added custom duration handling to delayed triggered abilities.

This commit is contained in:
LevelX2 2014-08-27 17:08:19 +02:00
parent a2fe968582
commit cb7d3ab284
3 changed files with 15 additions and 1 deletions

View file

@ -54,6 +54,12 @@ import mage.game.events.GameEvent;
if (this.size() > 0) {
for (Iterator<DelayedTriggeredAbility> it = this.iterator();it.hasNext();) {
DelayedTriggeredAbility ability = it.next();
if (ability.getDuration().equals(Duration.Custom)){
if (ability.isInactive(game)) {
it.remove();
continue;
}
}
if (ability.checkTrigger(event, game)) {
ability.trigger(game, ability.controllerId);
if (ability.getTriggerOnlyOnce()) {

View file

@ -31,6 +31,7 @@ package mage.abilities;
import mage.abilities.effects.Effect;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.game.Game;
/**
*
@ -74,4 +75,10 @@ public abstract class DelayedTriggeredAbility extends TriggeredAbilityImpl {
public Boolean getTriggerOnlyOnce() {
return triggerOnlyOnce;
}
public void init(Game game) {};
public boolean isInactive(Game game) {
return false;
}
}

View file

@ -1258,7 +1258,7 @@ public abstract class GameImpl implements Game, Serializable {
manaAbiltiy.resolve(this);
}
else {
TriggeredAbility newAbility = (TriggeredAbility) ability.copy();
TriggeredAbility newAbility = ability.copy();
newAbility.newId();
state.addTriggeredAbility(newAbility);
}
@ -1268,6 +1268,7 @@ public abstract class GameImpl implements Game, Serializable {
public void addDelayedTriggeredAbility(DelayedTriggeredAbility delayedAbility) {
DelayedTriggeredAbility newAbility = delayedAbility.copy();
newAbility.newId();
newAbility.init(this);
state.addDelayedTriggeredAbility(newAbility);
}