[NEO] Implemented Kumano Faces Kakkazan / Etching of Kumano (#8674)

* [NEO] Implemented Kumano Faces Kakkazan / Etching of Kumano

* [NEO] Etching of Kumano - Clean up watcher controller check

Co-authored-by: Evan Kranzler <theelk801@gmail.com>
This commit is contained in:
Daniel Bomar 2022-02-12 14:05:04 -06:00 committed by GitHub
parent cff38b74b9
commit 0694fd3ef7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 311 additions and 0 deletions

View file

@ -0,0 +1,45 @@
package mage.watchers.common;
import mage.MageObjectReference;
import mage.constants.WatcherScope;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.permanent.Permanent;
import mage.watchers.Watcher;
import java.util.HashSet;
/**
*
* @author weirddan455
*/
public class DamagedByControlledWatcher extends Watcher {
private final HashSet<MageObjectReference> damagedPermanents = new HashSet<>();
public DamagedByControlledWatcher() {
super(WatcherScope.PLAYER);
}
@Override
public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.DAMAGED_PERMANENT) {
Permanent permanent = game.getPermanent(event.getTargetId());
if (permanent != null && permanent.isCreature(game)) {
if (controllerId != null && controllerId.equals(game.getControllerId(event.getSourceId()))) {
damagedPermanents.add(new MageObjectReference(event.getTargetId(), game));
}
}
}
}
@Override
public void reset() {
super.reset();
damagedPermanents.clear();
}
public boolean wasDamaged(Permanent permanent, Game game) {
return damagedPermanents.contains(new MageObjectReference(permanent, game));
}
}