mirror of
https://github.com/correl/mage.git
synced 2024-11-15 19:19:33 +00:00
Added custom duration handling to delayed triggered abilities.
This commit is contained in:
parent
a2fe968582
commit
cb7d3ab284
3 changed files with 15 additions and 1 deletions
|
@ -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()) {
|
||||
|
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue