added the possibility that DelayedTriggeredAbilities can trigger more than one time

This commit is contained in:
LevelX2 2012-11-05 16:54:11 +01:00
parent 222b74c8ea
commit f96cb6532a
2 changed files with 16 additions and 2 deletions

View file

@ -56,7 +56,9 @@ import mage.game.events.GameEvent;
DelayedTriggeredAbility ability = it.next();
if (ability.checkTrigger(event, game)) {
ability.trigger(game, ability.controllerId);
it.remove();
if (ability.getTriggerOnlyOnce()) {
it.remove();
}
}
}
}
@ -65,8 +67,9 @@ import mage.game.events.GameEvent;
public void removeEndOfTurnAbilities() {
for (Iterator<DelayedTriggeredAbility> it = this.iterator();it.hasNext();) {
DelayedTriggeredAbility ability = it.next();
if (ability.getDuration() == Duration.EndOfTurn)
if (ability.getDuration() == Duration.EndOfTurn) {
it.remove();
}
}
}

View file

@ -39,19 +39,26 @@ import mage.abilities.effects.Effect;
public abstract class DelayedTriggeredAbility<T extends DelayedTriggeredAbility<T>> extends TriggeredAbilityImpl<T> {
private Duration duration;
private Boolean triggerOnlyOnce;
public DelayedTriggeredAbility(Effect effect) {
this(effect, Duration.EndOfGame);
}
public DelayedTriggeredAbility(Effect effect, Duration duration) {
this(effect, duration, true);
}
public DelayedTriggeredAbility(Effect effect, Duration duration, Boolean triggerOnlyOnce) {
super(Zone.ALL, effect);
this.duration = duration;
this.triggerOnlyOnce = triggerOnlyOnce;
}
public DelayedTriggeredAbility(final DelayedTriggeredAbility ability) {
super(ability);
this.duration = ability.duration;
this.triggerOnlyOnce = ability.triggerOnlyOnce;
}
@Override
@ -60,4 +67,8 @@ public abstract class DelayedTriggeredAbility<T extends DelayedTriggeredAbility<
public Duration getDuration() {
return duration;
}
public Boolean getTriggerOnlyOnce() {
return triggerOnlyOnce;
}
}