Fixed Godo, Bandit Warlord copies not untapping themselves (fixes #4827)

Reworked the trigger, also affects Aurelia, the Warleader
This commit is contained in:
Evan Kranzler 2018-05-19 17:39:20 -04:00
parent e8ee1fc4f9
commit 01fb64367e
4 changed files with 128 additions and 152 deletions

View file

@ -27,7 +27,9 @@
*/
package mage.watchers.common;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import mage.MageObjectReference;
import mage.constants.WatcherScope;
@ -40,7 +42,8 @@ import mage.watchers.Watcher;
*/
public class AttackedThisTurnWatcher extends Watcher {
public final Set<MageObjectReference> attackedThisTurnCreatures = new HashSet<>();
protected final Set<MageObjectReference> attackedThisTurnCreatures = new HashSet<>();
protected final Map<MageObjectReference, Integer> attackedThisTurnCreaturesCounts = new HashMap<>();
public AttackedThisTurnWatcher() {
super(AttackedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
@ -49,12 +52,16 @@ public class AttackedThisTurnWatcher extends Watcher {
public AttackedThisTurnWatcher(final AttackedThisTurnWatcher watcher) {
super(watcher);
this.attackedThisTurnCreatures.addAll(watcher.attackedThisTurnCreatures);
this.attackedThisTurnCreaturesCounts.putAll(watcher.attackedThisTurnCreaturesCounts);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.ATTACKER_DECLARED) {
this.attackedThisTurnCreatures.add(new MageObjectReference(event.getSourceId(), game));
MageObjectReference mor = new MageObjectReference(event.getSourceId(), game);
this.attackedThisTurnCreatures.add(mor);
this.attackedThisTurnCreaturesCounts.putIfAbsent(mor, 0);
this.attackedThisTurnCreaturesCounts.compute(mor, (k, v) -> (v + 1));
}
}
@ -62,6 +69,10 @@ public class AttackedThisTurnWatcher extends Watcher {
return this.attackedThisTurnCreatures;
}
public Map<MageObjectReference, Integer> getAttackedThisTurnCreaturesCounts() {
return this.attackedThisTurnCreaturesCounts;
}
@Override
public AttackedThisTurnWatcher copy() {
return new AttackedThisTurnWatcher(this);
@ -71,6 +82,7 @@ public class AttackedThisTurnWatcher extends Watcher {
public void reset() {
super.reset();
this.attackedThisTurnCreatures.clear();
this.attackedThisTurnCreaturesCounts.clear();
}
}