mirror of
https://github.com/magefree/mage.git
synced 2026-01-09 20:32:06 -08:00
merge MorbidWatcher with CreaturesDiedWatcher
This commit is contained in:
parent
1ac4fe4e4a
commit
1f764515f6
4 changed files with 6 additions and 38 deletions
|
|
@ -3,7 +3,7 @@ package mage.abilities.condition.common;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.condition.Condition;
|
||||
import mage.game.Game;
|
||||
import mage.watchers.common.MorbidWatcher;
|
||||
import mage.watchers.common.CreaturesDiedWatcher;
|
||||
|
||||
/**
|
||||
* @author nantuko
|
||||
|
|
@ -13,7 +13,7 @@ public enum MorbidCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
MorbidWatcher watcher = game.getState().getWatcher(MorbidWatcher.class);
|
||||
CreaturesDiedWatcher watcher = game.getState().getWatcher(CreaturesDiedWatcher.class);
|
||||
return watcher != null && watcher.conditionMet();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1336,7 +1336,6 @@ public abstract class GameImpl implements Game {
|
|||
|
||||
public void initGameDefaultWatchers() {
|
||||
List<Watcher> newWatchers = new ArrayList<>();
|
||||
newWatchers.add(new MorbidWatcher());
|
||||
newWatchers.add(new CastSpellLastTurnWatcher());
|
||||
newWatchers.add(new PlayerLostLifeWatcher());
|
||||
newWatchers.add(new BlockedAttackerWatcher());
|
||||
|
|
|
|||
|
|
@ -19,6 +19,9 @@ public class CreaturesDiedWatcher extends Watcher {
|
|||
private final Map<UUID, Integer> amountOfCreaturesThatDiedByController = new HashMap<>();
|
||||
private final Map<UUID, Integer> amountOfCreaturesThatDiedByOwner = new HashMap<>();
|
||||
|
||||
/**
|
||||
* Game default watcher
|
||||
*/
|
||||
public CreaturesDiedWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
|
@ -34,6 +37,7 @@ public class CreaturesDiedWatcher extends Watcher {
|
|||
|| !zEvent.getTarget().isCreature(game)) {
|
||||
return;
|
||||
}
|
||||
condition = true;
|
||||
amountOfCreaturesThatDiedByController.compute(zEvent.getTarget().getControllerId(), CardUtil::setOrIncrementValue);
|
||||
amountOfCreaturesThatDiedByOwner.compute(zEvent.getTarget().getOwnerId(), CardUtil::setOrIncrementValue);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,35 +0,0 @@
|
|||
|
||||
package mage.watchers.common;
|
||||
|
||||
import mage.constants.WatcherScope;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
import mage.watchers.Watcher;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
*/
|
||||
public class MorbidWatcher extends Watcher {
|
||||
|
||||
/**
|
||||
* Game default watcher
|
||||
* TODO: Merge with CreaturesDiedWatcher
|
||||
*/
|
||||
public MorbidWatcher() {
|
||||
super(WatcherScope.GAME);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void watch(GameEvent event, Game game) {
|
||||
if (condition) {
|
||||
return;
|
||||
}
|
||||
if (event.getType() == GameEvent.EventType.ZONE_CHANGE
|
||||
&& ((ZoneChangeEvent) event).isDiesEvent()
|
||||
&& ((ZoneChangeEvent) event).getTarget().isCreature(game)) {
|
||||
condition = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue