mirror of
https://github.com/magefree/mage.git
synced 2025-12-25 21:12:04 -08:00
finish rewriting watchers
This commit is contained in:
parent
efae1251f9
commit
b6fe6f772a
146 changed files with 233 additions and 235 deletions
|
|
@ -24,7 +24,7 @@ public enum AttackedOrBlockedThisCombatSourceCondition implements Condition {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId());
|
||||
if (sourceObject != null) {
|
||||
AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatchers().get(AttackedOrBlockedThisCombatWatcher.class.getName());
|
||||
AttackedOrBlockedThisCombatWatcher watcher = (AttackedOrBlockedThisCombatWatcher) game.getState().getWatchers().get(AttackedOrBlockedThisCombatWatcher.class.getSimpleName());
|
||||
if (watcher != null) {
|
||||
for (MageObjectReference mor : watcher.getAttackedThisTurnCreatures()) {
|
||||
if (mor.refersTo(sourceObject, game)) {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ public enum CastFromHandSourceCondition implements Condition {
|
|||
return false;
|
||||
}
|
||||
}
|
||||
CastFromHandWatcher watcher = (CastFromHandWatcher) game.getState().getWatchers().get(CastFromHandWatcher.class.getName());
|
||||
CastFromHandWatcher watcher = (CastFromHandWatcher) game.getState().getWatchers().get(CastFromHandWatcher.class.getSimpleName());
|
||||
if (watcher != null && watcher.spellWasCastFromHand(source.getSourceId())) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public class DealtDamageToAnOpponent implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
for (UUID opponentId: game.getOpponents(source.getControllerId())) {
|
||||
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", opponentId);
|
||||
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), opponentId);
|
||||
if (watcher != null) {
|
||||
return watcher.hasSourceDoneDamage(source.getSourceId(), game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ public enum HateCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
LifeLossOtherFromCombatWatcher watcher = (LifeLossOtherFromCombatWatcher) game.getState().getWatchers().get(LifeLossOtherFromCombatWatcher.class.getName());
|
||||
LifeLossOtherFromCombatWatcher watcher = (LifeLossOtherFromCombatWatcher) game.getState().getWatchers().get(LifeLossOtherFromCombatWatcher.class.getSimpleName());
|
||||
return watcher != null && watcher.opponentLostLifeOtherFromCombat(source.getControllerId(), game);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public enum LandfallCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
LandfallWatcher watcher = (LandfallWatcher) game.getState().getWatchers().get("LandPlayed");
|
||||
LandfallWatcher watcher = (LandfallWatcher) game.getState().getWatchers().get(LandfallWatcher.class.getSimpleName());
|
||||
return watcher != null && watcher.landPlayed(source.getControllerId());
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -56,7 +56,7 @@ public class ManaWasSpentCondition implements Condition {
|
|||
if (source.getAbilityType() == AbilityType.SPELL) {
|
||||
return (source.getManaCostsToPay().getPayment().getColor(coloredManaSymbol) > 0);
|
||||
}
|
||||
ManaSpentToCastWatcher watcher = (ManaSpentToCastWatcher) game.getState().getWatchers().get("ManaSpentToCast", source.getSourceId());
|
||||
ManaSpentToCastWatcher watcher = (ManaSpentToCastWatcher) game.getState().getWatchers().get(ManaSpentToCastWatcher.class.getSimpleName(), source.getSourceId());
|
||||
if (watcher != null) {
|
||||
Mana payment = watcher.getAndResetLastPayment();
|
||||
if (payment != null) {
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@ public class OpponentLostLifeCondition extends IntCompareCondition {
|
|||
@Override
|
||||
protected int getInputValue(Game game, Ability source) {
|
||||
int maxLostLive = 0;
|
||||
PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher");
|
||||
PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName());
|
||||
if (watcher != null) {
|
||||
for (UUID opponentId : game.getOpponents(source.getControllerId())) {
|
||||
int lostLive = watcher.getLiveLost(opponentId);
|
||||
|
|
|
|||
|
|
@ -42,7 +42,7 @@ public enum RaidCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get("PlayerAttackedWatcher");
|
||||
PlayerAttackedWatcher watcher = (PlayerAttackedWatcher) game.getState().getWatchers().get(PlayerAttackedWatcher.class.getSimpleName());
|
||||
return watcher != null && watcher.getNumberOfAttackersCurrentTurn(source.getControllerId()) > 0;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -41,7 +41,7 @@ public enum RevoltCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
RevoltWatcher watcher = (RevoltWatcher) game.getState().getWatchers().get(RevoltWatcher.class.getName());
|
||||
RevoltWatcher watcher = (RevoltWatcher) game.getState().getWatchers().get(RevoltWatcher.class.getSimpleName());
|
||||
return watcher != null && watcher.revoltActive(source.getControllerId());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -24,7 +24,7 @@ public class SourceDealtDamageCondition implements Condition {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
DamageDoneWatcher watcher = (DamageDoneWatcher) game.getState().getWatchers().get("DamageDone");
|
||||
DamageDoneWatcher watcher = (DamageDoneWatcher) game.getState().getWatchers().get(DamageDoneWatcher.class.getSimpleName());
|
||||
return watcher != null && watcher.damageDoneBy(source.getSourceId(), source.getSourceObjectZoneChangeCounter(), game) >= value;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ public enum TargetAttackedThisTurnCondition implements Condition {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Permanent creature = game.getPermanentOrLKIBattlefield(source.getTargets().getFirstTarget());
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
|
||||
return watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(creature, game));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -18,7 +18,7 @@ public class YouGainedLifeCondition extends IntCompareCondition {
|
|||
@Override
|
||||
protected int getInputValue(Game game, Ability source) {
|
||||
int gainedLife = 0;
|
||||
PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getName());
|
||||
PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getSimpleName());
|
||||
if (watcher != null) {
|
||||
gainedLife = watcher.getLiveGained(source.getControllerId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class ControllerGotLifeCount implements DynamicValue, MageSingleton {
|
|||
}
|
||||
|
||||
public int calculate(Game game, UUID controllerId) {
|
||||
PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getName());
|
||||
PlayerGainedLifeWatcher watcher = (PlayerGainedLifeWatcher) game.getState().getWatchers().get(PlayerGainedLifeWatcher.class.getSimpleName());
|
||||
if (watcher != null) {
|
||||
return watcher.getLiveGained(controllerId);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ public class CreaturesDiedThisTurnCount implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
CreaturesDiedWatcher watcher = (CreaturesDiedWatcher)game.getState().getWatchers().get("CreaturesDiedWatcher");
|
||||
CreaturesDiedWatcher watcher = (CreaturesDiedWatcher)game.getState().getWatchers().get(CreaturesDiedWatcher.class.getSimpleName());
|
||||
if (watcher != null) {
|
||||
return watcher.getAmountOfCreaturesDiesThisTurn();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ import mage.abilities.Ability;
|
|||
import mage.abilities.dynamicvalue.DynamicValue;
|
||||
import mage.abilities.effects.Effect;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.watchers.common.PlayerLostLifeWatcher;
|
||||
|
||||
/**
|
||||
|
|
@ -46,7 +47,7 @@ public class OpponentsLostLifeCount implements DynamicValue {
|
|||
}
|
||||
|
||||
public int calculate(Game game, UUID controllerId) {
|
||||
PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get("PlayerLostLifeWatcher");
|
||||
PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName());
|
||||
if (watcher != null) {
|
||||
int amountLifeLost = 0;
|
||||
for (UUID opponentId : game.getOpponents(controllerId)) {
|
||||
|
|
|
|||
|
|
@ -13,7 +13,7 @@ public class ZuberasDiedDynamicValue implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get("ZuberasDied");
|
||||
ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get(ZuberasDiedWatcher.class.getSimpleName());
|
||||
return watcher.zuberasDiedThisTurn;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class UntapAllThatAttackedEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
Watcher watcher = game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
|
||||
if (watcher != null && watcher instanceof AttackedThisTurnWatcher) {
|
||||
Set<MageObjectReference> attackedThisTurn = ((AttackedThisTurnWatcher) watcher).getAttackedThisTurnCreatures();
|
||||
for (MageObjectReference mor : attackedThisTurn) {
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ public class AttacksIfAbleAllEffect extends RequirementEffect {
|
|||
if (eachCombat) {
|
||||
return true;
|
||||
}
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
|
||||
return watcher != null && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game));
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ public class AttacksIfAbleSourceEffect extends RequirementEffect {
|
|||
if (eachCombat) {
|
||||
return true;
|
||||
}
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getName());
|
||||
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
|
||||
return watcher != null && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(permanent, game));
|
||||
}
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ public class MustBeBlockedByAllTargetEffect extends RequirementEffect {
|
|||
Permanent attackingCreature = game.getPermanent(this.getTargetPointer().getFirst(game, source));
|
||||
if (attackingCreature != null && attackingCreature.isAttacking()) {
|
||||
if (source.getAbilityType() != AbilityType.STATIC) {
|
||||
BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get("BlockedAttackerWatcher");
|
||||
BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName());
|
||||
if (blockedAttackerWatcher != null && blockedAttackerWatcher.creatureHasBlockedAttacker(attackingCreature, permanent, game)) {
|
||||
// has already blocked this turn, so no need to do again
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -62,7 +62,7 @@ public class MustBeBlockedByTargetSourceEffect extends RequirementEffect {
|
|||
if (blocker != null && blocker.canBlock(source.getSourceId(), game)) {
|
||||
Permanent attacker = (Permanent) source.getSourceObjectIfItStillExists(game);
|
||||
if (attacker != null) {
|
||||
BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get("BlockedAttackerWatcher");
|
||||
BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName());
|
||||
if (blockedAttackerWatcher != null && blockedAttackerWatcher.creatureHasBlockedAttacker(attacker, blocker, game)) {
|
||||
// has already blocked this turn, so no need to do again
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -95,7 +95,7 @@ public class CantCastMoreThanOneSpellEffect extends ContinuousRuleModifyingEffec
|
|||
return false;
|
||||
}
|
||||
}
|
||||
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName());
|
||||
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
|
||||
if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(event.getPlayerId()) > 0) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public class DealtDamageToCreatureBySourceDies extends ReplacementEffectImpl {
|
|||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
ZoneChangeEvent zce = (ZoneChangeEvent) event;
|
||||
if (zce.isDiesEvent()) {
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get("DamagedByWatcher", source.getSourceId());
|
||||
DamagedByWatcher watcher = (DamagedByWatcher) game.getState().getWatchers().get(DamagedByWatcher.class.getSimpleName(), source.getSourceId());
|
||||
if (watcher != null) {
|
||||
return watcher.wasDamaged(zce.getTarget(), game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ public class CastOnlyIfYouHaveCastAnotherSpellEffect extends ContinuousRuleModif
|
|||
@Override
|
||||
public boolean applies(GameEvent event, Ability source, Game game) {
|
||||
if (event.getSourceId().equals(source.getSourceId())) {
|
||||
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName());
|
||||
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
|
||||
if (watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(source.getControllerId()) == 0) {
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,7 +69,7 @@ class BloodthirstEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get("DamagedOpponents", source.getControllerId());
|
||||
BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId());
|
||||
if (watcher != null && watcher.conditionMet()) {
|
||||
Permanent permanent = game.getPermanentEntering(source.getSourceId());
|
||||
if (permanent != null) {
|
||||
|
|
|
|||
|
|
@ -136,7 +136,7 @@ class ExertReplacementEffect extends ReplacementEffectImpl {
|
|||
if (creature != null && controller != null) {
|
||||
if (exertOnlyOncePerTurn) {
|
||||
MageObjectReference creatureReference = new MageObjectReference(creature.getId(), creature.getZoneChangeCounter(game), game);
|
||||
ExertedThisTurnWatcher watcher = (ExertedThisTurnWatcher) game.getState().getWatchers().get(ExertedThisTurnWatcher.class.getName());
|
||||
ExertedThisTurnWatcher watcher = (ExertedThisTurnWatcher) game.getState().getWatchers().get(ExertedThisTurnWatcher.class.getSimpleName());
|
||||
if (watcher != null && watcher.getExertedThisTurnCreatures().contains(creatureReference)) {
|
||||
return false;
|
||||
}
|
||||
|
|
@ -172,7 +172,7 @@ class ExertedThisTurnWatcher extends Watcher {
|
|||
private final Set<MageObjectReference> exertedThisTurnCreatures;
|
||||
|
||||
public ExertedThisTurnWatcher() {
|
||||
super(ExertedThisTurnWatcher.class.getName(), WatcherScope.GAME);
|
||||
super(ExertedThisTurnWatcher.class.getSimpleName(), WatcherScope.GAME);
|
||||
exertedThisTurnCreatures = new HashSet<>();
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -100,7 +100,7 @@ class GravestormEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
MageObjectReference spellRef = (MageObjectReference) this.getValue("GravestormSpellRef");
|
||||
if (spellRef != null) {
|
||||
GravestormWatcher watcher = (GravestormWatcher) game.getState().getWatchers().get("GravestormWatcher");
|
||||
GravestormWatcher watcher = (GravestormWatcher) game.getState().getWatchers().get(GravestormWatcher.class.getSimpleName());
|
||||
int gravestormCount = watcher.getGravestormCount();
|
||||
if (gravestormCount > 0) {
|
||||
Spell spell = (Spell) this.getValue("GravestormSpell");
|
||||
|
|
|
|||
|
|
@ -108,7 +108,7 @@ class MeleeDynamicValue implements DynamicValue {
|
|||
|
||||
@Override
|
||||
public int calculate(Game game, Ability sourceAbility, Effect effect) {
|
||||
MeleeWatcher watcher = (MeleeWatcher) game.getState().getWatchers().get("MeleeWatcher");
|
||||
MeleeWatcher watcher = (MeleeWatcher) game.getState().getWatchers().get(MeleeWatcher.class.getSimpleName());
|
||||
if (watcher != null) {
|
||||
return watcher.getNumberOfAttackedPlayers(sourceAbility.getControllerId());
|
||||
}
|
||||
|
|
|
|||
|
|
@ -117,7 +117,7 @@ public class ProwlAbility extends StaticAbility implements AlternativeSourceCost
|
|||
public boolean askToActivateAlternativeCosts(Ability ability, Game game) {
|
||||
if (ability instanceof SpellAbility) {
|
||||
Player player = game.getPlayer(controllerId);
|
||||
ProwlWatcher prowlWatcher = (ProwlWatcher) game.getState().getWatchers().get("Prowl");
|
||||
ProwlWatcher prowlWatcher = (ProwlWatcher) game.getState().getWatchers().get(ProwlWatcher.class.getSimpleName());
|
||||
Card card = game.getCard(ability.getSourceId());
|
||||
if (player == null || prowlWatcher == null || card == null) {
|
||||
throw new IllegalArgumentException("Params can't be null");
|
||||
|
|
|
|||
|
|
@ -68,7 +68,7 @@ public class SurgeAbility extends SpellAbility {
|
|||
@Override
|
||||
public boolean canActivate(UUID playerId, Game game) {
|
||||
// check if controller or teammate has already cast a spell this turn
|
||||
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getName());
|
||||
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
|
||||
if (watcher != null) {
|
||||
Player player = game.getPlayer(playerId);
|
||||
if (player != null) {
|
||||
|
|
|
|||
|
|
@ -54,14 +54,14 @@ public class DamagedPlayerThisTurnPredicate implements ObjectPlayerPredicate<Obj
|
|||
|
||||
switch (controller) {
|
||||
case YOU:
|
||||
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", playerId);
|
||||
PlayerDamagedBySourceWatcher watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), playerId);
|
||||
if (watcher != null) {
|
||||
return watcher.hasSourceDoneDamage(object.getId(), game);
|
||||
}
|
||||
break;
|
||||
case OPPONENT:
|
||||
for (UUID opponentId : game.getOpponents(playerId)) {
|
||||
watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", opponentId);
|
||||
watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), opponentId);
|
||||
if (watcher != null) {
|
||||
return watcher.hasSourceDoneDamage(object.getId(), game);
|
||||
}
|
||||
|
|
@ -70,7 +70,7 @@ public class DamagedPlayerThisTurnPredicate implements ObjectPlayerPredicate<Obj
|
|||
case NOT_YOU:
|
||||
for (UUID notYouId : game.getState().getPlayersInRange(playerId, game)) {
|
||||
if (!notYouId.equals(playerId)) {
|
||||
watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", notYouId);
|
||||
watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), notYouId);
|
||||
if (watcher != null) {
|
||||
return watcher.hasSourceDoneDamage(object.getId(), game);
|
||||
}
|
||||
|
|
@ -79,7 +79,7 @@ public class DamagedPlayerThisTurnPredicate implements ObjectPlayerPredicate<Obj
|
|||
break;
|
||||
case ANY:
|
||||
for (UUID anyId : game.getState().getPlayersInRange(playerId, game)) {
|
||||
watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get("PlayerDamagedBySource", anyId);
|
||||
watcher = (PlayerDamagedBySourceWatcher) game.getState().getWatchers().get(PlayerDamagedBySourceWatcher.class.getSimpleName(), anyId);
|
||||
if (watcher != null) {
|
||||
return watcher.hasSourceDoneDamage(object.getId(), game);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -183,7 +183,7 @@ public abstract class GameCommanderImpl extends GameImpl {
|
|||
protected boolean checkStateBasedActions() {
|
||||
for (Player player : getPlayers().values()) {
|
||||
for (UUID commanderId : player.getCommandersIds()) {
|
||||
CommanderInfoWatcher damageWatcher = (CommanderInfoWatcher) getState().getWatchers().get("CommanderCombatDamageWatcher", commanderId);
|
||||
CommanderInfoWatcher damageWatcher = (CommanderInfoWatcher) getState().getWatchers().get(CommanderInfoWatcher.class.getSimpleName(), commanderId);
|
||||
if (damageWatcher == null) {
|
||||
continue;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue