mirror of
https://github.com/correl/mage.git
synced 2025-01-12 19:25:44 +00:00
added the possibility that DelayedTriggeredAbilities can trigger more than one time
This commit is contained in:
parent
222b74c8ea
commit
f96cb6532a
2 changed files with 16 additions and 2 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue