Added missing logic to remove continuous effects with duration EndOfCombat.

This commit is contained in:
LevelX2 2013-05-09 09:06:31 +02:00
parent c2ecf71cab
commit f84177bbcd
5 changed files with 40 additions and 5 deletions

View file

@ -73,5 +73,15 @@ import mage.game.events.GameEvent;
}
}
public void removeEndOfCombatAbilities() {
for (Iterator<DelayedTriggeredAbility> it = this.iterator();it.hasNext();) {
DelayedTriggeredAbility ability = it.next();
if (ability.getDuration() == Duration.EndOfCombat) {
it.remove();
}
}
}
}

View file

@ -117,6 +117,16 @@ public class ContinuousEffects implements Serializable {
return restrictionEffects;
}
public void removeEndOfCombatEffects() {
layeredEffects.removeEndOfCombatEffects();
replacementEffects.removeEndOfCombatEffects();
preventionEffects.removeEndOfCombatEffects();
requirementEffects.removeEndOfCombatEffects();
restrictionEffects.removeEndOfCombatEffects();
asThoughEffects.removeEndOfCombatEffects();
costModificationEffects.removeEndOfCombatEffects();
}
public void removeEndOfTurnEffects() {
layeredEffects.removeEndOfTurnEffects();
replacementEffects.removeEndOfTurnEffects();

View file

@ -27,14 +27,11 @@
*/
package mage.abilities.effects;
import mage.Constants;
import mage.abilities.Ability;
import mage.game.Game;
import java.util.*;
import static mage.Constants.Duration.Custom;
import static mage.Constants.Duration.OneUse;
import static mage.Constants.Duration.WhileOnBattlefield;
import mage.Constants.Duration;
/**
*
@ -68,7 +65,17 @@ public class ContinuousEffectsList<T extends ContinuousEffect> extends ArrayList
public void removeEndOfTurnEffects() {
for (Iterator<T> i = this.iterator(); i.hasNext();) {
T entry = i.next();
if (entry.getDuration() == Constants.Duration.EndOfTurn) {
if (entry.getDuration() == Duration.EndOfTurn) {
i.remove();
effectAbilityMap.remove(entry.getId());
}
}
}
public void removeEndOfCombatEffects() {
for (Iterator<T> i = this.iterator(); i.hasNext();) {
T entry = i.next();
if (entry.getDuration() == Duration.EndOfCombat) {
i.remove();
effectAbilityMap.remove(entry.getId());
}

View file

@ -366,6 +366,13 @@ public class GameState implements Serializable, Copyable<GameState> {
battlefield.fireControlChangeEvents(game);
}
// Remove End of Combat effects
public void removeEocEffects(Game game) {
effects.removeEndOfCombatEffects();
delayed.removeEndOfCombatAbilities();
applyEffects(game);
}
public void removeEotEffects(Game game) {
effects.removeEndOfTurnEffects();
delayed.removeEndOfTurnAbilities();

View file

@ -55,6 +55,7 @@ public class EndOfCombatStep extends Step<EndOfCombatStep> {
super.endStep(game, activePlayerId);
//20091005 - 511.3
game.getCombat().endCombat(game);
game.getState().removeEocEffects(game);
// game.saveState();
}