fixed an error

This commit is contained in:
Evan Kranzler 2020-04-22 21:01:11 -04:00
parent ae3580a6c1
commit 1756c1f754
2 changed files with 25 additions and 29 deletions

View file

@ -37,7 +37,7 @@ public final class HaldanAvidArcanist extends CardImpl {
// You may play noncreature cards from exile with fetch counters on them if you exiled them, and you may spend mana as though it were mana of any color to cast those spells. // You may play noncreature cards from exile with fetch counters on them if you exiled them, and you may spend mana as though it were mana of any color to cast those spells.
Ability ability = new SimpleStaticAbility(new HaldanAvidArcanistCastFromExileEffect()); Ability ability = new SimpleStaticAbility(new HaldanAvidArcanistCastFromExileEffect());
ability.addEffect(new HaldanAvidArcanistSpendAnyManaEffect()); ability.addEffect(new HaldanAvidArcanistSpendAnyManaEffect());
this.addAbility(ability, PakoArcaneRetriever.makeWatcher()); this.addAbility(ability, new PakoArcaneRetriever.PakoArcaneRetrieverWatcher());
} }
private HaldanAvidArcanist(final HaldanAvidArcanist card) { private HaldanAvidArcanist(final HaldanAvidArcanist card) {

View file

@ -54,14 +54,34 @@ public final class PakoArcaneRetriever extends CardImpl {
return new PakoArcaneRetriever(this); return new PakoArcaneRetriever(this);
} }
public static PakoArcaneRetrieverWatcher makeWatcher() {
return new PakoArcaneRetrieverWatcher();
}
public static boolean checkWatcher(UUID playerId, Card card, Game game) { public static boolean checkWatcher(UUID playerId, Card card, Game game) {
PakoArcaneRetrieverWatcher watcher = game.getState().getWatcher(PakoArcaneRetrieverWatcher.class); PakoArcaneRetrieverWatcher watcher = game.getState().getWatcher(PakoArcaneRetrieverWatcher.class);
return watcher != null && watcher.checkCard(playerId, card, game); return watcher != null && watcher.checkCard(playerId, card, game);
} }
public static class PakoArcaneRetrieverWatcher extends Watcher {
private final Map<UUID, Set<MageObjectReference>> playerMap = new HashMap();
public PakoArcaneRetrieverWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
}
void addCard(UUID playerId, Card card, Game game) {
playerMap.computeIfAbsent(playerId, u -> new HashSet()).add(new MageObjectReference(card, game));
}
private boolean checkCard(UUID playerId, Card card, Game game) {
return playerMap
.computeIfAbsent(playerId, u -> new HashSet())
.stream()
.anyMatch(mageObjectReference -> mageObjectReference.refersTo(card, game));
}
}
} }
class PakoArcaneRetrieverEffect extends OneShotEffect { class PakoArcaneRetrieverEffect extends OneShotEffect {
@ -109,27 +129,3 @@ class PakoArcaneRetrieverEffect extends OneShotEffect {
return permanent.addCounters(CounterType.P1P1.createInstance(counters), source, game); return permanent.addCounters(CounterType.P1P1.createInstance(counters), source, game);
} }
} }
class PakoArcaneRetrieverWatcher extends Watcher {
private final Map<UUID, Set<MageObjectReference>> playerMap = new HashMap();
PakoArcaneRetrieverWatcher() {
super(WatcherScope.GAME);
}
@Override
public void watch(GameEvent event, Game game) {
}
void addCard(UUID playerId, Card card, Game game) {
playerMap.computeIfAbsent(playerId, u -> new HashSet()).add(new MageObjectReference(card, game));
}
boolean checkCard(UUID playerId, Card card, Game game) {
return playerMap
.computeIfAbsent(playerId, u -> new HashSet())
.stream()
.anyMatch(mageObjectReference -> mageObjectReference.refersTo(card, game));
}
}