Fixed missing watchers from DelayedTriggeredAbility:

* Planeswalkers Mischief - fixed rollback error on play;
* Psychic Theft - fixed rollback error on play;
This commit is contained in:
Oleg Agafonov 2020-07-25 19:00:59 +04:00
parent 32b7c592c8
commit 848c5b6052
6 changed files with 67 additions and 17 deletions

View file

@ -890,6 +890,7 @@ public class GameState implements Serializable, Copyable<GameState> {
// TODO: add sources for triggers - the same way as in addEffect: sources
this.triggers.add((TriggeredAbility) ability, sourceId, attachedTo);
}
List<Watcher> watcherList = new ArrayList<>(ability.getWatchers()); // Workaround to prevent ConcurrentModificationException, not clear to me why this is happening now
for (Watcher watcher : watcherList) {
// TODO: Check that watcher for commanderAbility (where attachedTo = null) also work correctly
@ -897,6 +898,7 @@ public class GameState implements Serializable, Copyable<GameState> {
watcher.setSourceId(attachedTo == null ? ability.getSourceId() : attachedTo.getId());
watchers.add(watcher);
}
for (Ability sub : ability.getSubAbilities()) {
addAbility(sub, sourceId, attachedTo);
}
@ -949,6 +951,13 @@ public class GameState implements Serializable, Copyable<GameState> {
public void addDelayedTriggeredAbility(DelayedTriggeredAbility ability) {
this.delayed.add(ability);
List<Watcher> watcherList = new ArrayList<>(ability.getWatchers()); // Workaround to prevent ConcurrentModificationException, not clear to me why this is happening now
for (Watcher watcher : watcherList) {
watcher.setControllerId(ability.getControllerId());
watcher.setSourceId(ability.getSourceId());
this.watchers.add(watcher);
}
}
public void removeDelayedTriggeredAbility(UUID abilityId) {