add nullchecks on watchers

This commit is contained in:
Ingmar Goudt 2019-01-06 00:35:15 +01:00
parent 5cab28182d
commit 95a31759b5
53 changed files with 134 additions and 85 deletions

View file

@ -51,8 +51,11 @@ class AetherfluxReservoirDynamicValue implements DynamicValue {
@Override @Override
public int calculate(Game game, Ability sourceAbility, Effect effect) { public int calculate(Game game, Ability sourceAbility, Effect effect) {
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
if(watcher != null) {
return watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(sourceAbility.getControllerId()); return watcher.getAmountOfSpellsPlayerCastOnCurrentTurn(sourceAbility.getControllerId());
} }
return 0;
}
@Override @Override
public AetherfluxReservoirDynamicValue copy() { public AetherfluxReservoirDynamicValue copy() {

View file

@ -84,7 +84,7 @@ class ArchfiendOfDespairEffect extends OneShotEffect {
for (UUID playerId : game.getOpponents(controller.getId())) { for (UUID playerId : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(playerId); Player opponent = game.getPlayer(playerId);
if (opponent != null) { if (opponent != null) {
int lifeLost = watcher.getLiveLost(playerId); int lifeLost = watcher.getLifeLost(playerId);
if (lifeLost > 0) { if (lifeLost > 0) {
opponent.loseLife(lifeLost, game, false); opponent.loseLife(lifeLost, game, false);
} }

View file

@ -2,7 +2,6 @@
package mage.cards.b; package mage.cards.b;
import java.util.UUID;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -17,8 +16,9 @@ import mage.game.Game;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.watchers.common.BloodthirstWatcher; import mage.watchers.common.BloodthirstWatcher;
import java.util.UUID;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
* @author North * @author North
*/ */
@ -70,7 +70,7 @@ class BloodcrazedGoblinEffect extends RestrictionEffect {
public boolean applies(Permanent permanent, Ability source, Game game) { public boolean applies(Permanent permanent, Ability source, Game game) {
if (permanent.getId().equals(source.getSourceId())) { if (permanent.getId().equals(source.getSourceId())) {
BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); // BloodthirstWatcher BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); // BloodthirstWatcher
return !watcher.conditionMet(); return watcher != null && !watcher.conditionMet();
} }
return false; return false;
} }

View file

@ -54,7 +54,7 @@ class BrimstoneVolleyEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
int damage = 3; int damage = 3;
Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName()); Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName());
if (watcher.conditionMet()) { if (watcher != null && watcher.conditionMet()) {
damage = 5; damage = 5;
} }
Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source)); Permanent permanent = game.getPermanent(targetPointer.getFirst(game, source));

View file

@ -156,6 +156,9 @@ class BrutalHordechiefChooseBlockersEffect extends ContinuousRuleModifyingEffect
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName());
if(watcher == null){
return false;
}
watcher.decrement(); watcher.decrement();
if (watcher.copyCountApply > 0) { if (watcher.copyCountApply > 0) {
game.informPlayers(source.getSourceObject(game).getIdName() + " didn't apply"); game.informPlayers(source.getSourceObject(game).getIdName() + " didn't apply");

View file

@ -54,7 +54,7 @@ class SourceControllerLostLifeCount implements DynamicValue {
public int calculate(Game game, Ability sourceAbility, Effect effect) { public int calculate(Game game, Ability sourceAbility, Effect effect) {
PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName());
if (watcher != null) { if (watcher != null) {
return watcher.getLiveLost(sourceAbility.getControllerId()); return watcher.getLifeLost(sourceAbility.getControllerId());
} }
return 0; return 0;
} }

View file

@ -75,6 +75,9 @@ class NoMoreThanOneCreatureCanAttackEachTurnEffect extends RestrictionEffect {
return false; return false;
} }
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
if(watcher == null){
return false;
}
Set<MageObjectReference> attackedThisTurnCreatures = watcher.getAttackedThisTurnCreatures(); Set<MageObjectReference> attackedThisTurnCreatures = watcher.getAttackedThisTurnCreatures();
return attackedThisTurnCreatures.isEmpty() return attackedThisTurnCreatures.isEmpty()
|| (attackedThisTurnCreatures.size() == 1 && attackedThisTurnCreatures.contains(new MageObjectReference(attacker, game))); || (attackedThisTurnCreatures.size() == 1 && attackedThisTurnCreatures.contains(new MageObjectReference(attacker, game)));
@ -109,6 +112,9 @@ class NoMoreThanOneCreatureCanBlockEachTurnEffect extends RestrictionEffect {
return false; return false;
} }
BlockedThisTurnWatcher watcher = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName()); BlockedThisTurnWatcher watcher = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName());
if(watcher == null){
return false;
}
Set<MageObjectReference> blockedThisTurnCreatures = watcher.getBlockedThisTurnCreatures(); Set<MageObjectReference> blockedThisTurnCreatures = watcher.getBlockedThisTurnCreatures();
MageObjectReference blockerReference = new MageObjectReference(blocker.getId(), blocker.getZoneChangeCounter(game), game); MageObjectReference blockerReference = new MageObjectReference(blocker.getId(), blocker.getZoneChangeCounter(game), game);
return blockedThisTurnCreatures.isEmpty() return blockedThisTurnCreatures.isEmpty()

View file

@ -57,6 +57,6 @@ class ErgRaidersCondition implements Condition {
Permanent raiders = game.getPermanentOrLKIBattlefield(source.getSourceId()); Permanent raiders = game.getPermanentOrLKIBattlefield(source.getSourceId());
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
// wasControlledFromStartOfControllerTurn should be checked during resolution I guess, but shouldn't be relevant // 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));
} }
} }

View file

@ -57,7 +57,7 @@ enum FeastOnTheFallenCondition implements Condition {
PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName());
if (watcher != null) { if (watcher != null) {
for (UUID opponentId : game.getOpponents(source.getControllerId())) { for (UUID opponentId : game.getOpponents(source.getControllerId())) {
if (watcher.getLiveLostLastTurn(opponentId) > 0) { if (watcher.getLifeLostLastTurn(opponentId) > 0) {
return true; return true;
} }
} }

View file

@ -51,6 +51,6 @@ class SourceWasBlockedThisTurnCondition implements Condition {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId());
WasBlockedThisTurnWatcher watcher = (WasBlockedThisTurnWatcher) game.getState().getWatchers().get(WasBlockedThisTurnWatcher.class.getSimpleName()); 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));
} }
} }

View file

@ -121,7 +121,7 @@ class GisaAndGeralfCastFromGraveyardEffect extends AsThoughEffectImpl {
if (objectId.equals(getTargetPointer().getFirst(game, source))) { if (objectId.equals(getTargetPointer().getFirst(game, source))) {
if (affectedControllerId.equals(source.getControllerId())) { if (affectedControllerId.equals(source.getControllerId())) {
GisaAndGeralfWatcher watcher = (GisaAndGeralfWatcher) game.getState().getWatchers().get(GisaAndGeralfWatcher.class.getSimpleName(), source.getSourceId()); GisaAndGeralfWatcher watcher = (GisaAndGeralfWatcher) game.getState().getWatchers().get(GisaAndGeralfWatcher.class.getSimpleName(), source.getSourceId());
return !watcher.isAbilityUsed(); return watcher != null && !watcher.isAbilityUsed();
} }
} }
return false; return false;
@ -145,7 +145,7 @@ class GisaAndGeralfWatcher extends Watcher {
public void watch(GameEvent event, Game game) { public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.GRAVEYARD) { if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getZone() == Zone.GRAVEYARD) {
Spell spell = (Spell) game.getObject(event.getTargetId()); 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; abilityUsed = true;
} }
} }

View file

@ -68,6 +68,7 @@ class HeatStrokeEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
BlockedThisTurnWatcher blockedWatcher = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName()); BlockedThisTurnWatcher blockedWatcher = (BlockedThisTurnWatcher) game.getState().getWatchers().get(BlockedThisTurnWatcher.class.getSimpleName());
WasBlockedThisTurnWatcher wasBlockedThisTurnWatcher = (WasBlockedThisTurnWatcher) game.getState().getWatchers().get(WasBlockedThisTurnWatcher.class.getSimpleName()); WasBlockedThisTurnWatcher wasBlockedThisTurnWatcher = (WasBlockedThisTurnWatcher) game.getState().getWatchers().get(WasBlockedThisTurnWatcher.class.getSimpleName());
Set<Permanent> inROI = new HashSet<>(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game)); Set<Permanent> inROI = new HashSet<>(game.getBattlefield().getActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, source.getControllerId(), source.getSourceId(), game));
boolean toRet = false; boolean toRet = false;
Set<MageObjectReference> toDestroy = new HashSet<>(); Set<MageObjectReference> toDestroy = new HashSet<>();

View file

@ -68,7 +68,7 @@ class HuntDownEffect extends RequirementEffect {
Permanent blocker = game.getPermanent(source.getTargets().get(0).getFirstTarget()); Permanent blocker = game.getPermanent(source.getTargets().get(0).getFirstTarget());
if (blocker != null if (blocker != null
&& blocker.canBlock(source.getTargets().get(1).getFirstTarget(), game)) { && 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) { if (attacker != null) {
BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName());
if (blockedAttackerWatcher != null if (blockedAttackerWatcher != null

View file

@ -47,7 +47,7 @@ class ImpatienceCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); 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() { public String toString() {

View file

@ -151,7 +151,7 @@ class KaradorGhostChieftainCastFromGraveyardEffect extends AsThoughEffectImpl {
if (objectId.equals(getTargetPointer().getFirst(game, source))) { if (objectId.equals(getTargetPointer().getFirst(game, source))) {
if (affectedControllerId.equals(source.getControllerId())) { if (affectedControllerId.equals(source.getControllerId())) {
KaradorGhostChieftainWatcher watcher = (KaradorGhostChieftainWatcher) game.getState().getWatchers().get(KaradorGhostChieftainWatcher.class.getSimpleName(), source.getSourceId()); KaradorGhostChieftainWatcher watcher = (KaradorGhostChieftainWatcher) game.getState().getWatchers().get(KaradorGhostChieftainWatcher.class.getSimpleName(), source.getSourceId());
return !watcher.isAbilityUsed(); return watcher != null && !watcher.isAbilityUsed();
} }
} }
return false; return false;

View file

@ -94,7 +94,7 @@ class KessDissidentMageCastFromGraveyardEffect extends AsThoughEffectImpl {
&& game.getState().getZone(objectId).equals(Zone.GRAVEYARD)) { && game.getState().getZone(objectId).equals(Zone.GRAVEYARD)) {
// check if not already a card was cast this turn with this ability // check if not already a card was cast this turn with this ability
KessDissidentMageWatcher watcher = (KessDissidentMageWatcher) game.getState().getWatchers().get(KessDissidentMageWatcher.class.getSimpleName()); 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; return false;
@ -138,7 +138,7 @@ class KessDissidentMageReplacementEffect extends ReplacementEffectImpl {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event; ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getToZone() == Zone.GRAVEYARD) { if (zEvent.getToZone() == Zone.GRAVEYARD) {
KessDissidentMageWatcher watcher = (KessDissidentMageWatcher) game.getState().getWatchers().get(KessDissidentMageWatcher.class.getSimpleName()); 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; return true;
} }
} }

View file

@ -116,7 +116,6 @@ enum KrovikanVampireInterveningIfCondition implements Condition {
KrovikanVampireCreaturesDamagedWatcher watcherDamaged = (KrovikanVampireCreaturesDamagedWatcher) game.getState().getWatchers().get(KrovikanVampireCreaturesDamagedWatcher.class.getSimpleName()); KrovikanVampireCreaturesDamagedWatcher watcherDamaged = (KrovikanVampireCreaturesDamagedWatcher) game.getState().getWatchers().get(KrovikanVampireCreaturesDamagedWatcher.class.getSimpleName());
if (watcherDied != null) { if (watcherDied != null) {
Set<UUID> creaturesThatDiedThisTurn = watcherDied.diedThisTurn; Set<UUID> creaturesThatDiedThisTurn = watcherDied.diedThisTurn;
if (creaturesThatDiedThisTurn != null) {
for (UUID mor : creaturesThatDiedThisTurn) { for (UUID mor : creaturesThatDiedThisTurn) {
if (watcherDamaged != null) { if (watcherDamaged != null) {
for (UUID mor2 : watcherDamaged.getDamagedBySource()) { for (UUID mor2 : watcherDamaged.getDamagedBySource()) {
@ -133,7 +132,6 @@ enum KrovikanVampireInterveningIfCondition implements Condition {
return true; return true;
} }
} }
}
return false; return false;
} }

View file

@ -58,8 +58,11 @@ class CardsDrawnThisTurnDynamicValue implements DynamicValue {
@Override @Override
public int calculate(Game game, Ability sourceAbility, Effect effect) { public int calculate(Game game, Ability sourceAbility, Effect effect) {
KydeleCardsDrawnThisTurnWatcher watcher = (KydeleCardsDrawnThisTurnWatcher) game.getState().getWatchers().get(KydeleCardsDrawnThisTurnWatcher.class.getSimpleName()); KydeleCardsDrawnThisTurnWatcher watcher = (KydeleCardsDrawnThisTurnWatcher) game.getState().getWatchers().get(KydeleCardsDrawnThisTurnWatcher.class.getSimpleName());
if(watcher != null) {
return watcher.getCardsDrawnThisTurn(sourceAbility.getControllerId()); return watcher.getCardsDrawnThisTurn(sourceAbility.getControllerId());
} }
return 0;
}
@Override @Override
public CardsDrawnThisTurnDynamicValue copy() { public CardsDrawnThisTurnDynamicValue copy() {

View file

@ -65,7 +65,7 @@ class LudevicNecroAlchemistCondition implements Condition {
currentPlayer = playerList.getNext(game); currentPlayer = playerList.getNext(game);
while (watcher != null && currentPlayer != null) { 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; return true;
} }
if (Objects.equals(currentPlayer, firstPlayer)) { if (Objects.equals(currentPlayer, firstPlayer)) {

View file

@ -121,7 +121,7 @@ enum YouLostNoLifeThisTurnCondition implements Condition {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName());
if (watcher != null) { if (watcher != null) {
return (watcher.getLiveLost(source.getControllerId()) == 0); return (watcher.getLifeLost(source.getControllerId()) == 0);
} }
return false; return false;
} }

View file

@ -65,11 +65,11 @@ enum MadDogCondition implements Condition {
&& madDog != null) { && madDog != null) {
// For some reason, compare did not work when checking the lists. Thus the interation. // For some reason, compare did not work when checking the lists. Thus the interation.
List<Permanent> permanents = watcher.getThisTurnEnteringPermanents(source.getControllerId()); List<Permanent> 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; return false;
} }
Set<MageObjectReference> mor = watcher2.getAttackedThisTurnCreatures(); Set<MageObjectReference> 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 false;
} }
return true; // Mad Dog did not come into play this turn nor did he attack this turn. Sacrifice the hound. return true; // Mad Dog did not come into play this turn nor did he attack this turn. Sacrifice the hound.

View file

@ -79,6 +79,9 @@ class MagusOfTheMindEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game); MageObject sourceObject = source.getSourceObject(game);
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
if(watcher == null){
return false;
}
int stormCount = watcher.getAmountOfSpellsAllPlayersCastOnCurrentTurn() + 1; int stormCount = watcher.getAmountOfSpellsAllPlayersCastOnCurrentTurn() + 1;
if (controller != null && sourceObject != null) { if (controller != null && sourceObject != null) {
controller.shuffleLibrary(source, game); controller.shuffleLibrary(source, game);

View file

@ -154,6 +154,9 @@ class MasterWarcraftChooseAttackersEffect extends ContinuousRuleModifyingEffectI
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
MasterWarcraftCastWatcher watcher = (MasterWarcraftCastWatcher) game.getState().getWatchers().get(MasterWarcraftCastWatcher.class.getSimpleName()); MasterWarcraftCastWatcher watcher = (MasterWarcraftCastWatcher) game.getState().getWatchers().get(MasterWarcraftCastWatcher.class.getSimpleName());
if(watcher == null){
return false;
}
watcher.decrement(); watcher.decrement();
if (watcher.copyCountApply > 0) { if (watcher.copyCountApply > 0) {
game.informPlayers(source.getSourceObject(game).getIdName() + " didn't apply"); game.informPlayers(source.getSourceObject(game).getIdName() + " didn't apply");
@ -227,6 +230,9 @@ class MasterWarcraftChooseBlockersEffect extends ContinuousRuleModifyingEffectIm
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName());
if(watcher == null){
return false;
}
watcher.decrement(); watcher.decrement();
if (watcher.copyCountApply > 0) { if (watcher.copyCountApply > 0) {
game.informPlayers(source.getSourceObject(game).getIdName() + " didn't apply"); game.informPlayers(source.getSourceObject(game).getIdName() + " didn't apply");

View file

@ -1,7 +1,6 @@
package mage.cards.m; package mage.cards.m;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.DelayedTriggeredAbility; import mage.abilities.DelayedTriggeredAbility;
import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility; import mage.abilities.common.CastOnlyDuringPhaseStepSourceAbility;
@ -17,19 +16,21 @@ import mage.abilities.effects.common.RemoveFromCombatTargetEffect;
import mage.abilities.effects.common.UntapTargetEffect; import mage.abilities.effects.common.UntapTargetEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; 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.Game;
import mage.game.combat.CombatGroup; import mage.game.combat.CombatGroup;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import mage.watchers.Watcher;
import mage.watchers.common.ChooseBlockersRedundancyWatcher; import mage.watchers.common.ChooseBlockersRedundancyWatcher;
import java.util.UUID;
/** /**
*
* @author L_J * @author L_J
*/ */
public final class Melee extends CardImpl { public final class Melee extends CardImpl {
@ -118,6 +119,9 @@ class MeleeChooseBlockersEffect extends ContinuousRuleModifyingEffectImpl {
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName());
if (watcher == null) {
return false;
}
watcher.decrement(); watcher.decrement();
watcher.copyCount--; watcher.copyCount--;
if (watcher.copyCountApply > 0) { if (watcher.copyCountApply > 0) {

View file

@ -87,7 +87,7 @@ class MoltenPsycheEffect extends OneShotEffect {
for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) {
if (game.isOpponent(controller, playerId)) { if (game.isOpponent(controller, playerId)) {
Player player = game.getPlayer(playerId); Player player = game.getPlayer(playerId);
if (player != null) { if (player != null && watcher != null) {
player.damage(watcher.getDraws(playerId), source.getSourceId(), game, false, true); player.damage(watcher.getDraws(playerId), source.getSourceId(), game, false, true);
} }
} }

View file

@ -63,7 +63,7 @@ class MultanisPresenceTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
MultanisPresenceWatcher watcher = (MultanisPresenceWatcher) game.getState().getWatchers().get(MultanisPresenceWatcher.class.getSimpleName()); 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 @Override

View file

@ -131,6 +131,9 @@ class OdricMasterTacticianChooseBlockersEffect extends ContinuousRuleModifyingEf
@Override @Override
public boolean applies(GameEvent event, Ability source, Game game) { public boolean applies(GameEvent event, Ability source, Game game) {
ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName()); ChooseBlockersRedundancyWatcher watcher = (ChooseBlockersRedundancyWatcher) game.getState().getWatchers().get(ChooseBlockersRedundancyWatcher.class.getSimpleName());
if(watcher == null){
return false;
}
watcher.decrement(); watcher.decrement();
watcher.copyCount--; watcher.copyCount--;
if (watcher.copyCountApply > 0) { if (watcher.copyCountApply > 0) {

View file

@ -65,10 +65,12 @@ class PowerSurgeDamageEffect extends OneShotEffect {
Player player = game.getPlayer(targetPointer.getFirst(game, source)); Player player = game.getPlayer(targetPointer.getFirst(game, source));
if (player != null) { if (player != null) {
PowerSurgeWatcher watcher = (PowerSurgeWatcher) game.getState().getWatchers().get(PowerSurgeWatcher.class.getSimpleName()); PowerSurgeWatcher watcher = (PowerSurgeWatcher) game.getState().getWatchers().get(PowerSurgeWatcher.class.getSimpleName());
if(watcher != null) {
int damage = watcher.getUntappedLandCount(); int damage = watcher.getUntappedLandCount();
player.damage(damage, source.getSourceId(), game, false, true); player.damage(damage, source.getSourceId(), game, false, true);
return true; return true;
} }
}
return false; return false;
} }

View file

@ -83,7 +83,7 @@ class ETBSinceYourLastTurnTarget extends TargetCreaturePermanent {
if(targetSource != null) { if(targetSource != null) {
for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) { for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, sourceControllerId, sourceId, game)) {
if (permanent.canBeTargetedBy(targetSource, sourceControllerId, 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; return true;
} }
} }

View file

@ -82,7 +82,7 @@ class ReaperFromTheAbyssAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName()); Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName());
return watcher.conditionMet(); return watcher != null && watcher.conditionMet();
} }
@Override @Override

View file

@ -65,7 +65,7 @@ enum LostLifeCondition implements Condition {
PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName());
UUID player = source.getControllerId(); UUID player = source.getControllerId();
if (watcher != null && player != null) { if (watcher != null && player != null) {
return watcher.getLiveLost(player) > 0; return watcher.getLifeLost(player) > 0;
} }
return false; return false;
} }

View file

@ -87,7 +87,7 @@ class RimehornAurochsEffect extends RequirementEffect {
Permanent blocker = game.getPermanent(source.getTargets().get(0).getFirstTarget()); Permanent blocker = game.getPermanent(source.getTargets().get(0).getFirstTarget());
if (blocker != null if (blocker != null
&& blocker.canBlock(source.getTargets().get(1).getFirstTarget(), game)) { && 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) { if (attacker != null) {
BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName()); BlockedAttackerWatcher blockedAttackerWatcher = (BlockedAttackerWatcher) game.getState().getWatchers().get(BlockedAttackerWatcher.class.getSimpleName());
if (blockedAttackerWatcher != null if (blockedAttackerWatcher != null

View file

@ -74,7 +74,7 @@ class PlayerLostLifePredicate implements Predicate<Player> {
public boolean apply(Player input, Game game) { public boolean apply(Player input, Game game) {
PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName());
if (watcher != null) { if (watcher != null) {
return (0 < watcher.getLiveLost(input.getId())); return (0 < watcher.getLifeLost(input.getId()));
} }
return false; return false;
} }

View file

@ -99,7 +99,7 @@ enum ControlledTurnCondition implements Condition {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
RocketLauncherWatcher watcher = (RocketLauncherWatcher) game.getState().getWatchers().get(RocketLauncherWatcher.class.getSimpleName()); RocketLauncherWatcher watcher = (RocketLauncherWatcher) game.getState().getWatchers().get(RocketLauncherWatcher.class.getSimpleName());
return !watcher.changedControllerOR1stTurn; return watcher != null && !watcher.changedControllerOR1stTurn;
} }
@Override @Override

View file

@ -51,7 +51,7 @@ class SecondSpellPredicate implements Predicate<StackObject> {
public boolean apply(StackObject input, Game game) { public boolean apply(StackObject input, Game game) {
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); 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; return true;
} }

View file

@ -49,8 +49,11 @@ class SilentChantZuberaDynamicValue implements DynamicValue {
@Override @Override
public int calculate(Game game, Ability sourceAbility, Effect effect) { public int calculate(Game game, Ability sourceAbility, Effect effect) {
ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get(ZuberasDiedWatcher.class.getSimpleName()); ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get(ZuberasDiedWatcher.class.getSimpleName());
if(watcher != null) {
return watcher.zuberasDiedThisTurn * 2; return watcher.zuberasDiedThisTurn * 2;
} }
return 0;
}
@Override @Override
public SilentChantZuberaDynamicValue copy() { public SilentChantZuberaDynamicValue copy() {

View file

@ -62,7 +62,7 @@ class OpponentWasDealtDamageCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId());
return watcher.conditionMet(); return watcher != null && watcher.conditionMet();
} }
@Override @Override

View file

@ -55,8 +55,11 @@ class OtherSpellsCastThisTurnCount implements DynamicValue {
@Override @Override
public int calculate(Game game, Ability sourceAbility, Effect effect) { public int calculate(Game game, Ability sourceAbility, Effect effect) {
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
if(watcher != null ) {
return watcher.getAmountOfSpellsAllPlayersCastOnCurrentTurn() - 1; return watcher.getAmountOfSpellsAllPlayersCastOnCurrentTurn() - 1;
} }
return 0;
}
@Override @Override
public DynamicValue copy() { public DynamicValue copy() {

View file

@ -60,7 +60,7 @@ class AllPlayersLostLifeCount implements DynamicValue {
if (watcher != null) { if (watcher != null) {
int amountLifeLost = 0; int amountLifeLost = 0;
for (UUID playerId : game.getState().getPlayersInRange(controllerId, game)) { for (UUID playerId : game.getState().getPlayersInRange(controllerId, game)) {
amountLifeLost += watcher.getLiveLost(playerId); amountLifeLost += watcher.getLifeLost(playerId);
} }
return amountLifeLost; return amountLifeLost;
} }

View file

@ -73,7 +73,7 @@ class EquippedDealtCombatDamageToCreatureCondition implements Condition {
if (equipment != null && equipment.getAttachedTo() != null) { if (equipment != null && equipment.getAttachedTo() != null) {
CombatDamageToCreatureWatcher watcher = CombatDamageToCreatureWatcher watcher =
(CombatDamageToCreatureWatcher) game.getState().getWatchers().get(CombatDamageToCreatureWatcher.BASIC_KEY); (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; return false;
} }

View file

@ -98,7 +98,7 @@ class TuvasaTheSunlitTriggeredAbility extends SpellCastControllerTriggeredAbilit
TuvasaTheSunlitWatcher watcher = (TuvasaTheSunlitWatcher) game.getState().getWatchers().get( TuvasaTheSunlitWatcher watcher = (TuvasaTheSunlitWatcher) game.getState().getWatchers().get(
TuvasaTheSunlitWatcher.class.getSimpleName() TuvasaTheSunlitWatcher.class.getSimpleName()
); );
return event.getTargetId().equals(watcher.getFirstEnchantmentThisTurn(this.getControllerId())); return watcher != null && event.getTargetId().equals(watcher.getFirstEnchantmentThisTurn(this.getControllerId()));
} }
return false; return false;
} }

View file

@ -61,9 +61,9 @@ class UrzasMiterDoIfCostPaid extends DoIfCostPaid {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
UrzasMiterWatcher watcher = (UrzasMiterWatcher) game.getState().getWatchers().get(UrzasMiterWatcher.class.getSimpleName()); 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 super.apply(game, source);
}
return false; return false;
} }

View file

@ -117,7 +117,7 @@ class OpponentWasDealtDamageCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId()); BloodthirstWatcher watcher = (BloodthirstWatcher) game.getState().getWatchers().get(BloodthirstWatcher.class.getSimpleName(), source.getControllerId());
return watcher.conditionMet(); return watcher != null && watcher.conditionMet();
} }
@Override @Override

View file

@ -62,7 +62,7 @@ class WoundReflectionEffect extends OneShotEffect {
for (UUID playerId : game.getOpponents(controller.getId())) { for (UUID playerId : game.getOpponents(controller.getId())) {
Player opponent = game.getPlayer(playerId); Player opponent = game.getPlayer(playerId);
if (opponent != null) { if (opponent != null) {
int lifeLost = watcher.getLiveLost(playerId); int lifeLost = watcher.getLifeLost(playerId);
if (lifeLost > 0) { if (lifeLost > 0) {
opponent.loseLife(lifeLost, game, false); opponent.loseLife(lifeLost, game, false);
} }

View file

@ -20,6 +20,6 @@ public enum AttackedThisTurnCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName()); AttackedThisTurnWatcher watcher = (AttackedThisTurnWatcher) game.getState().getWatchers().get(AttackedThisTurnWatcher.class.getSimpleName());
return !watcher.getAttackedThisTurnCreatures().isEmpty(); return watcher != null && !watcher.getAttackedThisTurnCreatures().isEmpty();
} }
} }

View file

@ -19,7 +19,7 @@ public enum LiveLostLastTurnCondition implements Condition {
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName());
if (watcher != null) { if (watcher != null) {
return watcher.getLiveLostLastTurn(source.getControllerId()) > 0; return watcher.getLifeLostLastTurn(source.getControllerId()) > 0;
} else { } else {
WatcherUtils.logMissingWatcher(game, source, PlayerLostLifeWatcher.class, this.getClass()); WatcherUtils.logMissingWatcher(game, source, PlayerLostLifeWatcher.class, this.getClass());
} }

View file

@ -17,7 +17,7 @@ public enum MorbidCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName()); Watcher watcher = game.getState().getWatchers().get(MorbidWatcher.class.getSimpleName());
return watcher.conditionMet(); return watcher != null && watcher.conditionMet();
} }
@Override @Override

View file

@ -24,6 +24,9 @@ public enum NoSpellsWereCastLastTurnCondition implements Condition {
} }
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName());
if(watcher == null){
return false;
}
// if any player cast spell, return false // if any player cast spell, return false
for (Integer count : watcher.getAmountOfSpellsCastOnPrevTurn().values()) { for (Integer count : watcher.getAmountOfSpellsCastOnPrevTurn().values()) {
if (count > 0) { if (count > 0) {

View file

@ -26,7 +26,7 @@ public class OpponentLostLifeCondition extends IntCompareCondition {
PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName()); PlayerLostLifeWatcher watcher = (PlayerLostLifeWatcher) game.getState().getWatchers().get(PlayerLostLifeWatcher.class.getSimpleName());
if (watcher != null) { if (watcher != null) {
for (UUID opponentId : game.getOpponents(source.getControllerId())) { for (UUID opponentId : game.getOpponents(source.getControllerId())) {
int lostLive = watcher.getLiveLost(opponentId); int lostLive = watcher.getLifeLost(opponentId);
if (lostLive > maxLostLive) { if (lostLive > maxLostLive) {
maxLostLive = lostLive; maxLostLive = lostLive;
} }

View file

@ -16,6 +16,9 @@ public enum TwoOrMoreSpellsWereCastLastTurnCondition implements Condition {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); 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 // if any player cast more than two spells, return true
for (Integer count : watcher.getAmountOfSpellsCastOnPrevTurn().values()) { for (Integer count : watcher.getAmountOfSpellsCastOnPrevTurn().values()) {
if (count >= 2) { if (count >= 2) {

View file

@ -14,6 +14,9 @@ public class ZuberasDiedDynamicValue implements DynamicValue {
@Override @Override
public int calculate(Game game, Ability sourceAbility, Effect effect) { public int calculate(Game game, Ability sourceAbility, Effect effect) {
ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get(ZuberasDiedWatcher.class.getSimpleName()); ZuberasDiedWatcher watcher = (ZuberasDiedWatcher) game.getState().getWatchers().get(ZuberasDiedWatcher.class.getSimpleName());
if(watcher == null){
return 0;
}
return watcher.zuberasDiedThisTurn; return watcher.zuberasDiedThisTurn;
} }

View file

@ -75,6 +75,7 @@ class GravestormEffect extends OneShotEffect {
MageObjectReference spellRef = (MageObjectReference) this.getValue("GravestormSpellRef"); MageObjectReference spellRef = (MageObjectReference) this.getValue("GravestormSpellRef");
if (spellRef != null) { if (spellRef != null) {
GravestormWatcher watcher = (GravestormWatcher) game.getState().getWatchers().get(GravestormWatcher.class.getSimpleName()); GravestormWatcher watcher = (GravestormWatcher) game.getState().getWatchers().get(GravestormWatcher.class.getSimpleName());
if(watcher != null) {
int gravestormCount = watcher.getGravestormCount(); int gravestormCount = watcher.getGravestormCount();
if (gravestormCount > 0) { if (gravestormCount > 0) {
Spell spell = (Spell) this.getValue("GravestormSpell"); Spell spell = (Spell) this.getValue("GravestormSpell");
@ -89,6 +90,7 @@ class GravestormEffect extends OneShotEffect {
} }
return true; return true;
} }
}
return false; return false;
} }

View file

@ -49,7 +49,7 @@ public class PlayerLostLifeWatcher extends Watcher {
} }
} }
public int getLiveLost(UUID playerId) { public int getLifeLost(UUID playerId) {
return amountOfLifeLostThisTurn.getOrDefault(playerId, 0); return amountOfLifeLostThisTurn.getOrDefault(playerId, 0);
} }
@ -64,7 +64,7 @@ public class PlayerLostLifeWatcher extends Watcher {
return amount; return amount;
} }
public int getLiveLostLastTurn(UUID playerId) { public int getLifeLostLastTurn(UUID playerId) {
return amountOfLifeLostLastTurn.getOrDefault(playerId, 0); return amountOfLifeLostLastTurn.getOrDefault(playerId, 0);
} }