diff --git a/Mage.Sets/src/mage/cards/a/AetherfluxReservoir.java b/Mage.Sets/src/mage/cards/a/AetherfluxReservoir.java index 5b25220b99..f835909a00 100644 --- a/Mage.Sets/src/mage/cards/a/AetherfluxReservoir.java +++ b/Mage.Sets/src/mage/cards/a/AetherfluxReservoir.java @@ -51,7 +51,10 @@ class AetherfluxReservoirDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); - return watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(sourceAbility.getControllerId()); + if(watcher != null) { + return watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(sourceAbility.getControllerId()); + } + return 0; } @Override diff --git a/Mage.Sets/src/mage/cards/a/ArchfiendOfDespair.java b/Mage.Sets/src/mage/cards/a/ArchfiendOfDespair.java index 4d5bc436e4..c7c5a5ed6f 100644 --- a/Mage.Sets/src/mage/cards/a/ArchfiendOfDespair.java +++ b/Mage.Sets/src/mage/cards/a/ArchfiendOfDespair.java @@ -84,7 +84,7 @@ class ArchfiendOfDespairEffect extends OneShotEffect { for (UUID playerId : game.getOpponents(controller.getId())) { Player opponent = game.getPlayer(playerId); if (opponent != null) { - int lifeLost = watcher.getLiveLost(playerId); + int lifeLost = watcher.getLifeLost(playerId); if (lifeLost > 0) { opponent.loseLife(lifeLost, game, false); } diff --git a/Mage.Sets/src/mage/cards/b/BloodcrazedGoblin.java b/Mage.Sets/src/mage/cards/b/BloodcrazedGoblin.java index a67946442b..fbc0a3c769 100644 --- a/Mage.Sets/src/mage/cards/b/BloodcrazedGoblin.java +++ b/Mage.Sets/src/mage/cards/b/BloodcrazedGoblin.java @@ -2,7 +2,6 @@ package mage.cards.b; -import java.util.UUID; import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; @@ -17,15 +16,16 @@ import mage.game.Game; import mage.game.permanent.Permanent; import mage.watchers.common.BloodthirstWatcher; +import java.util.UUID; + /** - * * @author BetaSteward_at_googlemail.com * @author North */ public final class BloodcrazedGoblin extends CardImpl { public BloodcrazedGoblin(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{R}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{R}"); this.subtype.add(SubType.GOBLIN, SubType.BERSERKER); this.power = new MageInt(2); @@ -70,7 +70,7 @@ class BloodcrazedGoblinEffect extends RestrictionEffect { public boolean applies(Permanent permanent, Ability source, Game game) { if (permanent.getId().equals(source.getSourceId())) { BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); // BloodthirstWatcher - return !watcher.conditionMet(); + return watcher != null && !watcher.conditionMet(); } return false; } diff --git a/Mage.Sets/src/mage/cards/b/BrimstoneVolley.java b/Mage.Sets/src/mage/cards/b/BrimstoneVolley.java index dd37a947c6..168cdae234 100644 --- a/Mage.Sets/src/mage/cards/b/BrimstoneVolley.java +++ b/Mage.Sets/src/mage/cards/b/BrimstoneVolley.java @@ -54,7 +54,7 @@ class BrimstoneVolleyEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { int damage = 3; Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName()); - if (watcher.conditionMet()) { + if (watcher != null && watcher.conditionMet()) { damage = 5; } Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); diff --git a/Mage.Sets/src/mage/cards/b/BrutalHordechief.java b/Mage.Sets/src/mage/cards/b/BrutalHordechief.java index e3b37d6800..0565345b7d 100644 --- a/Mage.Sets/src/mage/cards/b/BrutalHordechief.java +++ b/Mage.Sets/src/mage/cards/b/BrutalHordechief.java @@ -156,6 +156,9 @@ class BrutalHordechiefChooseBlockersEffect extends ContinuousRuleModifyingEffect @Override public boolean applies(GameEvent event, Ability source, Game game) { ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); + if(watcher == null){ + return false; + } watcher.decrement(); if (watcher.copyCountApply > 0) { game.informPlayers(source.getSourceObject(game).getIdName() + " didn't apply"); diff --git a/Mage.Sets/src/mage/cards/c/ChildrenOfKorlis.java b/Mage.Sets/src/mage/cards/c/ChildrenOfKorlis.java index c38f2ec2f4..d6165cffc5 100644 --- a/Mage.Sets/src/mage/cards/c/ChildrenOfKorlis.java +++ b/Mage.Sets/src/mage/cards/c/ChildrenOfKorlis.java @@ -54,7 +54,7 @@ class SourceControllerLostLifeCount implements DynamicValue { public int calculate(Game game, Ability sourceAbility, Effect effect) { PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (watcher != null) { - return watcher.getLiveLost(sourceAbility.getControllerId()); + return watcher.getLifeLost(sourceAbility.getControllerId()); } return 0; } diff --git a/Mage.Sets/src/mage/cards/d/DuelingGrounds.java b/Mage.Sets/src/mage/cards/d/DuelingGrounds.java index 92c0cbe041..fbab09bf33 100644 --- a/Mage.Sets/src/mage/cards/d/DuelingGrounds.java +++ b/Mage.Sets/src/mage/cards/d/DuelingGrounds.java @@ -75,6 +75,9 @@ class NoMoreThanOneCreatureCanAttackEachTurnEffect extends RestrictionEffect { return false; } AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); + if(watcher == null){ + return false; + } Set attackedThisTurnCreatures = watcher.getAttackedThisTurnCreatures(); return attackedThisTurnCreatures.isEmpty() || (attackedThisTurnCreatures.size() == 1 && attackedThisTurnCreatures.contains(new MageObjectReference(attacker, game))); @@ -109,6 +112,9 @@ class NoMoreThanOneCreatureCanBlockEachTurnEffect extends RestrictionEffect { return false; } BlockedThisTurnWatcher watcher = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName()); + if(watcher == null){ + return false; + } Set blockedThisTurnCreatures = watcher.getBlockedThisTurnCreatures(); MageObjectReference blockerReference = new MageObjectReference(blocker.getId(), blocker.getZoneChangeCounter(game), game); return blockedThisTurnCreatures.isEmpty() diff --git a/Mage.Sets/src/mage/cards/e/ErgRaiders.java b/Mage.Sets/src/mage/cards/e/ErgRaiders.java index fbf0ea92e3..3ad0a59eef 100644 --- a/Mage.Sets/src/mage/cards/e/ErgRaiders.java +++ b/Mage.Sets/src/mage/cards/e/ErgRaiders.java @@ -57,6 +57,6 @@ class ErgRaidersCondition implements Condition { Permanent raiders = game.getPermanentOrLKIBattlefield(source.getSourceId()); AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); // wasControlledFromStartOfControllerTurn should be checked during resolution I guess, but shouldn't be relevant - return raiders.wasControlledFromStartOfControllerTurn() && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(raiders, game)); + return raiders != null &&raiders.wasControlledFromStartOfControllerTurn() && watcher != null && !watcher.getAttackedThisTurnCreatures().contains(new MageObjectReference(raiders, game)); } } diff --git a/Mage.Sets/src/mage/cards/f/FeastOnTheFallen.java b/Mage.Sets/src/mage/cards/f/FeastOnTheFallen.java index 22d1800804..7d37092fff 100644 --- a/Mage.Sets/src/mage/cards/f/FeastOnTheFallen.java +++ b/Mage.Sets/src/mage/cards/f/FeastOnTheFallen.java @@ -57,7 +57,7 @@ enum FeastOnTheFallenCondition implements Condition { PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (watcher != null) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { - if (watcher.getLiveLostLastTurn(opponentId) > 0) { + if (watcher.getLifeLostLastTurn(opponentId) > 0) { return true; } } diff --git a/Mage.Sets/src/mage/cards/f/FyndhornDruid.java b/Mage.Sets/src/mage/cards/f/FyndhornDruid.java index 78c6ef165e..b1b49136b1 100644 --- a/Mage.Sets/src/mage/cards/f/FyndhornDruid.java +++ b/Mage.Sets/src/mage/cards/f/FyndhornDruid.java @@ -51,6 +51,6 @@ class SourceWasBlockedThisTurnCondition implements Condition { public boolean apply(Game game, Ability source) { Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); WasBlockedThisTurnWatcher watcher = (WasBlockedThisTurnWatcher) game.getState().getWatchers().get(WasBlockedThisTurnWatcher.class.getSimpleName()); - return sourcePermanent != null && watcher.getWasBlockedThisTurnCreatures().contains(new MageObjectReference(sourcePermanent, game)); + return sourcePermanent != null && watcher != null && watcher.getWasBlockedThisTurnCreatures().contains(new MageObjectReference(sourcePermanent, game)); } } diff --git a/Mage.Sets/src/mage/cards/g/GisaAndGeralf.java b/Mage.Sets/src/mage/cards/g/GisaAndGeralf.java index 66e7d23cbd..ab9e185c8d 100644 --- a/Mage.Sets/src/mage/cards/g/GisaAndGeralf.java +++ b/Mage.Sets/src/mage/cards/g/GisaAndGeralf.java @@ -121,7 +121,7 @@ class GisaAndGeralfCastFromGraveyardEffect extends AsThoughEffectImpl { if (objectId.equals(getTargetPointer().getFirst(game, source))) { if (affectedControllerId.equals(source.getControllerId())) { GisaAndGeralfWatcher watcher = (GisaAndGeralfWatcher) game.getState().getWatchers().get(GisaAndGeralfWatcher.class.getSimpleName(), source.getSourceId()); - return !watcher.isAbilityUsed(); + return watcher != null && !watcher.isAbilityUsed(); } } return false; @@ -145,7 +145,7 @@ class GisaAndGeralfWatcher extends Watcher { public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.GRAVEYARD) { Spell spell = (Spell) game.getObject(event.getTargetId()); - if (spell.isCreature() && spell.hasSubtype(SubType.ZOMBIE, game)) { + if (spell != null && spell.isCreature() && spell.hasSubtype(SubType.ZOMBIE, game)) { abilityUsed = true; } } diff --git a/Mage.Sets/src/mage/cards/h/HeatStroke.java b/Mage.Sets/src/mage/cards/h/HeatStroke.java index 130b465e31..414daf009e 100644 --- a/Mage.Sets/src/mage/cards/h/HeatStroke.java +++ b/Mage.Sets/src/mage/cards/h/HeatStroke.java @@ -68,6 +68,7 @@ class HeatStrokeEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { BlockedThisTurnWatcher blockedWatcher = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName()); WasBlockedThisTurnWatcher wasBlockedThisTurnWatcher = (WasBlockedThisTurnWatcher) game.getState().getWatchers().get(WasBlockedThisTurnWatcher.class.getSimpleName()); + Set inROI = new HashSet<>(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)); boolean toRet = false; Set toDestroy = new HashSet<>(); diff --git a/Mage.Sets/src/mage/cards/h/HuntDown.java b/Mage.Sets/src/mage/cards/h/HuntDown.java index f03e5c2107..2d2c6f1fa5 100644 --- a/Mage.Sets/src/mage/cards/h/HuntDown.java +++ b/Mage.Sets/src/mage/cards/h/HuntDown.java @@ -68,7 +68,7 @@ class HuntDownEffect extends RequirementEffect { Permanent blocker = game.getPermanent(source.getTargets().get(0).getFirstTarget()); if (blocker != null && blocker.canBlock(source.getTargets().get(1).getFirstTarget(), game)) { - Permanent attacker = (Permanent) game.getPermanent(source.getTargets().get(1).getFirstTarget()); + Permanent attacker = game.getPermanent(source.getTargets().get(1).getFirstTarget()); if (attacker != null) { BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); if (blockedAttackerWatcher != null diff --git a/Mage.Sets/src/mage/cards/i/Impatience.java b/Mage.Sets/src/mage/cards/i/Impatience.java index 7e40923e11..93c267c58c 100644 --- a/Mage.Sets/src/mage/cards/i/Impatience.java +++ b/Mage.Sets/src/mage/cards/i/Impatience.java @@ -47,7 +47,7 @@ class ImpatienceCondition implements Condition { @Override public boolean apply(Game game, Ability source) { CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); - return watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(game.getActivePlayerId()) == 0; + return watcher != null && watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(game.getActivePlayerId()) == 0; } public String toString() { diff --git a/Mage.Sets/src/mage/cards/k/KaradorGhostChieftain.java b/Mage.Sets/src/mage/cards/k/KaradorGhostChieftain.java index aba7458be3..8a64ceeeb1 100644 --- a/Mage.Sets/src/mage/cards/k/KaradorGhostChieftain.java +++ b/Mage.Sets/src/mage/cards/k/KaradorGhostChieftain.java @@ -151,7 +151,7 @@ class KaradorGhostChieftainCastFromGraveyardEffect extends AsThoughEffectImpl { if (objectId.equals(getTargetPointer().getFirst(game, source))) { if (affectedControllerId.equals(source.getControllerId())) { KaradorGhostChieftainWatcher watcher = (KaradorGhostChieftainWatcher) game.getState().getWatchers().get(KaradorGhostChieftainWatcher.class.getSimpleName(), source.getSourceId()); - return !watcher.isAbilityUsed(); + return watcher != null && !watcher.isAbilityUsed(); } } return false; diff --git a/Mage.Sets/src/mage/cards/k/KessDissidentMage.java b/Mage.Sets/src/mage/cards/k/KessDissidentMage.java index ecc3620585..6cd52ac84b 100644 --- a/Mage.Sets/src/mage/cards/k/KessDissidentMage.java +++ b/Mage.Sets/src/mage/cards/k/KessDissidentMage.java @@ -94,7 +94,7 @@ class KessDissidentMageCastFromGraveyardEffect extends AsThoughEffectImpl { && game.getState().getZone(objectId).equals(Zone.GRAVEYARD)) { // check if not already a card was cast this turn with this ability KessDissidentMageWatcher watcher = (KessDissidentMageWatcher) game.getState().getWatchers().get(KessDissidentMageWatcher.class.getSimpleName()); - return !watcher.isAbilityUsed(new MageObjectReference(source.getSourceId(), game)); + return watcher != null && !watcher.isAbilityUsed(new MageObjectReference(source.getSourceId(), game)); } } return false; @@ -138,7 +138,7 @@ class KessDissidentMageReplacementEffect extends ReplacementEffectImpl { ZoneChangeEvent zEvent = (ZoneChangeEvent) event; if (zEvent.getToZone() == Zone.GRAVEYARD) { KessDissidentMageWatcher watcher = (KessDissidentMageWatcher) game.getState().getWatchers().get(KessDissidentMageWatcher.class.getSimpleName()); - if (source.getSourceId().equals(watcher.spellCastWasAllowedBy(new MageObjectReference(event.getTargetId(), game)))) { + if (watcher != null && source.getSourceId().equals(watcher.spellCastWasAllowedBy(new MageObjectReference(event.getTargetId(), game)))) { return true; } } diff --git a/Mage.Sets/src/mage/cards/k/KrovikanVampire.java b/Mage.Sets/src/mage/cards/k/KrovikanVampire.java index c260081ba4..d6593ff621 100644 --- a/Mage.Sets/src/mage/cards/k/KrovikanVampire.java +++ b/Mage.Sets/src/mage/cards/k/KrovikanVampire.java @@ -116,22 +116,20 @@ enum KrovikanVampireInterveningIfCondition implements Condition { KrovikanVampireCreaturesDamagedWatcher watcherDamaged = (KrovikanVampireCreaturesDamagedWatcher) game.getState().getWatchers().get(KrovikanVampireCreaturesDamagedWatcher.class.getSimpleName()); if (watcherDied != null) { Set creaturesThatDiedThisTurn = watcherDied.diedThisTurn; - if (creaturesThatDiedThisTurn != null) { - for (UUID mor : creaturesThatDiedThisTurn) { - if (watcherDamaged != null) { - for (UUID mor2 : watcherDamaged.getDamagedBySource()) { - if (mor2 != null - && mor == mor2) { - creaturesAffected.add(mor); - } + for (UUID mor : creaturesThatDiedThisTurn) { + if (watcherDamaged != null) { + for (UUID mor2 : watcherDamaged.getDamagedBySource()) { + if (mor2 != null + && mor == mor2) { + creaturesAffected.add(mor); } } } - if (creaturesAffected != null - && creaturesAffected.size() > 0) { - game.getState().setValue(source.getSourceId() + "creatureToGainControl", creaturesAffected); - return true; - } + } + if (creaturesAffected != null + && creaturesAffected.size() > 0) { + game.getState().setValue(source.getSourceId() + "creatureToGainControl", creaturesAffected); + return true; } } return false; diff --git a/Mage.Sets/src/mage/cards/k/KydeleChosenOfKruphix.java b/Mage.Sets/src/mage/cards/k/KydeleChosenOfKruphix.java index ba654daf77..aedb737dc0 100644 --- a/Mage.Sets/src/mage/cards/k/KydeleChosenOfKruphix.java +++ b/Mage.Sets/src/mage/cards/k/KydeleChosenOfKruphix.java @@ -58,7 +58,10 @@ class CardsDrawnThisTurnDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { KydeleCardsDrawnThisTurnWatcher watcher = (KydeleCardsDrawnThisTurnWatcher) game.getState().getWatchers().get(KydeleCardsDrawnThisTurnWatcher.class.getSimpleName()); - return watcher.getCardsDrawnThisTurn(sourceAbility.getControllerId()); + if(watcher != null) { + return watcher.getCardsDrawnThisTurn(sourceAbility.getControllerId()); + } + return 0; } @Override diff --git a/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java b/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java index 9499bda49e..d75b41a30a 100644 --- a/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java +++ b/Mage.Sets/src/mage/cards/l/LudevicNecroAlchemist.java @@ -65,7 +65,7 @@ class LudevicNecroAlchemistCondition implements Condition { currentPlayer = playerList.getNext(game); while (watcher != null && currentPlayer != null) { - if (!Objects.equals(currentPlayer.getId(), sourcePlayerId) && watcher.getLiveLost(currentPlayer.getId()) > 0) { + if (!Objects.equals(currentPlayer.getId(), sourcePlayerId) && watcher.getLifeLost(currentPlayer.getId()) > 0) { return true; } if (Objects.equals(currentPlayer, firstPlayer)) { diff --git a/Mage.Sets/src/mage/cards/l/LuminarchAscension.java b/Mage.Sets/src/mage/cards/l/LuminarchAscension.java index b2710993d1..045707bfda 100644 --- a/Mage.Sets/src/mage/cards/l/LuminarchAscension.java +++ b/Mage.Sets/src/mage/cards/l/LuminarchAscension.java @@ -121,7 +121,7 @@ enum YouLostNoLifeThisTurnCondition implements Condition { public boolean apply(Game game, Ability source) { PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (watcher != null) { - return (watcher.getLiveLost(source.getControllerId()) == 0); + return (watcher.getLifeLost(source.getControllerId()) == 0); } return false; } diff --git a/Mage.Sets/src/mage/cards/m/MadDog.java b/Mage.Sets/src/mage/cards/m/MadDog.java index f9206d7ec0..72f18fa119 100644 --- a/Mage.Sets/src/mage/cards/m/MadDog.java +++ b/Mage.Sets/src/mage/cards/m/MadDog.java @@ -65,11 +65,11 @@ enum MadDogCondition implements Condition { && madDog != null) { // For some reason, compare did not work when checking the lists. Thus the interation. List permanents = watcher.getThisTurnEnteringPermanents(source.getControllerId()); - if (!permanents.stream().noneMatch((p) -> (p.getId().equals(madDog.getId())))) { + if (permanents.stream().anyMatch((p) -> (p.getId().equals(madDog.getId())))) { return false; } Set mor = watcher2.getAttackedThisTurnCreatures(); - if (!mor.stream().noneMatch((m) -> (m.getPermanent(game).equals(madDog)))) { + if (mor.stream().anyMatch((m) -> (m.getPermanent(game).equals(madDog)))) { return false; } return true; // Mad Dog did not come into play this turn nor did he attack this turn. Sacrifice the hound. diff --git a/Mage.Sets/src/mage/cards/m/MagusOfTheMind.java b/Mage.Sets/src/mage/cards/m/MagusOfTheMind.java index 5ee6f042a7..d7ae654535 100644 --- a/Mage.Sets/src/mage/cards/m/MagusOfTheMind.java +++ b/Mage.Sets/src/mage/cards/m/MagusOfTheMind.java @@ -79,6 +79,9 @@ class MagusOfTheMindEffect extends OneShotEffect { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObject(game); CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + if(watcher == null){ + return false; + } int stormCount = watcher.getAmountOfSpellsAllPlayersCastOnCurrentTurn() + 1; if (controller != null && sourceObject != null) { controller.shuffleLibrary(source, game); diff --git a/Mage.Sets/src/mage/cards/m/MasterWarcraft.java b/Mage.Sets/src/mage/cards/m/MasterWarcraft.java index a5861363c5..641d328715 100644 --- a/Mage.Sets/src/mage/cards/m/MasterWarcraft.java +++ b/Mage.Sets/src/mage/cards/m/MasterWarcraft.java @@ -154,6 +154,9 @@ class MasterWarcraftChooseAttackersEffect extends ContinuousRuleModifyingEffectI @Override public boolean applies(GameEvent event, Ability source, Game game) { MasterWarcraftCastWatcher watcher = (MasterWarcraftCastWatcher) game.getState().getWatchers().get(MasterWarcraftCastWatcher.class.getSimpleName()); + if(watcher == null){ + return false; + } watcher.decrement(); if (watcher.copyCountApply > 0) { game.informPlayers(source.getSourceObject(game).getIdName() + " didn't apply"); @@ -227,6 +230,9 @@ class MasterWarcraftChooseBlockersEffect extends ContinuousRuleModifyingEffectIm @Override public boolean applies(GameEvent event, Ability source, Game game) { ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); + if(watcher == null){ + return false; + } watcher.decrement(); if (watcher.copyCountApply > 0) { game.informPlayers(source.getSourceObject(game).getIdName() + " didn't apply"); diff --git a/Mage.Sets/src/mage/cards/m/Melee.java b/Mage.Sets/src/mage/cards/m/Melee.java index 3031c15e64..b526764238 100644 --- a/Mage.Sets/src/mage/cards/m/Melee.java +++ b/Mage.Sets/src/mage/cards/m/Melee.java @@ -1,7 +1,6 @@ package mage.cards.m; -import java.util.UUID; import mage.abilities.Ability; import mage.abilities.DelayedTriggeredAbility; import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility; @@ -17,19 +16,21 @@ import mage.abilities.effects.common.RemoveFromCombatTargetEffect; import mage.abilities.effects.common.UntapTargetEffect; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.*; +import mage.constants.CardType; +import mage.constants.Duration; +import mage.constants.Outcome; +import mage.constants.TurnPhase; import mage.game.Game; import mage.game.combat.CombatGroup; import mage.game.events.GameEvent; -import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; import mage.target.targetpointer.FixedTarget; -import mage.watchers.Watcher; import mage.watchers.common.ChooseBlockersRedundancyWatcher; +import java.util.UUID; + /** - * * @author L_J */ public final class Melee extends CardImpl { @@ -61,17 +62,17 @@ public final class Melee extends CardImpl { public Melee copy() { return new Melee(this); } - + private class ChooseBlockersRedundancyWatcherIncrementEffect extends OneShotEffect { - + ChooseBlockersRedundancyWatcherIncrementEffect() { super(Outcome.Neutral); } - + ChooseBlockersRedundancyWatcherIncrementEffect(final ChooseBlockersRedundancyWatcherIncrementEffect effect) { super(effect); } - + @Override public boolean apply(Game game, Ability source) { ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); @@ -81,7 +82,7 @@ public final class Melee extends CardImpl { } return false; } - + @Override public ChooseBlockersRedundancyWatcherIncrementEffect copy() { return new ChooseBlockersRedundancyWatcherIncrementEffect(this); @@ -118,6 +119,9 @@ class MeleeChooseBlockersEffect extends ContinuousRuleModifyingEffectImpl { @Override public boolean applies(GameEvent event, Ability source, Game game) { ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); + if (watcher == null) { + return false; + } watcher.decrement(); watcher.copyCount--; if (watcher.copyCountApply > 0) { diff --git a/Mage.Sets/src/mage/cards/m/MoltenPsyche.java b/Mage.Sets/src/mage/cards/m/MoltenPsyche.java index bd9f8b6e8d..8d5f4594d3 100644 --- a/Mage.Sets/src/mage/cards/m/MoltenPsyche.java +++ b/Mage.Sets/src/mage/cards/m/MoltenPsyche.java @@ -87,7 +87,7 @@ class MoltenPsycheEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { if (game.isOpponent(controller, playerId)) { Player player = game.getPlayer(playerId); - if (player != null) { + if (player != null && watcher != null) { player.damage(watcher.getDraws(playerId), source.getSourceId(), game, false, true); } } diff --git a/Mage.Sets/src/mage/cards/m/MultanisPresence.java b/Mage.Sets/src/mage/cards/m/MultanisPresence.java index 2ad766fea5..2cfb6d3a7e 100644 --- a/Mage.Sets/src/mage/cards/m/MultanisPresence.java +++ b/Mage.Sets/src/mage/cards/m/MultanisPresence.java @@ -63,7 +63,7 @@ class MultanisPresenceTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { MultanisPresenceWatcher watcher = (MultanisPresenceWatcher) game.getState().getWatchers().get(MultanisPresenceWatcher.class.getSimpleName()); - return (watcher.getSpellsCastThisTurn(controllerId).contains(event.getTargetId())); + return watcher != null && watcher.getSpellsCastThisTurn(controllerId).contains(event.getTargetId()); } @Override diff --git a/Mage.Sets/src/mage/cards/o/OdricMasterTactician.java b/Mage.Sets/src/mage/cards/o/OdricMasterTactician.java index 70498e24c5..8b3128f475 100644 --- a/Mage.Sets/src/mage/cards/o/OdricMasterTactician.java +++ b/Mage.Sets/src/mage/cards/o/OdricMasterTactician.java @@ -131,6 +131,9 @@ class OdricMasterTacticianChooseBlockersEffect extends ContinuousRuleModifyingEf @Override public boolean applies(GameEvent event, Ability source, Game game) { ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); + if(watcher == null){ + return false; + } watcher.decrement(); watcher.copyCount--; if (watcher.copyCountApply > 0) { diff --git a/Mage.Sets/src/mage/cards/p/PowerSurge.java b/Mage.Sets/src/mage/cards/p/PowerSurge.java index 186e7039ba..4467777139 100644 --- a/Mage.Sets/src/mage/cards/p/PowerSurge.java +++ b/Mage.Sets/src/mage/cards/p/PowerSurge.java @@ -65,9 +65,11 @@ class PowerSurgeDamageEffect extends OneShotEffect { Player player = game.getPlayer(targetPointer.getFirst(game, source)); if (player != null) { PowerSurgeWatcher watcher = (PowerSurgeWatcher) game.getState().getWatchers().get(PowerSurgeWatcher.class.getSimpleName()); - int damage = watcher.getUntappedLandCount(); - player.damage(damage, source.getSourceId(), game, false, true); - return true; + if(watcher != null) { + int damage = watcher.getUntappedLandCount(); + player.damage(damage, source.getSourceId(), game, false, true); + return true; + } } return false; } diff --git a/Mage.Sets/src/mage/cards/p/PrematureBurial.java b/Mage.Sets/src/mage/cards/p/PrematureBurial.java index 3f8ac248ae..07656dd653 100644 --- a/Mage.Sets/src/mage/cards/p/PrematureBurial.java +++ b/Mage.Sets/src/mage/cards/p/PrematureBurial.java @@ -83,7 +83,7 @@ class ETBSinceYourLastTurnTarget extends TargetCreaturePermanent { if(targetSource != null) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { if (permanent.canBeTargetedBy(targetSource, sourceControllerId, game)) { - if (watcher.enteredSinceLastTurn(sourceControllerId, new MageObjectReference(permanent.getId(), game))) { + if (watcher != null && watcher.enteredSinceLastTurn(sourceControllerId, new MageObjectReference(permanent.getId(), game))) { return true; } } diff --git a/Mage.Sets/src/mage/cards/r/ReaperFromTheAbyss.java b/Mage.Sets/src/mage/cards/r/ReaperFromTheAbyss.java index c9a9bf3f10..530594cba3 100644 --- a/Mage.Sets/src/mage/cards/r/ReaperFromTheAbyss.java +++ b/Mage.Sets/src/mage/cards/r/ReaperFromTheAbyss.java @@ -82,7 +82,7 @@ class ReaperFromTheAbyssAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName()); - return watcher.conditionMet(); + return watcher != null && watcher.conditionMet(); } @Override diff --git a/Mage.Sets/src/mage/cards/r/Revenge.java b/Mage.Sets/src/mage/cards/r/Revenge.java index 2674b8c0fd..140696b541 100644 --- a/Mage.Sets/src/mage/cards/r/Revenge.java +++ b/Mage.Sets/src/mage/cards/r/Revenge.java @@ -65,7 +65,7 @@ enum LostLifeCondition implements Condition { PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); UUID player = source.getControllerId(); if (watcher != null && player != null) { - return watcher.getLiveLost(player) > 0; + return watcher.getLifeLost(player) > 0; } return false; } diff --git a/Mage.Sets/src/mage/cards/r/RimehornAurochs.java b/Mage.Sets/src/mage/cards/r/RimehornAurochs.java index 1976045e92..a982d12576 100644 --- a/Mage.Sets/src/mage/cards/r/RimehornAurochs.java +++ b/Mage.Sets/src/mage/cards/r/RimehornAurochs.java @@ -87,7 +87,7 @@ class RimehornAurochsEffect extends RequirementEffect { Permanent blocker = game.getPermanent(source.getTargets().get(0).getFirstTarget()); if (blocker != null && blocker.canBlock(source.getTargets().get(1).getFirstTarget(), game)) { - Permanent attacker = (Permanent) game.getPermanent(source.getTargets().get(1).getFirstTarget()); + Permanent attacker = game.getPermanent(source.getTargets().get(1).getFirstTarget()); if (attacker != null) { BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); if (blockedAttackerWatcher != null diff --git a/Mage.Sets/src/mage/cards/r/RixMaadiGuildmage.java b/Mage.Sets/src/mage/cards/r/RixMaadiGuildmage.java index 0f8e1c76a9..891f0b5ed9 100644 --- a/Mage.Sets/src/mage/cards/r/RixMaadiGuildmage.java +++ b/Mage.Sets/src/mage/cards/r/RixMaadiGuildmage.java @@ -74,7 +74,7 @@ class PlayerLostLifePredicate implements Predicate { public boolean apply(Player input, Game game) { PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (watcher != null) { - return (0 < watcher.getLiveLost(input.getId())); + return (0 < watcher.getLifeLost(input.getId())); } return false; } diff --git a/Mage.Sets/src/mage/cards/r/RocketLauncher.java b/Mage.Sets/src/mage/cards/r/RocketLauncher.java index 5fb0060a45..2cc8d0b348 100644 --- a/Mage.Sets/src/mage/cards/r/RocketLauncher.java +++ b/Mage.Sets/src/mage/cards/r/RocketLauncher.java @@ -99,7 +99,7 @@ enum ControlledTurnCondition implements Condition { public boolean apply(Game game, Ability source) { RocketLauncherWatcher watcher = (RocketLauncherWatcher) game.getState().getWatchers().get(RocketLauncherWatcher.class.getSimpleName()); - return !watcher.changedControllerOR1stTurn; + return watcher != null && !watcher.changedControllerOR1stTurn; } @Override diff --git a/Mage.Sets/src/mage/cards/s/SecondGuess.java b/Mage.Sets/src/mage/cards/s/SecondGuess.java index 140e9f74a2..6a65427e44 100644 --- a/Mage.Sets/src/mage/cards/s/SecondGuess.java +++ b/Mage.Sets/src/mage/cards/s/SecondGuess.java @@ -51,7 +51,7 @@ class SecondSpellPredicate implements Predicate { public boolean apply(StackObject input, Game game) { CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); - if (watcher.getSpellOrder(new MageObjectReference(input.getId(), game), game) == 2) { + if (watcher != null && watcher.getSpellOrder(new MageObjectReference(input.getId(), game), game) == 2) { return true; } diff --git a/Mage.Sets/src/mage/cards/s/SilentChantZubera.java b/Mage.Sets/src/mage/cards/s/SilentChantZubera.java index 8854eb990e..1d186102d0 100644 --- a/Mage.Sets/src/mage/cards/s/SilentChantZubera.java +++ b/Mage.Sets/src/mage/cards/s/SilentChantZubera.java @@ -49,7 +49,10 @@ class SilentChantZuberaDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get(ZuberasDiedWatcher.class.getSimpleName()); - return watcher.zuberasDiedThisTurn * 2; + if(watcher != null) { + return watcher.zuberasDiedThisTurn * 2; + } + return 0; } @Override diff --git a/Mage.Sets/src/mage/cards/s/SkarrganFirebird.java b/Mage.Sets/src/mage/cards/s/SkarrganFirebird.java index 9f445da773..ad3da8d578 100644 --- a/Mage.Sets/src/mage/cards/s/SkarrganFirebird.java +++ b/Mage.Sets/src/mage/cards/s/SkarrganFirebird.java @@ -62,7 +62,7 @@ class OpponentWasDealtDamageCondition implements Condition { @Override public boolean apply(Game game, Ability source) { BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); - return watcher.conditionMet(); + return watcher != null && watcher.conditionMet(); } @Override diff --git a/Mage.Sets/src/mage/cards/s/StormEntity.java b/Mage.Sets/src/mage/cards/s/StormEntity.java index e0a2f1adf0..2635920bd0 100644 --- a/Mage.Sets/src/mage/cards/s/StormEntity.java +++ b/Mage.Sets/src/mage/cards/s/StormEntity.java @@ -55,7 +55,10 @@ class OtherSpellsCastThisTurnCount implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); - return watcher.getAmountOfSpellsAllPlayersCastOnCurrentTurn() - 1; + if(watcher != null ) { + return watcher.getAmountOfSpellsAllPlayersCastOnCurrentTurn() - 1; + } + return 0; } @Override diff --git a/Mage.Sets/src/mage/cards/t/TaintedSigil.java b/Mage.Sets/src/mage/cards/t/TaintedSigil.java index 18f6f77378..d189045f4c 100644 --- a/Mage.Sets/src/mage/cards/t/TaintedSigil.java +++ b/Mage.Sets/src/mage/cards/t/TaintedSigil.java @@ -60,7 +60,7 @@ class AllPlayersLostLifeCount implements DynamicValue { if (watcher != null) { int amountLifeLost = 0; for (UUID playerId : game.getState().getPlayersInRange(controllerId, game)) { - amountLifeLost += watcher.getLiveLost(playerId); + amountLifeLost += watcher.getLifeLost(playerId); } return amountLifeLost; } diff --git a/Mage.Sets/src/mage/cards/t/ThirstingAxe.java b/Mage.Sets/src/mage/cards/t/ThirstingAxe.java index e5da2e1873..c9134558f4 100644 --- a/Mage.Sets/src/mage/cards/t/ThirstingAxe.java +++ b/Mage.Sets/src/mage/cards/t/ThirstingAxe.java @@ -73,7 +73,7 @@ class EquippedDealtCombatDamageToCreatureCondition implements Condition { if (equipment != null && equipment.getAttachedTo() != null) { CombatDamageToCreatureWatcher watcher = (CombatDamageToCreatureWatcher) game.getState().getWatchers().get(CombatDamageToCreatureWatcher.BASIC_KEY); - return watcher.dealtDamage(equipment.getAttachedTo(), equipment.getAttachedToZoneChangeCounter(), game); + return watcher != null && watcher.dealtDamage(equipment.getAttachedTo(), equipment.getAttachedToZoneChangeCounter(), game); } return false; } diff --git a/Mage.Sets/src/mage/cards/t/TuvasaTheSunlit.java b/Mage.Sets/src/mage/cards/t/TuvasaTheSunlit.java index 5af7d2b974..425cf9f478 100644 --- a/Mage.Sets/src/mage/cards/t/TuvasaTheSunlit.java +++ b/Mage.Sets/src/mage/cards/t/TuvasaTheSunlit.java @@ -98,7 +98,7 @@ class TuvasaTheSunlitTriggeredAbility extends SpellCastControllerTriggeredAbilit TuvasaTheSunlitWatcher watcher = (TuvasaTheSunlitWatcher) game.getState().getWatchers().get( TuvasaTheSunlitWatcher.class.getSimpleName() ); - return event.getTargetId().equals(watcher.getFirstEnchantmentThisTurn(this.getControllerId())); + return watcher != null && event.getTargetId().equals(watcher.getFirstEnchantmentThisTurn(this.getControllerId())); } return false; } diff --git a/Mage.Sets/src/mage/cards/u/UrzasMiter.java b/Mage.Sets/src/mage/cards/u/UrzasMiter.java index d65cdd52c5..90575263f6 100644 --- a/Mage.Sets/src/mage/cards/u/UrzasMiter.java +++ b/Mage.Sets/src/mage/cards/u/UrzasMiter.java @@ -61,9 +61,9 @@ class UrzasMiterDoIfCostPaid extends DoIfCostPaid { @Override public boolean apply(Game game, Ability source) { UrzasMiterWatcher watcher = (UrzasMiterWatcher) game.getState().getWatchers().get(UrzasMiterWatcher.class.getSimpleName()); - if(!watcher.cards.contains(source.getFirstTarget())) + if(watcher != null && !watcher.cards.contains(source.getFirstTarget())) { return super.apply(game, source); - + } return false; } diff --git a/Mage.Sets/src/mage/cards/w/WarElemental.java b/Mage.Sets/src/mage/cards/w/WarElemental.java index fd2aa63c26..ff55ba6e77 100644 --- a/Mage.Sets/src/mage/cards/w/WarElemental.java +++ b/Mage.Sets/src/mage/cards/w/WarElemental.java @@ -117,7 +117,7 @@ class OpponentWasDealtDamageCondition implements Condition { @Override public boolean apply(Game game, Ability source) { BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); - return watcher.conditionMet(); + return watcher != null && watcher.conditionMet(); } @Override diff --git a/Mage.Sets/src/mage/cards/w/WoundReflection.java b/Mage.Sets/src/mage/cards/w/WoundReflection.java index 156d16384c..408a349715 100644 --- a/Mage.Sets/src/mage/cards/w/WoundReflection.java +++ b/Mage.Sets/src/mage/cards/w/WoundReflection.java @@ -62,7 +62,7 @@ class WoundReflectionEffect extends OneShotEffect { for (UUID playerId : game.getOpponents(controller.getId())) { Player opponent = game.getPlayer(playerId); if (opponent != null) { - int lifeLost = watcher.getLiveLost(playerId); + int lifeLost = watcher.getLifeLost(playerId); if (lifeLost > 0) { opponent.loseLife(lifeLost, game, false); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/AttackedThisTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/AttackedThisTurnCondition.java index 6341d527a8..ccd336f20a 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/AttackedThisTurnCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/AttackedThisTurnCondition.java @@ -20,6 +20,6 @@ public enum AttackedThisTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); - return !watcher.getAttackedThisTurnCreatures().isEmpty(); + return watcher != null && !watcher.getAttackedThisTurnCreatures().isEmpty(); } } diff --git a/Mage/src/main/java/mage/abilities/condition/common/LiveLostLastTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/LiveLostLastTurnCondition.java index 9832cc9109..1dcaaea74f 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/LiveLostLastTurnCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/LiveLostLastTurnCondition.java @@ -19,7 +19,7 @@ public enum LiveLostLastTurnCondition implements Condition { public boolean apply(Game game, Ability source) { PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); if (watcher != null) { - return watcher.getLiveLostLastTurn(source.getControllerId()) > 0; + return watcher.getLifeLostLastTurn(source.getControllerId()) > 0; } else { WatcherUtils.logMissingWatcher(game, source, PlayerLostLifeWatcher.class, this.getClass()); } diff --git a/Mage/src/main/java/mage/abilities/condition/common/MorbidCondition.java b/Mage/src/main/java/mage/abilities/condition/common/MorbidCondition.java index d095c2b0f5..b127435975 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/MorbidCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/MorbidCondition.java @@ -17,7 +17,7 @@ public enum MorbidCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName()); - return watcher.conditionMet(); + return watcher != null && watcher.conditionMet(); } @Override diff --git a/Mage/src/main/java/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java index c43f09ba86..72dc12c321 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/NoSpellsWereCastLastTurnCondition.java @@ -24,6 +24,9 @@ public enum NoSpellsWereCastLastTurnCondition implements Condition { } CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + if(watcher == null){ + return false; + } // if any player cast spell, return false for (Integer count : watcher.getAmountOfSpellsCastOnPrevTurn().values()) { if (count > 0) { diff --git a/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java b/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java index 75e9107f57..03c5e6c839 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/OpponentLostLifeCondition.java @@ -26,7 +26,7 @@ public class OpponentLostLifeCondition extends IntCompareCondition { 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); + int lostLive = watcher.getLifeLost(opponentId); if (lostLive > maxLostLive) { maxLostLive = lostLive; } diff --git a/Mage/src/main/java/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java b/Mage/src/main/java/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java index 01f3decbd0..498dc96ed1 100644 --- a/Mage/src/main/java/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java +++ b/Mage/src/main/java/mage/abilities/condition/common/TwoOrMoreSpellsWereCastLastTurnCondition.java @@ -16,6 +16,9 @@ public enum TwoOrMoreSpellsWereCastLastTurnCondition implements Condition { @Override public boolean apply(Game game, Ability source) { CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); + if(watcher == null){ + return false; + } // if any player cast more than two spells, return true for (Integer count : watcher.getAmountOfSpellsCastOnPrevTurn().values()) { if (count >= 2) { diff --git a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ZuberasDiedDynamicValue.java b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ZuberasDiedDynamicValue.java index 85a86a8375..c6dc8094ff 100644 --- a/Mage/src/main/java/mage/abilities/dynamicvalue/common/ZuberasDiedDynamicValue.java +++ b/Mage/src/main/java/mage/abilities/dynamicvalue/common/ZuberasDiedDynamicValue.java @@ -14,7 +14,10 @@ public class ZuberasDiedDynamicValue implements DynamicValue { @Override public int calculate(Game game, Ability sourceAbility, Effect effect) { ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get(ZuberasDiedWatcher.class.getSimpleName()); - return watcher.zuberasDiedThisTurn; + if(watcher == null){ + return 0; + } + return watcher.zuberasDiedThisTurn; } @Override diff --git a/Mage/src/main/java/mage/abilities/keyword/GravestormAbility.java b/Mage/src/main/java/mage/abilities/keyword/GravestormAbility.java index 01eb83de3b..7783f32d9d 100644 --- a/Mage/src/main/java/mage/abilities/keyword/GravestormAbility.java +++ b/Mage/src/main/java/mage/abilities/keyword/GravestormAbility.java @@ -75,19 +75,21 @@ class GravestormEffect extends OneShotEffect { MageObjectReference spellRef = (MageObjectReference) this.getValue("GravestormSpellRef"); if (spellRef != null) { GravestormWatcher watcher = (GravestormWatcher) game.getState().getWatchers().get(GravestormWatcher.class.getSimpleName()); - int gravestormCount = watcher.getGravestormCount(); - if (gravestormCount > 0) { - Spell spell = (Spell) this.getValue("GravestormSpell"); - if (spell != null) { - if (!game.isSimulation()) { - game.informPlayers("Gravestorm: " + spell.getName() + " will be copied " + gravestormCount + " time" + (gravestormCount > 1 ? "s" : "")); - } - for (int i = 0; i < gravestormCount; i++) { - spell.createCopyOnStack(game, source, source.getControllerId(), true); + if(watcher != null) { + int gravestormCount = watcher.getGravestormCount(); + if (gravestormCount > 0) { + Spell spell = (Spell) this.getValue("GravestormSpell"); + if (spell != null) { + if (!game.isSimulation()) { + game.informPlayers("Gravestorm: " + spell.getName() + " will be copied " + gravestormCount + " time" + (gravestormCount > 1 ? "s" : "")); + } + for (int i = 0; i < gravestormCount; i++) { + spell.createCopyOnStack(game, source, source.getControllerId(), true); + } } } + return true; } - return true; } return false; } diff --git a/Mage/src/main/java/mage/watchers/common/PlayerLostLifeWatcher.java b/Mage/src/main/java/mage/watchers/common/PlayerLostLifeWatcher.java index bcc4182fd9..70c389b01d 100644 --- a/Mage/src/main/java/mage/watchers/common/PlayerLostLifeWatcher.java +++ b/Mage/src/main/java/mage/watchers/common/PlayerLostLifeWatcher.java @@ -49,7 +49,7 @@ public class PlayerLostLifeWatcher extends Watcher { } } - public int getLiveLost(UUID playerId) { + public int getLifeLost(UUID playerId) { return amountOfLifeLostThisTurn.getOrDefault(playerId, 0); } @@ -64,7 +64,7 @@ public class PlayerLostLifeWatcher extends Watcher { return amount; } - public int getLiveLostLastTurn(UUID playerId) { + public int getLifeLostLastTurn(UUID playerId) { return amountOfLifeLostLastTurn.getOrDefault(playerId, 0); }