mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
reworked implementation of Ashling the Pilgrim and similar cards, added a test
This commit is contained in:
parent
ae20bb36a4
commit
4d1f37d0fe
5 changed files with 243 additions and 136 deletions
|
|
@ -0,0 +1,40 @@
|
|||
package mage.watchers.common;
|
||||
|
||||
import mage.MageObjectReference;
|
||||
import mage.abilities.Ability;
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* @author TheElk801
|
||||
*/
|
||||
public class AbilityResolvedWatcher extends Watcher {
|
||||
|
||||
private final Map<MageObjectReference, Map<UUID, Integer>> activationMap = new HashMap<>();
|
||||
|
||||
public AbilityResolvedWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reset() {
|
||||
super.reset();
|
||||
activationMap.clear();
|
||||
}
|
||||
|
||||
public boolean checkActivations(Ability source, Game game) {
|
||||
return activationMap.computeIfAbsent(new MageObjectReference(
|
||||
source.getSourceId(), source.getSourceObjectZoneChangeCounter(), game
|
||||
), x -> new HashMap<>()).compute(source.getOriginalId(), (u, i) -> i == null ? 1 : i + 1).intValue() == 3;
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue