Fixed the causes that triggered abilities were applied more often than they should. Fixed the lose ability bug (test with Master of the Pearl Trident giving island walk). Tests now build without errors. Only rarely the Grounded/Drake Umbra lose ability test fails.

This commit is contained in:
LevelX2 2012-12-05 01:16:28 +01:00
parent 80e9d748a7
commit bb5b9587e0
11 changed files with 119 additions and 29 deletions

View file

@ -60,15 +60,15 @@ import java.io.Serializable;
import java.util.*;
/**
*
* @author BetaSteward_at_googlemail.com
*
* since at any time the game state may be copied and restored you cannot
* rely on any object maintaining it's instance
* it then becomes necessary to only refer to objects by their ids since
* these will always remain constant throughout its lifetime
*
*/
*
* @author BetaSteward_at_googlemail.com
*
* since at any time the game state may be copied and restored you cannot
* rely on any object maintaining it's instance
* it then becomes necessary to only refer to objects by their ids since
* these will always remain constant throughout its lifetime
*
*/
public class GameState implements Serializable, Copyable<GameState> {
private Players players;
@ -478,7 +478,7 @@ public class GameState implements Serializable, Copyable<GameState> {
}
else if (ability instanceof TriggeredAbility) {
// TODO: add sources for triggers - the same way as in addEffect: sources
this.triggers.add((TriggeredAbility)ability, attachedTo);
this.triggers.add((TriggeredAbility)ability, sourceId, attachedTo);
}
}
@ -555,6 +555,18 @@ public class GameState implements Serializable, Copyable<GameState> {
}
}
/**
* Removes Triggered abilities that were gained from sourceId
*
* @param sourceId
*/
public void resetForSourceId(UUID sourceId) {
List<String> keysToRemove = triggers.removeGainedAbilitiesForSource(sourceId);
for (String key : keysToRemove) {
triggers.remove(key);
}
}
public void clear() {
battlefield.clear();
effects.clear();