diff --git a/Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java b/Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java index 81a7e42baf5..cd82afc4ba1 100644 --- a/Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java +++ b/Mage.Sets/src/mage/cards/a/AbandonedSarcophagus.java @@ -120,6 +120,7 @@ class AbandonedSarcophagusReplacementEffect extends ReplacementEffectImpl { AbandonedSarcophagusWatcher watcher = (AbandonedSarcophagusWatcher) game.getState().getWatchers().get(AbandonedSarcophagusWatcher.class.getSimpleName()); Card card = game.getCard(event.getTargetId()); if (card != null + && controller != null && watcher != null && card.isOwnedBy(controller.getId())) { for (Ability ability : card.getAbilities()) { diff --git a/Mage.Sets/src/mage/cards/a/AliveWell.java b/Mage.Sets/src/mage/cards/a/AliveWell.java index 59944246910..523cf73a104 100644 --- a/Mage.Sets/src/mage/cards/a/AliveWell.java +++ b/Mage.Sets/src/mage/cards/a/AliveWell.java @@ -65,8 +65,8 @@ class WellEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - int life = 2 * game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); if (player != null) { + int life = 2 * game.getBattlefield().count(filter, source.getSourceId(), source.getControllerId(), game); player.gainLife(life, game, source); } return true; diff --git a/Mage.Sets/src/mage/cards/a/AncestorDragon.java b/Mage.Sets/src/mage/cards/a/AncestorDragon.java index ffb6f54a8a6..ed0fce26295 100644 --- a/Mage.Sets/src/mage/cards/a/AncestorDragon.java +++ b/Mage.Sets/src/mage/cards/a/AncestorDragon.java @@ -1,6 +1,7 @@ package mage.cards.a; import java.util.UUID; + import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.AttacksWithCreaturesTriggeredAbility; @@ -15,7 +16,6 @@ import mage.game.Game; import mage.players.Player; /** - * * @author TheElk801 */ public final class AncestorDragon extends CardImpl { @@ -46,8 +46,6 @@ public final class AncestorDragon extends CardImpl { class AncestorDragonEffect extends OneShotEffect { - private int attackers; - public AncestorDragonEffect() { super(Outcome.GainLife); staticText = "you gain 1 life for each attacking creature"; @@ -65,10 +63,9 @@ class AncestorDragonEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); - attackers = game.getCombat().getAttackers().size(); if (you != null) { + int attackers = game.getCombat().getAttackers().size(); you.gainLife(attackers, game, source); - attackers = 0; return true; } return false; diff --git a/Mage.Sets/src/mage/cards/a/AngelsTrumpet.java b/Mage.Sets/src/mage/cards/a/AngelsTrumpet.java index 0f415cc4050..2a05d869ffc 100644 --- a/Mage.Sets/src/mage/cards/a/AngelsTrumpet.java +++ b/Mage.Sets/src/mage/cards/a/AngelsTrumpet.java @@ -64,8 +64,8 @@ class AngelsTrumpetTapEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(game.getActivePlayerId()); - int count = 0; if (player != null) { + int count = 0; for (Permanent creature : game.getBattlefield().getAllActivePermanents(StaticFilters.FILTER_PERMANENT_CREATURE, player.getId(), game)) { // Untapped creatures are safe. if (creature.isTapped()) { diff --git a/Mage.Sets/src/mage/cards/a/AssassinsTrophy.java b/Mage.Sets/src/mage/cards/a/AssassinsTrophy.java index 0d3015285ae..45ee06cb1ab 100644 --- a/Mage.Sets/src/mage/cards/a/AssassinsTrophy.java +++ b/Mage.Sets/src/mage/cards/a/AssassinsTrophy.java @@ -1,6 +1,7 @@ package mage.cards.a; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.DestroyTargetEffect; @@ -21,7 +22,6 @@ import mage.target.TargetPermanent; import mage.target.common.TargetCardInLibrary; /** - * * @author TheElk801 */ public final class AssassinsTrophy extends CardImpl { @@ -74,17 +74,19 @@ class AssassinsTrophyEffect extends OneShotEffect { Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); if (permanent != null) { Player controller = game.getPlayer(permanent.getControllerId()); - if (controller.chooseUse(Outcome.PutLandInPlay, "Do you wish to search for a basic land, put it onto the battlefield and then shuffle your library?", source, game)) { - TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND); - if (controller.searchLibrary(target, game)) { - Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); - if (card != null) { - controller.moveCards(card, Zone.BATTLEFIELD, source, game); + if (controller != null) { + if (controller.chooseUse(Outcome.PutLandInPlay, "Do you wish to search for a basic land, put it onto the battlefield and then shuffle your library?", source, game)) { + TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND); + if (controller.searchLibrary(target, game)) { + Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); + if (card != null) { + controller.moveCards(card, Zone.BATTLEFIELD, source, game); + } } + controller.shuffleLibrary(source, game); } - controller.shuffleLibrary(source, game); + return true; } - return true; } return false; } diff --git a/Mage.Sets/src/mage/cards/a/AthreosGodOfPassage.java b/Mage.Sets/src/mage/cards/a/AthreosGodOfPassage.java index 53f6e575df4..fbd70641c0a 100644 --- a/Mage.Sets/src/mage/cards/a/AthreosGodOfPassage.java +++ b/Mage.Sets/src/mage/cards/a/AthreosGodOfPassage.java @@ -99,7 +99,7 @@ class AthreosGodOfPassageReturnEffect extends OneShotEffect { if (opponent != null) { Cost cost = new PayLifeCost(3); if (cost.canPay(source, source.getSourceId(), opponent.getId(), game) - && opponent.chooseUse(outcome, new StringBuilder("Pay 3 live to prevent that ").append(creature.getLogName()).append(" returns to ").append(controller.getLogName()).append("'s hand?").toString(), source, game)) { + && opponent.chooseUse(outcome, "Pay 3 life to prevent that " + creature.getLogName() + " returns to " + controller.getLogName() + "'s hand?", source, game)) { if (cost.pay(source, game, source.getSourceId(), opponent.getId(), false, null)) { paid = true; } diff --git a/Mage.Sets/src/mage/cards/a/AyliEternalPilgrim.java b/Mage.Sets/src/mage/cards/a/AyliEternalPilgrim.java index dd52b588a1d..d552596e349 100644 --- a/Mage.Sets/src/mage/cards/a/AyliEternalPilgrim.java +++ b/Mage.Sets/src/mage/cards/a/AyliEternalPilgrim.java @@ -78,6 +78,9 @@ class AyliEternalPilgrimCondition implements Condition { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - return player.getLife() >= game.getLife() + 10; + if(player != null) { + return player.getLife() >= game.getLife() + 10; + } + return false; } } diff --git a/Mage.Sets/src/mage/cards/b/BarrinsSpite.java b/Mage.Sets/src/mage/cards/b/BarrinsSpite.java index f1a97ff4d05..5eb3a9baf8e 100644 --- a/Mage.Sets/src/mage/cards/b/BarrinsSpite.java +++ b/Mage.Sets/src/mage/cards/b/BarrinsSpite.java @@ -67,16 +67,18 @@ class BarrinsSpiteEffect extends OneShotEffect { Permanent creature = game.getPermanent(targetId); if (creature != null) { Player controllerOfCreature = game.getPlayer(creature.getControllerId()); - if ((count == 0 - && controllerOfCreature.chooseUse(Outcome.Sacrifice, "Sacrifice " + creature.getLogName() + '?', source, game)) - || (count == 1 - && !sacrificeDone)) { - creature.sacrifice(source.getId(), game); - sacrificeDone = true; - } else { - creature.moveToZone(Zone.HAND, source.getId(), game, false); + if(controllerOfCreature != null) { + if ((count == 0 + && controllerOfCreature.chooseUse(Outcome.Sacrifice, "Sacrifice " + creature.getLogName() + '?', source, game)) + || (count == 1 + && !sacrificeDone)) { + creature.sacrifice(source.getId(), game); + sacrificeDone = true; + } else { + creature.moveToZone(Zone.HAND, source.getId(), game, false); + } + count++; } - count++; } } return true; diff --git a/Mage.Sets/src/mage/cards/b/BattletideAlchemist.java b/Mage.Sets/src/mage/cards/b/BattletideAlchemist.java index 5b7a4e94bf6..1c94669e7c7 100644 --- a/Mage.Sets/src/mage/cards/b/BattletideAlchemist.java +++ b/Mage.Sets/src/mage/cards/b/BattletideAlchemist.java @@ -2,6 +2,7 @@ package mage.cards.b; import java.util.UUID; + import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleStaticAbility; @@ -17,13 +18,12 @@ import mage.game.events.GameEvent.EventType; import mage.players.Player; /** - * * @author emerald000 */ public final class BattletideAlchemist extends CardImpl { public BattletideAlchemist(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}{W}"); this.subtype.add(SubType.KITHKIN, SubType.CLERIC); this.power = new MageInt(3); this.toughness = new MageInt(4); @@ -63,7 +63,7 @@ class BattletideAlchemistEffect extends PreventionEffectImpl { boolean result = false; Player controller = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(event.getTargetId()); - if (controller != null) { + if (controller != null && targetPlayer != null) { int numberOfClericsControlled = new PermanentsOnBattlefieldCount(new FilterControlledCreaturePermanent(SubType.CLERIC, "Clerics")).calculate(game, source, this); int toPrevent = Math.min(numberOfClericsControlled, event.getAmount()); if (toPrevent > 0 && controller.chooseUse(Outcome.PreventDamage, "Prevent " + toPrevent + " damage to " + targetPlayer.getName() + '?', source, game)) { @@ -71,20 +71,18 @@ class BattletideAlchemistEffect extends PreventionEffectImpl { if (!game.replaceEvent(preventEvent)) { if (event.getAmount() >= toPrevent) { event.setAmount(event.getAmount() - toPrevent); - } - else { + } else { event.setAmount(0); result = true; } - if (toPrevent > 0) { - game.informPlayers("Battletide Alchemist prevented " + toPrevent + " damage to " + targetPlayer.getName()); - game.fireEvent(GameEvent.getEvent( - GameEvent.EventType.PREVENTED_DAMAGE, - targetPlayer.getId(), - source.getSourceId(), - source.getControllerId(), - toPrevent)); - } + game.informPlayers("Battletide Alchemist prevented " + toPrevent + " damage to " + targetPlayer.getName()); + game.fireEvent(GameEvent.getEvent( + GameEvent.EventType.PREVENTED_DAMAGE, + targetPlayer.getId(), + source.getSourceId(), + source.getControllerId(), + toPrevent)); + } } } diff --git a/Mage.Sets/src/mage/cards/b/BloodScrivener.java b/Mage.Sets/src/mage/cards/b/BloodScrivener.java index 9eb861cc9aa..ee24474fbd0 100644 --- a/Mage.Sets/src/mage/cards/b/BloodScrivener.java +++ b/Mage.Sets/src/mage/cards/b/BloodScrivener.java @@ -85,8 +85,10 @@ class BloodScrivenerReplacementEffect extends ReplacementEffectImpl { public boolean applies(GameEvent event, Ability source, Game game) { if (event.getPlayerId().equals(source.getControllerId())) { Player player = game.getPlayer(event.getPlayerId()); - if (player.getHand().isEmpty()) { - return true; + if(player != null) { + if (player.getHand().isEmpty()) { + return true; + } } } return false; diff --git a/Mage.Sets/src/mage/cards/b/BraidOfFire.java b/Mage.Sets/src/mage/cards/b/BraidOfFire.java index 40a2ba2f88b..b211a5b7e6c 100644 --- a/Mage.Sets/src/mage/cards/b/BraidOfFire.java +++ b/Mage.Sets/src/mage/cards/b/BraidOfFire.java @@ -49,9 +49,12 @@ class BraidOfFireCost extends CostImpl { @Override public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { Player player = game.getPlayer(controllerId); - player.getManaPool().addMana(Mana.RedMana(1), game, ability); - paid = true; - return true; + if(player != null) { + player.getManaPool().addMana(Mana.RedMana(1), game, ability); + paid = true; + return true; + } + return false; } @Override diff --git a/Mage.Sets/src/mage/cards/b/BrainGorgers.java b/Mage.Sets/src/mage/cards/b/BrainGorgers.java index b704ffe4964..056e52aa17e 100644 --- a/Mage.Sets/src/mage/cards/b/BrainGorgers.java +++ b/Mage.Sets/src/mage/cards/b/BrainGorgers.java @@ -74,7 +74,7 @@ class BrainGorgersCounterSourceEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) { cost.clearPaid(); Player player = game.getPlayer(playerId); - if (cost.canPay(source, source.getSourceId(), player.getId(), game) + if (player != null && cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(outcome, "Sacrifice a creature to counter " + sourceObject.getIdName() + '?', source, game)) { if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) { game.informPlayers(player.getLogName() + " sacrifices a creature to counter " + sourceObject.getIdName() + '.'); diff --git a/Mage.Sets/src/mage/cards/b/Browbeat.java b/Mage.Sets/src/mage/cards/b/Browbeat.java index ac5df5f4fa1..4bc1a4a7e57 100644 --- a/Mage.Sets/src/mage/cards/b/Browbeat.java +++ b/Mage.Sets/src/mage/cards/b/Browbeat.java @@ -2,6 +2,7 @@ package mage.cards.b; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.CardImpl; @@ -15,13 +16,12 @@ import mage.players.Player; import mage.target.TargetPlayer; /** - * * @author dustinconrad */ public final class Browbeat extends CardImpl { public Browbeat(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{R}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{R}"); // Any player may have Browbeat deal 5 damage to him or her. If no one does, target player draws three cards. this.getSpellAbility().addEffect(new BrowbeatDrawEffect()); @@ -61,16 +61,16 @@ class BrowbeatDrawEffect extends OneShotEffect { return false; } StackObject spell = null; - for(StackObject object : game.getStack()){ - if(object instanceof Spell && object.getSourceId().equals(source.getSourceId())){ + for (StackObject object : game.getStack()) { + if (object instanceof Spell && object.getSourceId().equals(source.getSourceId())) { spell = object; } } - if(spell != null){ + if (spell != null) { boolean drawCards = true; - for(UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)){ + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); - if (player != null && player.chooseUse(Outcome.Detriment, "Have " + spell.getLogName() + " deal 5 damage to you?", source, game)){ + if (player != null && player.chooseUse(Outcome.Detriment, "Have " + spell.getLogName() + " deal 5 damage to you?", source, game)) { drawCards = false; player.damage(5, source.getSourceId(), game, false, true); game.informPlayers(player.getLogName() + " has " + spell.getLogName() + " deal 5 to him or her"); @@ -80,7 +80,9 @@ class BrowbeatDrawEffect extends OneShotEffect { UUID targetPlayer = getTargetPointer().getFirst(game, source); if (targetPlayer != null) { Player player = game.getPlayer(targetPlayer); - player.drawCards(3, game); + if (player != null) { + player.drawCards(3, game); + } } } return drawCards; diff --git a/Mage.Sets/src/mage/cards/b/BrudicladTelchorEngineer.java b/Mage.Sets/src/mage/cards/b/BrudicladTelchorEngineer.java index 52e0b75f3c6..3ed5ff115ef 100644 --- a/Mage.Sets/src/mage/cards/b/BrudicladTelchorEngineer.java +++ b/Mage.Sets/src/mage/cards/b/BrudicladTelchorEngineer.java @@ -84,6 +84,9 @@ class BrudicladTelchorEngineerEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); + if(controller == null){ + return false; + } CreateTokenEffect effect = new CreateTokenEffect(new BrudicladTelchorMyrToken(), 1); if (effect.apply(game, source)) { diff --git a/Mage.Sets/src/mage/cards/b/BubblingCauldron.java b/Mage.Sets/src/mage/cards/b/BubblingCauldron.java index 01dd111c020..c2c79710315 100644 --- a/Mage.Sets/src/mage/cards/b/BubblingCauldron.java +++ b/Mage.Sets/src/mage/cards/b/BubblingCauldron.java @@ -72,11 +72,16 @@ class BubblingCauldronEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { int damage = 0; + Player you = game.getPlayer(source.getControllerId()); for (UUID opponentId : game.getOpponents(source.getControllerId())) { Player opponent = game.getPlayer(opponentId); - damage += opponent.loseLife(4, game, false); + if(opponent != null) { + damage += opponent.loseLife(4, game, false); + } + } + if(you != null){ + you.gainLife(damage, game, source); } - game.getPlayer(source.getControllerId()).gainLife(damage, game, source); return true; } diff --git a/Mage.Sets/src/mage/cards/c/CandlesOfLeng.java b/Mage.Sets/src/mage/cards/c/CandlesOfLeng.java index ca0dd9384f0..71a2e653497 100644 --- a/Mage.Sets/src/mage/cards/c/CandlesOfLeng.java +++ b/Mage.Sets/src/mage/cards/c/CandlesOfLeng.java @@ -63,6 +63,9 @@ class CandlesOfLengEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); MageObject sourceObject = game.getObject(source.getSourceId()); + if(controller == null || sourceObject == null){ + return false; + } if (controller.getLibrary().hasCards()) { CardsImpl cards = new CardsImpl(); Card card = controller.getLibrary().getFromTop(game); diff --git a/Mage.Sets/src/mage/cards/c/ChainOfSilence.java b/Mage.Sets/src/mage/cards/c/ChainOfSilence.java index b9848d13baf..68833dbeb17 100644 --- a/Mage.Sets/src/mage/cards/c/ChainOfSilence.java +++ b/Mage.Sets/src/mage/cards/c/ChainOfSilence.java @@ -74,7 +74,7 @@ class ChainOfSilenceEffect extends OneShotEffect { game.addEffect(effect, source); Player player = game.getPlayer(permanent.getControllerId()); TargetControlledPermanent target = new TargetControlledPermanent(0, 1, new FilterControlledLandPermanent("a land to sacrifice (to be able to copy " + sourceObject.getName() + ')'), true); - if (player.chooseTarget(Outcome.Sacrifice, target, source, game)) { + if (player != null && player.chooseTarget(Outcome.Sacrifice, target, source, game)) { Permanent land = game.getPermanent(target.getFirstTarget()); if (land != null && land.sacrifice(source.getSourceId(), game)) { if (player.chooseUse(outcome, "Copy the spell?", source, game)) { diff --git a/Mage.Sets/src/mage/cards/c/ChainOfVapor.java b/Mage.Sets/src/mage/cards/c/ChainOfVapor.java index d6b94d8838c..cfcb94afc32 100644 --- a/Mage.Sets/src/mage/cards/c/ChainOfVapor.java +++ b/Mage.Sets/src/mage/cards/c/ChainOfVapor.java @@ -71,7 +71,7 @@ class ChainOfVaporEffect extends OneShotEffect { controller.moveCards(permanent, Zone.HAND, source, game); Player player = game.getPlayer(permanent.getControllerId()); TargetControlledPermanent target = new TargetControlledPermanent(0, 1, new FilterControlledLandPermanent("a land to sacrifice (to be able to copy " + sourceObject.getName() + ')'), true); - if (player.chooseTarget(Outcome.Sacrifice, target, source, game)) { + if (player != null && player.chooseTarget(Outcome.Sacrifice, target, source, game)) { Permanent land = game.getPermanent(target.getFirstTarget()); if (land != null && land.sacrifice(source.getSourceId(), game)) { if (player.chooseUse(outcome, "Copy the spell?", source, game)) { diff --git a/Mage.Sets/src/mage/cards/c/ChainStasis.java b/Mage.Sets/src/mage/cards/c/ChainStasis.java index 295f1bffa14..4724a14be86 100644 --- a/Mage.Sets/src/mage/cards/c/ChainStasis.java +++ b/Mage.Sets/src/mage/cards/c/ChainStasis.java @@ -74,6 +74,9 @@ class ChainStasisEffect extends OneShotEffect { effect.setTargetPointer(new FixedTarget(source.getFirstTarget())); effect.apply(game, source); Player player = game.getPlayer(permanent.getControllerId()); + if(player == null){ + return false; + } Cost cost = new ManaCostsImpl("{2}{U}"); if (cost.pay(source, game, player.getId(), controller.getId(), false)) { if (player.chooseUse(outcome, "Copy the spell?", source, game)) { diff --git a/Mage.Sets/src/mage/cards/c/ChaliceOfLife.java b/Mage.Sets/src/mage/cards/c/ChaliceOfLife.java index 64428785ba4..038aae4141b 100644 --- a/Mage.Sets/src/mage/cards/c/ChaliceOfLife.java +++ b/Mage.Sets/src/mage/cards/c/ChaliceOfLife.java @@ -60,13 +60,15 @@ class ChaliceOfLifeEffect extends OneShotEffect { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { Player player = game.getPlayer(source.getControllerId()); - //gain 1 life - player.gainLife(1, game, source); + if(player != null) { + //gain 1 life + player.gainLife(1, game, source); - // if you have at least 10 life more than your starting life total, transform Chalice of Life. - if (player.getLife() >= game.getLife() + 10) { - permanent.transform(game); - game.informPlayers(new StringBuilder(permanent.getName()).append(" transforms into ").append(permanent.getSecondCardFace().getName()).toString()); + // if you have at least 10 life more than your starting life total, transform Chalice of Life. + if (player.getLife() >= game.getLife() + 10) { + permanent.transform(game); + game.informPlayers(permanent.getName() + " transforms into " + permanent.getSecondCardFace().getName()); + } } } return false; diff --git a/Mage.Sets/src/mage/cards/c/Cleansing.java b/Mage.Sets/src/mage/cards/c/Cleansing.java index 29f62f0d3d5..457e84620ba 100644 --- a/Mage.Sets/src/mage/cards/c/Cleansing.java +++ b/Mage.Sets/src/mage/cards/c/Cleansing.java @@ -55,17 +55,18 @@ class CleansingEffect extends OneShotEffect { boolean paidLife = false; Permanent p = permanents.next(); if (p.isLand()) { - paidLife = false; game.informPlayers("Any player may pay 1 life to prevent the destruction of " + p.getLogName() + " controlled by " + game.getPlayer(p.getControllerId()).getLogName() + "."); PayLifeCost cost = new PayLifeCost(1); for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) { Player player = game.getPlayer(playerId); - cost.clearPaid(); - if (cost.canPay(source, source.getSourceId(), player.getId(), game) - && player.chooseUse(outcome, "Pay 1 life to prevent this?", source, game)) { - if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) { - game.informPlayers(player.getLogName() + " pays 1 life to prevent the destruction of " + p.getLogName()); - paidLife = true; + if(player != null) { + cost.clearPaid(); + if (cost.canPay(source, source.getSourceId(), player.getId(), game) + && player.chooseUse(outcome, "Pay 1 life to prevent this?", source, game)) { + if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) { + game.informPlayers(player.getLogName() + " pays 1 life to prevent the destruction of " + p.getLogName()); + paidLife = true; + } } } } diff --git a/Mage.Sets/src/mage/cards/c/CloakOfConfusion.java b/Mage.Sets/src/mage/cards/c/CloakOfConfusion.java index 782df614d47..477ddbbc723 100644 --- a/Mage.Sets/src/mage/cards/c/CloakOfConfusion.java +++ b/Mage.Sets/src/mage/cards/c/CloakOfConfusion.java @@ -1,21 +1,15 @@ package mage.cards.c; -import java.util.UUID; -import mage.constants.SubType; import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.ReplacementEffectImpl; import mage.abilities.effects.common.AttachEffect; -import mage.constants.Outcome; -import mage.target.TargetPermanent; import mage.abilities.keyword.EnchantAbility; import mage.cards.CardImpl; import mage.cards.CardSetInfo; -import mage.constants.CardType; -import mage.constants.Duration; -import mage.constants.Zone; +import mage.constants.*; import mage.game.Game; import mage.game.combat.CombatGroup; import mage.game.events.DamageEvent; @@ -23,11 +17,13 @@ import mage.game.events.GameEvent; import mage.game.events.GameEvent.EventType; import mage.game.permanent.Permanent; import mage.players.Player; +import mage.target.TargetPermanent; import mage.target.common.TargetControlledCreaturePermanent; import mage.target.targetpointer.FixedTarget; +import java.util.UUID; + /** - * * @author jeffwadsworth */ public final class CloakOfConfusion extends CardImpl { @@ -128,19 +124,18 @@ class CloakOfConfusionEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent enchantedCreature = game.getPermanent(game.getPermanent(source.getSourceId()).getAttachedTo()); - if (controller != null) { - if (controller.chooseUse(outcome, "Do you wish to not assign combat damage from " - + enchantedCreature.getName() + " and have the defending player discard a card at random?", source, game)) { - ContinuousEffect effect = new AssignNoCombatDamageTargetEffect(); - effect.setTargetPointer(new FixedTarget(enchantedCreature.getId())); - game.addEffect(effect, source); - Player defendingPlayer = game.getPlayer(targetPointer.getFirst(game, source)); - if (defendingPlayer != null) { - defendingPlayer.discard(1, true, source, game); - } + if (controller != null && controller.chooseUse(outcome, "Do you wish to not assign combat damage from " + + enchantedCreature.getName() + " and have the defending player discard a card at random?", source, game)) { + ContinuousEffect effect = new AssignNoCombatDamageTargetEffect(); + effect.setTargetPointer(new FixedTarget(enchantedCreature.getId())); + game.addEffect(effect, source); + Player defendingPlayer = game.getPlayer(targetPointer.getFirst(game, source)); + if (defendingPlayer != null) { + defendingPlayer.discard(1, true, source, game); } return true; } + return false; } } diff --git a/Mage.Sets/src/mage/cards/c/CompellingDeterrence.java b/Mage.Sets/src/mage/cards/c/CompellingDeterrence.java index d456459d5bd..4be944df327 100644 --- a/Mage.Sets/src/mage/cards/c/CompellingDeterrence.java +++ b/Mage.Sets/src/mage/cards/c/CompellingDeterrence.java @@ -65,9 +65,9 @@ class CompellingDeterrenceEffect extends OneShotEffect { if (controller != null && player != null) { player.moveCards(target, Zone.HAND, source, game); game.applyEffects(); - FilterPermanent FILTER = new FilterPermanent(); - FILTER.add(new SubtypePredicate(SubType.ZOMBIE)); - if (game.getState().getBattlefield().countAll(FILTER, controller.getId(), game) > 0) { + FilterPermanent zombieFilter = new FilterPermanent(); + zombieFilter.add(new SubtypePredicate(SubType.ZOMBIE)); + if (game.getState().getBattlefield().countAll(zombieFilter, controller.getId(), game) > 0) { player.discard(1, false, source, game); } return true; diff --git a/Mage.Sets/src/mage/cards/c/ConquerorsFlail.java b/Mage.Sets/src/mage/cards/c/ConquerorsFlail.java index 477cd898b81..6e1ed21d91b 100644 --- a/Mage.Sets/src/mage/cards/c/ConquerorsFlail.java +++ b/Mage.Sets/src/mage/cards/c/ConquerorsFlail.java @@ -90,9 +90,8 @@ class ConquerorsFlailColorCount implements DynamicValue { count++; } } - return count; } - return 0; + return count; } @Override diff --git a/Mage.Sets/src/mage/cards/c/ConsulateCrackdown.java b/Mage.Sets/src/mage/cards/c/ConsulateCrackdown.java index c43791b4388..164a7c77f30 100644 --- a/Mage.Sets/src/mage/cards/c/ConsulateCrackdown.java +++ b/Mage.Sets/src/mage/cards/c/ConsulateCrackdown.java @@ -64,19 +64,19 @@ class ConsulateCracksownExileEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player contoller = game.getPlayer(source.getControllerId()); + Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getSourceId()); //If the permanent leaves the battlefield before the ability resolves, artifacts won't be exiled. - if (permanent == null || contoller == null) return false; + if (permanent == null || controller == null) return false; Set toExile = new LinkedHashSet<>(); - for (Permanent artifact : game.getBattlefield().getActivePermanents(filter, contoller.getId(), game)) { + for (Permanent artifact : game.getBattlefield().getActivePermanents(filter, controller.getId(), game)) { toExile.add(artifact); } if (!toExile.isEmpty()) { - contoller.moveCardsToExile(toExile, source, game, true, CardUtil.getCardExileZoneId(game, source), permanent.getIdName()); + controller.moveCardsToExile(toExile, source, game, true, CardUtil.getCardExileZoneId(game, source), permanent.getIdName()); new CreateDelayedTriggeredAbilityEffect(new OnLeaveReturnExiledToBattlefieldAbility()).apply(game, source); } diff --git a/Mage.Sets/src/mage/cards/c/ConsumingVapors.java b/Mage.Sets/src/mage/cards/c/ConsumingVapors.java index f31246100a6..adbf64bb32c 100644 --- a/Mage.Sets/src/mage/cards/c/ConsumingVapors.java +++ b/Mage.Sets/src/mage/cards/c/ConsumingVapors.java @@ -72,7 +72,7 @@ class ConsumingVaporsEffect extends OneShotEffect { //A spell or ability could have removed the only legal target this player //had, if thats the case this ability should fizzle. - if (target.canChoose(player.getId(), game)) { + if (player != null && target.canChoose(player.getId(), game)) { player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/c/Convalescence.java b/Mage.Sets/src/mage/cards/c/Convalescence.java index 104ba5007fa..fa3476e5a43 100644 --- a/Mage.Sets/src/mage/cards/c/Convalescence.java +++ b/Mage.Sets/src/mage/cards/c/Convalescence.java @@ -51,7 +51,7 @@ class ConvalescenceEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - if (player.getLife() <= 10) { + if (player != null && player.getLife() <= 10) { player.gainLife(1, game, source); return true; } diff --git a/Mage.Sets/src/mage/cards/c/CopyEnchantment.java b/Mage.Sets/src/mage/cards/c/CopyEnchantment.java index 53ecbe3072a..a17d5da5263 100644 --- a/Mage.Sets/src/mage/cards/c/CopyEnchantment.java +++ b/Mage.Sets/src/mage/cards/c/CopyEnchantment.java @@ -47,63 +47,3 @@ public final class CopyEnchantment extends CardImpl { return new CopyEnchantment(this); } } - -class CopyEnchantmentEffect extends CopyPermanentEffect { - - public CopyEnchantmentEffect(FilterPermanent filter) { - super(filter, new EmptyApplyToPermanent()); - } - - public CopyEnchantmentEffect(final CopyEnchantmentEffect effect) { - super(effect); - } - - @Override - public boolean apply(Game game, Ability source) { - Player controller = game.getPlayer(source.getControllerId()); - Permanent sourcePermanent = game.getPermanentEntering(source.getSourceId()); - if (controller != null && sourcePermanent != null) { - if (super.apply(game, source)) { - Permanent permanentToCopy = getBluePrintPermanent(); - if (permanentToCopy != null) { - if (permanentToCopy.hasSubtype(SubType.AURA, game)) { - Target target = getBluePrintPermanent().getSpellAbility().getTargets().get(0); - Outcome auraOutcome = Outcome.BoostCreature; - Ability: - for (Ability ability : getBluePrintPermanent().getAbilities()) { - if (ability instanceof SpellAbility) { - for (Effect effect : ability.getEffects()) { - if (effect instanceof AttachEffect) { - auraOutcome = effect.getOutcome(); - break Ability; - } - } - } - } - target.setNotTarget(true); - if (controller.choose(auraOutcome, target, source.getSourceId(), game)) { - UUID targetId = target.getFirstTarget(); - Permanent targetPermanent = game.getPermanent(targetId); - Player targetPlayer = game.getPlayer(targetId); - if (targetPermanent != null) { - targetPermanent.addAttachment(sourcePermanent.getId(), game); - } else if (targetPlayer != null) { - targetPlayer.addAttachment(sourcePermanent.getId(), game); - } else { - return false; - } - } - } - return true; - } - } - } - return false; - } - - @Override - public CopyEnchantmentEffect copy() { - return new CopyEnchantmentEffect(this); - } - -} diff --git a/Mage.Sets/src/mage/cards/c/CreepingDread.java b/Mage.Sets/src/mage/cards/c/CreepingDread.java index 509cf4176d6..c2b0e0e8a06 100644 --- a/Mage.Sets/src/mage/cards/c/CreepingDread.java +++ b/Mage.Sets/src/mage/cards/c/CreepingDread.java @@ -89,7 +89,7 @@ class CreepingDreadEffect extends OneShotEffect { for (UUID playerId : game.getOpponents(source.getControllerId())) { Player opponent = game.getPlayer(playerId); // opponent discards a card - if it is same card type as controller, add to opponentsAffected - if(!opponent.getHand().isEmpty()) { + if(opponent != null && !opponent.getHand().isEmpty()) { TargetCard target = new TargetCard(Zone.HAND, new FilterCard()); if(opponent.choose(Outcome.Discard, opponent.getHand(), target, game)) { Card card = opponent.getHand().get(target.getFirstTarget(), game); diff --git a/Mage.Sets/src/mage/cards/c/CrosisThePurger.java b/Mage.Sets/src/mage/cards/c/CrosisThePurger.java index 7bd601aaa26..b2f87e2d6a0 100644 --- a/Mage.Sets/src/mage/cards/c/CrosisThePurger.java +++ b/Mage.Sets/src/mage/cards/c/CrosisThePurger.java @@ -78,22 +78,24 @@ class CrosisThePurgerEffect extends OneShotEffect { ChoiceColor choice = new ChoiceColor(); player.choose(outcome, choice, game); if (choice.isChosen()) { - game.informPlayers(new StringBuilder(player.getLogName()).append(" chooses ").append(choice.getColor()).toString()); + game.informPlayers(player.getLogName() + " chooses " + choice.getColor()); Player damagedPlayer = game.getPlayer(this.getTargetPointer().getFirst(game, source)); - damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game); - FilterCard filter = new FilterCard(); - filter.add(new ColorPredicate(choice.getColor())); - List toDiscard = new ArrayList<>(); - for (UUID cardId : damagedPlayer.getHand()) { - Card card = game.getCard(cardId); - if (filter.match(card, game)) { - toDiscard.add(card); + if(damagedPlayer != null) { + damagedPlayer.revealCards("hand of " + damagedPlayer.getName(), damagedPlayer.getHand(), game); + FilterCard filter = new FilterCard(); + filter.add(new ColorPredicate(choice.getColor())); + List toDiscard = new ArrayList<>(); + for (UUID cardId : damagedPlayer.getHand()) { + Card card = game.getCard(cardId); + if (filter.match(card, game)) { + toDiscard.add(card); + } } + for (Card card : toDiscard) { + damagedPlayer.discard(card, source, game); + } + return true; } - for (Card card : toDiscard) { - damagedPlayer.discard(card, source, game); - } - return true; } } return false; diff --git a/Mage.Sets/src/mage/cards/c/CrypticGateway.java b/Mage.Sets/src/mage/cards/c/CrypticGateway.java index def2b7f7702..704e9dc48bd 100644 --- a/Mage.Sets/src/mage/cards/c/CrypticGateway.java +++ b/Mage.Sets/src/mage/cards/c/CrypticGateway.java @@ -146,7 +146,6 @@ class CrypticGatewayEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); if (source.getCosts() == null) { return false; } diff --git a/Mage.Sets/src/mage/cards/c/CurseOfEchoes.java b/Mage.Sets/src/mage/cards/c/CurseOfEchoes.java index fc85728ff25..ff670fab1a4 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfEchoes.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfEchoes.java @@ -121,9 +121,9 @@ class CurseOfEchoesEffect extends OneShotEffect { if (spell != null) { String chooseMessage = "Copy target spell? You may choose new targets for the copy."; for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { - if (!playerId.equals(spell.getControllerId())) { + if (!spell.isControlledBy(playerId)) { Player player = game.getPlayer(playerId); - if (player.chooseUse(Outcome.Copy, chooseMessage, source, game)) { + if (player != null && player.chooseUse(Outcome.Copy, chooseMessage, source, game)) { spell.createCopyOnStack(game, source, player.getId(), true); } } diff --git a/Mage.Sets/src/mage/cards/c/CurseOfVengeance.java b/Mage.Sets/src/mage/cards/c/CurseOfVengeance.java index 3fb01a3559e..318a99d37e8 100644 --- a/Mage.Sets/src/mage/cards/c/CurseOfVengeance.java +++ b/Mage.Sets/src/mage/cards/c/CurseOfVengeance.java @@ -153,7 +153,7 @@ class CurseOfVengeanceDrawLifeEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - Permanent sourceObject = (Permanent) game.getPermanentOrLKIBattlefield(source.getSourceId()); + Permanent sourceObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (sourceObject != null && controller != null) { if (sourceObject.getCounters(game).containsKey(CounterType.SPITE)) { controller.drawCards(sourceObject.getCounters(game).getCount(CounterType.SPITE), game); diff --git a/Mage.Sets/src/mage/cards/c/CyclopsGladiator.java b/Mage.Sets/src/mage/cards/c/CyclopsGladiator.java index 95877d5cb98..638e886454f 100644 --- a/Mage.Sets/src/mage/cards/c/CyclopsGladiator.java +++ b/Mage.Sets/src/mage/cards/c/CyclopsGladiator.java @@ -70,7 +70,7 @@ class CyclopsGladiatorEffect extends OneShotEffect { TargetCreaturePermanent target = new TargetCreaturePermanent(filter); Player player = game.getPlayer(source.getControllerId()); if (target.canChoose(source.getSourceId(), source.getControllerId(), game)) { - if (player.chooseTarget(Outcome.Detriment, target, source, game)) { + if (player != null && player.chooseTarget(Outcome.Detriment, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); Permanent cyclops = game.getPermanent(source.getSourceId()); if (permanent != null && cyclops != null) { diff --git a/Mage.Sets/src/mage/cards/d/DarkRevenant.java b/Mage.Sets/src/mage/cards/d/DarkRevenant.java index cb0fc5a2da1..6741b40a2bd 100644 --- a/Mage.Sets/src/mage/cards/d/DarkRevenant.java +++ b/Mage.Sets/src/mage/cards/d/DarkRevenant.java @@ -68,8 +68,10 @@ class DarkRevenantEffect extends OneShotEffect { Card card = game.getCard(source.getSourceId()); if (card != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) { Player owner = game.getPlayer(card.getOwnerId()); - owner.getGraveyard().remove(card); - return card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + if(owner != null) { + owner.getGraveyard().remove(card); + return card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + } } return true; } diff --git a/Mage.Sets/src/mage/cards/d/DashHopes.java b/Mage.Sets/src/mage/cards/d/DashHopes.java index c3a0336f7ad..a8edaeace7f 100644 --- a/Mage.Sets/src/mage/cards/d/DashHopes.java +++ b/Mage.Sets/src/mage/cards/d/DashHopes.java @@ -67,14 +67,16 @@ class DashHopesCounterSourceEffect extends OneShotEffect { PayLifeCost cost = new PayLifeCost(5); for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) { Player player = game.getPlayer(playerId); - cost.clearPaid(); - if (cost.canPay(source, source.getSourceId(), player.getId(), game) - && player.chooseUse(outcome, "Pay 5 life to counter " + sourceObject.getIdName() + '?', source, game)) { - if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) { - game.informPlayers(player.getLogName() + " pays 5 life to counter " + sourceObject.getIdName() + '.'); - Spell spell = game.getStack().getSpell(source.getSourceId()); - if (spell != null) { - game.getStack().counter(spell.getId(), source.getSourceId(), game); + if(player != null) { + cost.clearPaid(); + if (cost.canPay(source, source.getSourceId(), player.getId(), game) + && player.chooseUse(outcome, "Pay 5 life to counter " + sourceObject.getIdName() + '?', source, game)) { + if (cost.pay(source, game, source.getSourceId(), player.getId(), false, null)) { + game.informPlayers(player.getLogName() + " pays 5 life to counter " + sourceObject.getIdName() + '.'); + Spell spell = game.getStack().getSpell(source.getSourceId()); + if (spell != null) { + game.getStack().counter(spell.getId(), source.getSourceId(), game); + } } } } diff --git a/Mage.Sets/src/mage/cards/d/DauntlessBodyguard.java b/Mage.Sets/src/mage/cards/d/DauntlessBodyguard.java index e88ad33e38d..1d7eedc6ade 100644 --- a/Mage.Sets/src/mage/cards/d/DauntlessBodyguard.java +++ b/Mage.Sets/src/mage/cards/d/DauntlessBodyguard.java @@ -85,16 +85,14 @@ class DauntlessBodyguardChooseCreatureEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - MageObject mageObject = game.getPermanentEntering(source.getSourceId()); + Permanent mageObject = game.getPermanentEntering(source.getSourceId()); if (controller != null && mageObject != null) { TargetControlledCreaturePermanent target = new TargetControlledCreaturePermanent(1, 1, filter, true); if (controller.choose(this.outcome, target, source.getSourceId(), game)) { Permanent chosenCreature = game.getPermanent(target.getFirstTarget()); if (chosenCreature != null) { game.getState().setValue(mageObject.getId() + "_chosenCreature", new MageObjectReference(chosenCreature, game)); - if (mageObject instanceof Permanent) { - ((Permanent) mageObject).addInfo("chosen creature", CardUtil.addToolTipMarkTags("Chosen creature: " + chosenCreature.getIdName()), game); - } + mageObject.addInfo("chosen creature", CardUtil.addToolTipMarkTags("Chosen creature: " + chosenCreature.getIdName()), game); } } return true; diff --git a/Mage.Sets/src/mage/cards/d/Deicide.java b/Mage.Sets/src/mage/cards/d/Deicide.java index 3e72df10a88..a1fa7e38556 100644 --- a/Mage.Sets/src/mage/cards/d/Deicide.java +++ b/Mage.Sets/src/mage/cards/d/Deicide.java @@ -68,7 +68,7 @@ class DeicideExileEffect extends SearchTargetGraveyardHandLibraryForCardNameAndE Card cardInExile = game.getExile().getCard(targetEnchantment.getId(), game); if (cardInExile != null && cardInExile.hasSubtype(SubType.GOD, game)) { Player enchantmentController = game.getPlayer(targetEnchantment.getControllerId()); - return super.applySearchAndExile(game, source, cardInExile.getName(), enchantmentController.getId()); + return enchantmentController != null && super.applySearchAndExile(game, source, cardInExile.getName(), enchantmentController.getId()); } } } diff --git a/Mage.Sets/src/mage/cards/d/DesperateGambit.java b/Mage.Sets/src/mage/cards/d/DesperateGambit.java index eb79f9d2627..bce9512aa1d 100644 --- a/Mage.Sets/src/mage/cards/d/DesperateGambit.java +++ b/Mage.Sets/src/mage/cards/d/DesperateGambit.java @@ -68,8 +68,11 @@ class DesperateGambitEffect extends PreventionEffectImpl { @Override public void init(Ability source, Game game) { this.target.choose(Outcome.Benefit, source.getControllerId(), source.getSourceId(), game); - this.wonFlip = game.getPlayer(source.getControllerId()).flipCoin(game); - super.init(source, game); + Player you = game.getPlayer(source.getControllerId()); + if(you != null) { + wonFlip = you.flipCoin(game); + super.init(source, game); + } } @Override diff --git a/Mage.Sets/src/mage/cards/d/DiscordantDirge.java b/Mage.Sets/src/mage/cards/d/DiscordantDirge.java index cab74cb9870..dcac03578fe 100644 --- a/Mage.Sets/src/mage/cards/d/DiscordantDirge.java +++ b/Mage.Sets/src/mage/cards/d/DiscordantDirge.java @@ -81,7 +81,7 @@ class DiscordantDirgeEffect extends OneShotEffect { TargetCard target = new TargetCard(0, verseCounters, Zone.HAND, new FilterCard()); target.setNotTarget(true); if (controller.choose(Outcome.Benefit, targetOpponent.getHand(), target, game)) { - target.getTargets().stream().map((targetCardId) -> game.getCard(targetCardId)).filter((card) -> (card != null + target.getTargets().stream().map(game::getCard).filter((card) -> (card != null && targetOpponent.getHand().contains(card.getId()))).forEachOrdered((card) -> { targetOpponent.discard(card, source, game); }); diff --git a/Mage.Sets/src/mage/cards/d/DivineCongregation.java b/Mage.Sets/src/mage/cards/d/DivineCongregation.java index fd2337047f9..d135de316e1 100644 --- a/Mage.Sets/src/mage/cards/d/DivineCongregation.java +++ b/Mage.Sets/src/mage/cards/d/DivineCongregation.java @@ -62,7 +62,7 @@ class DivineCongregationEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getFirstTarget()); - if (controller != null) { + if (controller != null && player != null) { int critters = game.getBattlefield().getAllActivePermanents(new FilterCreaturePermanent(), player.getId(), game).size(); controller.gainLife(2 * critters, game, source); } diff --git a/Mage.Sets/src/mage/cards/d/DivineReckoning.java b/Mage.Sets/src/mage/cards/d/DivineReckoning.java index 88ec3027151..784babe0fcb 100644 --- a/Mage.Sets/src/mage/cards/d/DivineReckoning.java +++ b/Mage.Sets/src/mage/cards/d/DivineReckoning.java @@ -4,6 +4,7 @@ package mage.cards.d; import java.util.ArrayList; import java.util.List; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.costs.mana.ManaCostsImpl; import mage.abilities.effects.OneShotEffect; @@ -28,7 +29,7 @@ import mage.target.common.TargetControlledPermanent; public final class DivineReckoning extends CardImpl { public DivineReckoning(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{W}{W}"); // Each player chooses a creature he or she controls. Destroy the rest. this.getSpellAbility().addEffect(new DivineReckoningEffect()); @@ -65,15 +66,16 @@ class DivineReckoningEffect extends OneShotEffect { if (controller != null) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); - - Target target = new TargetControlledPermanent(1, 1, new FilterControlledCreaturePermanent(), true); - if (target.canChoose(player.getId(), game)) { - while (player.canRespond() && !target.isChosen() && target.canChoose(player.getId(), game)) { - player.chooseTarget(Outcome.Benefit, target, source, game); - } - Permanent permanent = game.getPermanent(target.getFirstTarget()); - if (permanent != null) { - chosen.add(permanent); + if (player != null) { + Target target = new TargetControlledPermanent(1, 1, new FilterControlledCreaturePermanent(), true); + if (target.canChoose(player.getId(), game)) { + while (player.canRespond() && !target.isChosen() && target.canChoose(player.getId(), game)) { + player.chooseTarget(Outcome.Benefit, target, source, game); + } + Permanent permanent = game.getPermanent(target.getFirstTarget()); + if (permanent != null) { + chosen.add(permanent); + } } } } diff --git a/Mage.Sets/src/mage/cards/d/DragonlordKolaghan.java b/Mage.Sets/src/mage/cards/d/DragonlordKolaghan.java index 5c793c9bf7e..380bcc134b4 100644 --- a/Mage.Sets/src/mage/cards/d/DragonlordKolaghan.java +++ b/Mage.Sets/src/mage/cards/d/DragonlordKolaghan.java @@ -89,16 +89,18 @@ class DragonlordKolaghanTriggeredAbility extends TriggeredAbilityImpl { Spell spell = game.getStack().getSpell(event.getSourceId()); if (spell != null && !spell.isFaceDown(game) && (spell.isCreature() || spell.isPlaneswalker())) { Player opponent = game.getPlayer(event.getPlayerId()); - boolean sameName = false; - for (Card graveCard : opponent.getGraveyard().getCards(game)) { - if (CardUtil.haveSameNames(graveCard, spell)) { - sameName = true; - break; + if(opponent != null) { + boolean sameName = false; + for (Card graveCard : opponent.getGraveyard().getCards(game)) { + if (CardUtil.haveSameNames(graveCard, spell)) { + sameName = true; + break; + } + } + if (sameName) { + this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); + return true; } - } - if (sameName) { - this.getEffects().get(0).setTargetPointer(new FixedTarget(event.getPlayerId())); - return true; } } } diff --git a/Mage.Sets/src/mage/cards/d/DrasticRevelation.java b/Mage.Sets/src/mage/cards/d/DrasticRevelation.java index 5f314f7ae08..e6d3c98266a 100644 --- a/Mage.Sets/src/mage/cards/d/DrasticRevelation.java +++ b/Mage.Sets/src/mage/cards/d/DrasticRevelation.java @@ -54,13 +54,15 @@ class DrasticRevelationEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); - you.discardToMax(game); - you.drawCards(7, game); - Cards hand = you.getHand(); - for (int i = 0; i < 3; i++) { - Card card = hand.getRandom(game); - if (card != null) { - you.discard(card, source, game); + if(you != null) { + you.discardToMax(game); + you.drawCards(7, game); + Cards hand = you.getHand(); + for (int i = 0; i < 3; i++) { + Card card = hand.getRandom(game); + if (card != null) { + you.discard(card, source, game); + } } } return false; diff --git a/Mage.Sets/src/mage/cards/e/EliteArcanist.java b/Mage.Sets/src/mage/cards/e/EliteArcanist.java index ed9cb29391d..b44d6aef399 100644 --- a/Mage.Sets/src/mage/cards/e/EliteArcanist.java +++ b/Mage.Sets/src/mage/cards/e/EliteArcanist.java @@ -95,7 +95,7 @@ class EliteArcanistImprintEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - if (!player.getHand().isEmpty()) { + if (player != null && !player.getHand().isEmpty()) { TargetCard target = new TargetCard(Zone.HAND, filter); if (target.canChoose(source.getSourceId(), source.getControllerId(), game) && player.choose(Outcome.Benefit, player.getHand(), target, game)) { @@ -105,7 +105,7 @@ class EliteArcanistImprintEffect extends OneShotEffect { Permanent permanent = game.getPermanent(source.getSourceId()); if (permanent != null) { permanent.imprint(card.getId(), game); - permanent.addInfo("imprint", new StringBuilder("[Exiled card - ").append(card.getName()).append(']').toString(), game); + permanent.addInfo("imprint", "[Exiled card - " + card.getName() + ']', game); } return true; } diff --git a/Mage.Sets/src/mage/cards/e/EnfysNest.java b/Mage.Sets/src/mage/cards/e/EnfysNest.java index 0fb3a495b8f..a1c387a8045 100644 --- a/Mage.Sets/src/mage/cards/e/EnfysNest.java +++ b/Mage.Sets/src/mage/cards/e/EnfysNest.java @@ -74,9 +74,11 @@ class EnfysNestEffect extends ExileTargetEffect { // If you do, that player gains life equal to that creature's power. Player player = game.getPlayer(permanent.getControllerId()); - player.gainLife(permanent.getPower().getValue(), game, source); + if(player != null) { + player.gainLife(permanent.getPower().getValue(), game, source); - return true; + return true; + } } return false; } diff --git a/Mage.Sets/src/mage/cards/e/Eureka.java b/Mage.Sets/src/mage/cards/e/Eureka.java index 7ab838fadd1..e76f14de6db 100644 --- a/Mage.Sets/src/mage/cards/e/Eureka.java +++ b/Mage.Sets/src/mage/cards/e/Eureka.java @@ -90,7 +90,7 @@ class EurekaEffect extends OneShotEffect { playerList.getNext(); currentPlayer = game.getPlayer(playerList.get()); // if all player since this player didn't put permanent in play finish the process - if (currentPlayer.getId().equals(firstInactivePlayer)) { + if (currentPlayer != null &¤tPlayer.getId().equals(firstInactivePlayer)) { break; } } diff --git a/Mage.Sets/src/mage/cards/e/EyeOfDoom.java b/Mage.Sets/src/mage/cards/e/EyeOfDoom.java index 5c872651e6d..e580ff068cc 100644 --- a/Mage.Sets/src/mage/cards/e/EyeOfDoom.java +++ b/Mage.Sets/src/mage/cards/e/EyeOfDoom.java @@ -86,7 +86,7 @@ class EyeOfDoomEffect extends OneShotEffect { Player player = game.getPlayer(game.getActivePlayerId()); do { target.clearChosen(); - if (player.chooseTarget(outcome, target, source, game)) { + if (player != null && player.chooseTarget(outcome, target, source, game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null) { permanents.add(permanent); diff --git a/Mage.Sets/src/mage/cards/f/FallOfTheThran.java b/Mage.Sets/src/mage/cards/f/FallOfTheThran.java index 351672ca518..bae5195fc3d 100644 --- a/Mage.Sets/src/mage/cards/f/FallOfTheThran.java +++ b/Mage.Sets/src/mage/cards/f/FallOfTheThran.java @@ -77,13 +77,15 @@ class FallOfTheThranReturnEffect extends OneShotEffect { if (controller != null) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); - TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(2, 2, StaticFilters.FILTER_CARD_LAND); - target.setNotTarget(true); - target.setTargetController(playerId); - if (target.canChoose(source.getSourceId(), playerId, game)) { - player.choose(outcome, target, source.getSourceId(), game); - if (target.getTargets().size() == 2) { - toBattlefield.put(playerId, new CardsImpl(target.getTargets()).getCards(game)); + if(player != null) { + TargetCardInYourGraveyard target = new TargetCardInYourGraveyard(2, 2, StaticFilters.FILTER_CARD_LAND); + target.setNotTarget(true); + target.setTargetController(playerId); + if (target.canChoose(source.getSourceId(), playerId, game)) { + player.choose(outcome, target, source.getSourceId(), game); + if (target.getTargets().size() == 2) { + toBattlefield.put(playerId, new CardsImpl(target.getTargets()).getCards(game)); + } } } } diff --git a/Mage.Sets/src/mage/cards/f/FeedThePack.java b/Mage.Sets/src/mage/cards/f/FeedThePack.java index 7e5ce9cadc9..24957df34a6 100644 --- a/Mage.Sets/src/mage/cards/f/FeedThePack.java +++ b/Mage.Sets/src/mage/cards/f/FeedThePack.java @@ -69,7 +69,7 @@ class FeedThePackEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Target target = new TargetPermanent(filter); Player player = game.getPlayer(source.getControllerId()); - if (player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { + if (player != null && player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { Permanent permanent = game.getPermanent(target.getFirstTarget()); if (permanent != null && permanent.sacrifice(source.getSourceId(), game)) { int toughness = permanent.getToughness().getValue(); diff --git a/Mage.Sets/src/mage/cards/f/Foresight.java b/Mage.Sets/src/mage/cards/f/Foresight.java index b424fce3f60..96ce3b1792f 100644 --- a/Mage.Sets/src/mage/cards/f/Foresight.java +++ b/Mage.Sets/src/mage/cards/f/Foresight.java @@ -63,7 +63,7 @@ class ForesightEffect extends SearchEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - if (player.searchLibrary(target, game)) { + if (player != null && player.searchLibrary(target, game)) { for (UUID targetId : getTargets()) { Card card = player.getLibrary().getCard(targetId, game); if (card != null) { diff --git a/Mage.Sets/src/mage/cards/f/Fork.java b/Mage.Sets/src/mage/cards/f/Fork.java index 3c1e610ac81..3c18033485e 100644 --- a/Mage.Sets/src/mage/cards/f/Fork.java +++ b/Mage.Sets/src/mage/cards/f/Fork.java @@ -58,7 +58,7 @@ class ForkEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Spell spell = game.getStack().getSpell(targetPointer.getFirst(game, source)); - if (spell != null) { + if (spell != null && controller != null) { Spell copy = spell.copySpell(source.getControllerId()); copy.getColor(game).setRed(true); game.getStack().push(copy); diff --git a/Mage.Sets/src/mage/cards/g/GOTOJAIL.java b/Mage.Sets/src/mage/cards/g/GOTOJAIL.java index a7977281ffb..90a1fcb9fc8 100644 --- a/Mage.Sets/src/mage/cards/g/GOTOJAIL.java +++ b/Mage.Sets/src/mage/cards/g/GOTOJAIL.java @@ -145,7 +145,6 @@ class GoToJailUpkeepEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Player player = game.getPlayer(source.getControllerId()); MageObject sourceObject = source.getSourceObjectIfItStillExists(game); Permanent permanent = (Permanent) source.getSourceObjectIfItStillExists(game); diff --git a/Mage.Sets/src/mage/cards/g/GhostQuarter.java b/Mage.Sets/src/mage/cards/g/GhostQuarter.java index 66a20c6860e..89e6e43128a 100644 --- a/Mage.Sets/src/mage/cards/g/GhostQuarter.java +++ b/Mage.Sets/src/mage/cards/g/GhostQuarter.java @@ -71,7 +71,7 @@ class GhostQuarterEffect extends OneShotEffect { Permanent permanent = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); if (permanent != null) { Player controller = game.getPlayer(permanent.getControllerId()); - if (controller.chooseUse(Outcome.PutLandInPlay, "Do you wish to search for a basic land, put it onto the battlefield and then shuffle your library?", source, game)) { + if (controller != null && controller.chooseUse(Outcome.PutLandInPlay, "Do you wish to search for a basic land, put it onto the battlefield and then shuffle your library?", source, game)) { TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_BASIC_LAND); if (controller.searchLibrary(target, game)) { Card card = controller.getLibrary().getCard(target.getFirstTarget(), game); diff --git a/Mage.Sets/src/mage/cards/g/GiantAlbatross.java b/Mage.Sets/src/mage/cards/g/GiantAlbatross.java index d2c05f3e8cd..f6f27628e4a 100644 --- a/Mage.Sets/src/mage/cards/g/GiantAlbatross.java +++ b/Mage.Sets/src/mage/cards/g/GiantAlbatross.java @@ -74,7 +74,7 @@ class GiantAlbatrossEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent sourcePermanent = game.getPermanentOrLKIBattlefield(source.getSourceId()); - if (sourcePermanent != null) { + if (sourcePermanent != null && controller != null) { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/g/GlobalRuin.java b/Mage.Sets/src/mage/cards/g/GlobalRuin.java index 75906072ee6..0f191c52182 100644 --- a/Mage.Sets/src/mage/cards/g/GlobalRuin.java +++ b/Mage.Sets/src/mage/cards/g/GlobalRuin.java @@ -67,13 +67,15 @@ class GlobalRuinDestroyLandEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); - for (SubType landName : Arrays.stream(SubType.values()).filter(p -> p.getSubTypeSet() == SubTypeSet.BasicLandType).collect(Collectors.toSet())) { - FilterControlledLandPermanent filter = new FilterControlledLandPermanent(landName + " you control"); - filter.add(new SubtypePredicate(landName)); - Target target = new TargetControlledPermanent(1, 1, filter, true); - if (target.canChoose(player.getId(), game)) { - player.chooseTarget(outcome, target, source, game); - lands.add(target.getFirstTarget()); + if(player != null) { + for (SubType landName : Arrays.stream(SubType.values()).filter(p -> p.getSubTypeSet() == SubTypeSet.BasicLandType).collect(Collectors.toSet())) { + FilterControlledLandPermanent filter = new FilterControlledLandPermanent(landName + " you control"); + filter.add(new SubtypePredicate(landName)); + Target target = new TargetControlledPermanent(1, 1, filter, true); + if (target.canChoose(player.getId(), game)) { + player.chooseTarget(outcome, target, source, game); + lands.add(target.getFirstTarget()); + } } } } diff --git a/Mage.Sets/src/mage/cards/g/Gloomlance.java b/Mage.Sets/src/mage/cards/g/Gloomlance.java index f0a70975759..f7a42d9e084 100644 --- a/Mage.Sets/src/mage/cards/g/Gloomlance.java +++ b/Mage.Sets/src/mage/cards/g/Gloomlance.java @@ -63,8 +63,10 @@ class GloomlanceEffect extends OneShotEffect { Permanent destroyedCreature = game.getPermanentOrLKIBattlefield(source.getFirstTarget()); if (destroyedCreature.getColor(game).isGreen() || destroyedCreature.getColor(game).isWhite()) { - targetController.discard(1, false, source, game); - return true; + if(targetController != null) { + targetController.discard(1, false, source, game); + return true; + } } } return false; diff --git a/Mage.Sets/src/mage/cards/g/GroveOfTheBurnwillows.java b/Mage.Sets/src/mage/cards/g/GroveOfTheBurnwillows.java index 8f6d13c9a4b..76bbe397825 100644 --- a/Mage.Sets/src/mage/cards/g/GroveOfTheBurnwillows.java +++ b/Mage.Sets/src/mage/cards/g/GroveOfTheBurnwillows.java @@ -59,7 +59,9 @@ class GroveOfTheBurnwillowsEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { for (UUID playerId : game.getOpponents(source.getControllerId())) { Player player = game.getPlayer(playerId); - player.gainLife(1, game, source); + if(player != null) { + player.gainLife(1, game, source); + } } return true; } diff --git a/Mage.Sets/src/mage/cards/h/HallOfGemstone.java b/Mage.Sets/src/mage/cards/h/HallOfGemstone.java index 0f825dd8ef7..ea53e84b9c6 100644 --- a/Mage.Sets/src/mage/cards/h/HallOfGemstone.java +++ b/Mage.Sets/src/mage/cards/h/HallOfGemstone.java @@ -70,7 +70,7 @@ class HallOfGemstoneEffect extends ReplacementEffectImpl { public void init(Ability source, Game game) { super.init(source, game); Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); - MageObject mageObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); + Permanent mageObject = game.getPermanentOrLKIBattlefield(source.getSourceId()); if (player != null && mageObject != null) { ChoiceColor choice = new ChoiceColor(); if (!player.choose(outcome, choice, game)) { @@ -81,9 +81,7 @@ class HallOfGemstoneEffect extends ReplacementEffectImpl { game.informPlayers(mageObject.getLogName() + ": " + player.getLogName() + " has chosen " + choice.getChoice()); } game.getState().setValue(mageObject.getId() + "_color", choice.getColor()); - if (mageObject instanceof Permanent) { - ((Permanent) mageObject).addInfo("chosen color", CardUtil.addToolTipMarkTags("Chosen color: " + choice.getChoice()), game); - } + mageObject.addInfo("chosen color", CardUtil.addToolTipMarkTags("Chosen color: " + choice.getChoice()), game); } } diff --git a/Mage.Sets/src/mage/cards/h/HarshMercy.java b/Mage.Sets/src/mage/cards/h/HarshMercy.java index d511cacc884..748c75d06c0 100644 --- a/Mage.Sets/src/mage/cards/h/HarshMercy.java +++ b/Mage.Sets/src/mage/cards/h/HarshMercy.java @@ -71,7 +71,7 @@ class HarshMercyEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { Player player = game.getPlayer(playerId); Choice typeChoice = new ChoiceCreatureType(sourceObject); - if (!player.choose(Outcome.DestroyPermanent, typeChoice, game)) { + if (player != null && !player.choose(Outcome.DestroyPermanent, typeChoice, game)) { continue PlayerIteration; } String chosenType = typeChoice.getChoice(); diff --git a/Mage.Sets/src/mage/cards/h/HauntingEchoes.java b/Mage.Sets/src/mage/cards/h/HauntingEchoes.java index 35434189da6..5fc7b28ebda 100644 --- a/Mage.Sets/src/mage/cards/h/HauntingEchoes.java +++ b/Mage.Sets/src/mage/cards/h/HauntingEchoes.java @@ -58,7 +58,7 @@ class HauntingEchoesEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); Player targetPlayer = game.getPlayer(source.getFirstTarget()); - if (targetPlayer != null) { + if (targetPlayer != null && player != null) { for (Card card : targetPlayer.getGraveyard().getCards(game)) { if (!StaticFilters.FILTER_CARD_BASIC_LAND.match(card, game)) { card.moveToExile(null, "", source.getSourceId(), game); diff --git a/Mage.Sets/src/mage/cards/h/HeraldsHorn.java b/Mage.Sets/src/mage/cards/h/HeraldsHorn.java index f95458daedb..c57b4d8139f 100644 --- a/Mage.Sets/src/mage/cards/h/HeraldsHorn.java +++ b/Mage.Sets/src/mage/cards/h/HeraldsHorn.java @@ -73,7 +73,7 @@ class HeraldsHornEffect extends OneShotEffect { MageObject sourceObject = game.getObject(source.getSourceId()); // Look at the top card of your library. - if (controller.getLibrary().hasCards()) { + if (controller != null && controller.getLibrary().hasCards()) { Card card = controller.getLibrary().getFromTop(game); Cards cards = new CardsImpl(card); controller.lookAtCards(sourceObject.getIdName(), cards, game); diff --git a/Mage.Sets/src/mage/cards/h/HisokaMinamoSensei.java b/Mage.Sets/src/mage/cards/h/HisokaMinamoSensei.java index a8452b08ecf..c137a7de62d 100644 --- a/Mage.Sets/src/mage/cards/h/HisokaMinamoSensei.java +++ b/Mage.Sets/src/mage/cards/h/HisokaMinamoSensei.java @@ -75,13 +75,15 @@ class HisokaMinamoSenseiDiscardTargetCost extends CostImpl { public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { if (targets.choose(Outcome.Discard, controllerId, sourceId, game)) { Player player = game.getPlayer(controllerId); - for (UUID targetId: targets.get(0).getTargets()) { - card = player.getHand().get(targetId, game); - if (card == null) { - return false; - } - paid |= player.discard(card, null, game); + if(player != null) { + for (UUID targetId : targets.get(0).getTargets()) { + card = player.getHand().get(targetId, game); + if (card == null) { + return false; + } + paid |= player.discard(card, null, game); + } } } return paid; diff --git a/Mage.Sets/src/mage/cards/h/Hydradoodle.java b/Mage.Sets/src/mage/cards/h/Hydradoodle.java index f5f5afffbd5..75fc85bff8c 100644 --- a/Mage.Sets/src/mage/cards/h/Hydradoodle.java +++ b/Mage.Sets/src/mage/cards/h/Hydradoodle.java @@ -84,7 +84,7 @@ class HydradoodleEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanentEntering(source.getSourceId()); Player controller = game.getPlayer(source.getControllerId()); - if (permanent != null) { + if (permanent != null && controller != null) { SpellAbility spellAbility = (SpellAbility) getValue(EntersBattlefieldEffect.SOURCE_CAST_SPELL_ABILITY); if (spellAbility != null && spellAbility.getSourceId().equals(source.getSourceId()) diff --git a/Mage.Sets/src/mage/cards/i/Intuition.java b/Mage.Sets/src/mage/cards/i/Intuition.java index f4146f636d4..101f0ab1b9d 100644 --- a/Mage.Sets/src/mage/cards/i/Intuition.java +++ b/Mage.Sets/src/mage/cards/i/Intuition.java @@ -3,6 +3,7 @@ package mage.cards.i; import java.util.List; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.effects.SearchEffect; import mage.cards.Card; @@ -21,13 +22,12 @@ import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetOpponent; /** - * * @author Plopman */ public final class Intuition extends CardImpl { public Intuition(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{2}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{2}{U}"); // Search your library for three cards and reveal them. Target opponent chooses one. Put that card into your hand and the rest into your graveyard. Then shuffle your library. @@ -47,7 +47,6 @@ public final class Intuition extends CardImpl { class IntuitionEffect extends SearchEffect { - public IntuitionEffect() { super(new TargetCardInLibrary(3, new FilterCard()), Outcome.Benefit); @@ -70,22 +69,22 @@ class IntuitionEffect extends SearchEffect { Player opponent = game.getPlayer(source.getFirstTarget()); if (controller == null || opponent == null) return false; - + if (controller.getLibrary().size() >= 3 && controller.searchLibrary(target, game)) { - + if (target.getTargets().size() == 3) { Cards cards = new CardsImpl(); - for (UUID cardId: (List)target.getTargets()) { + for (UUID cardId : target.getTargets()) { Card card = controller.getLibrary().getCard(cardId, game); if (card != null) { cards.add(card); } } controller.revealCards("Reveal", cards, game); - + TargetCard targetCard = new TargetCard(Zone.LIBRARY, new FilterCard()); - - while(!opponent.choose(Outcome.Neutral, cards, targetCard, game)) { + + while (!opponent.choose(Outcome.Neutral, cards, targetCard, game)) { if (!opponent.canRespond()) { return false; } @@ -100,7 +99,7 @@ class IntuitionEffect extends SearchEffect { controller.shuffleLibrary(source, game); return true; } - + controller.shuffleLibrary(source, game); return false; } diff --git a/Mage.Sets/src/mage/cards/j/JacesArchivist.java b/Mage.Sets/src/mage/cards/j/JacesArchivist.java index 525800c3c76..4d5d557d450 100644 --- a/Mage.Sets/src/mage/cards/j/JacesArchivist.java +++ b/Mage.Sets/src/mage/cards/j/JacesArchivist.java @@ -62,23 +62,24 @@ class JacesArchivistEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { int maxDiscarded = 0; Player controller = game.getPlayer(source.getControllerId()); - for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - Player player = game.getPlayer(playerId); - if (player != null) { - int discarded = player.getHand().size(); - player.discard(discarded, false, source, game); - if (discarded > maxDiscarded) { - maxDiscarded = discarded; + if(controller != null) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + int discarded = player.getHand().size(); + player.discard(discarded, false, source, game); + if (discarded > maxDiscarded) { + maxDiscarded = discarded; + } + } + } + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + player.drawCards(maxDiscarded, game); } } } - for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - Player player = game.getPlayer(playerId); - if (player != null) { - player.drawCards(maxDiscarded, game); - } - } - return true; } diff --git a/Mage.Sets/src/mage/cards/j/JaddiLifestrider.java b/Mage.Sets/src/mage/cards/j/JaddiLifestrider.java index 5048c5792b2..74b680ba40d 100644 --- a/Mage.Sets/src/mage/cards/j/JaddiLifestrider.java +++ b/Mage.Sets/src/mage/cards/j/JaddiLifestrider.java @@ -78,7 +78,7 @@ class JaddiLifestriderEffect extends OneShotEffect { } } } - if (tappedAmount > 0) { + if (tappedAmount > 0 && you != null) { you.gainLife(tappedAmount * 2, game, source); return true; } diff --git a/Mage.Sets/src/mage/cards/j/JandorsRing.java b/Mage.Sets/src/mage/cards/j/JandorsRing.java index 58d23261037..6a8425521fc 100644 --- a/Mage.Sets/src/mage/cards/j/JandorsRing.java +++ b/Mage.Sets/src/mage/cards/j/JandorsRing.java @@ -81,7 +81,9 @@ class JandorsRingEffect extends OneShotEffect { DiscardCardYouChooseTargetEffect effect = new DiscardCardYouChooseTargetEffect(filter, TargetController.YOU); if (effect.apply(game, source)) {//Conditional was already checked, card should be in hand, but if for some weird reason it fails, the card won't be drawn, although the cost will already be paid Player controller = game.getPlayer(source.getControllerId()); - controller.drawCards(1, game); + if(controller != null) { + controller.drawCards(1, game); + } } } return true; diff --git a/Mage.Sets/src/mage/cards/k/KarnsTemporalSundering.java b/Mage.Sets/src/mage/cards/k/KarnsTemporalSundering.java index 01b2b24c50a..2fae89966e7 100644 --- a/Mage.Sets/src/mage/cards/k/KarnsTemporalSundering.java +++ b/Mage.Sets/src/mage/cards/k/KarnsTemporalSundering.java @@ -70,8 +70,12 @@ class KarnsTemporalSunderingEffect extends OneShotEffect { if (returnPermanent != null) { Card returnCard = returnPermanent.getMainCard(); - Player cardOwner = game.getPlayer(returnCard.getOwnerId()); - cardOwner.moveCards(returnCard, Zone.HAND, source, game); + if(returnCard != null) { + Player cardOwner = game.getPlayer(returnCard.getOwnerId()); + if (cardOwner != null) { + cardOwner.moveCards(returnCard, Zone.HAND, source, game); + } + } } return true; diff --git a/Mage.Sets/src/mage/cards/k/KheruSpellsnatcher.java b/Mage.Sets/src/mage/cards/k/KheruSpellsnatcher.java index d5e5bf5a3d8..853f920dd6c 100644 --- a/Mage.Sets/src/mage/cards/k/KheruSpellsnatcher.java +++ b/Mage.Sets/src/mage/cards/k/KheruSpellsnatcher.java @@ -126,8 +126,10 @@ class KheruSpellsnatcherCastFromExileEffect extends AsThoughEffectImpl { if (card != null) { if (game.getState().getZone(sourceId) == Zone.EXILED) { Player player = game.getPlayer(affectedControllerId); - player.setCastSourceIdWithAlternateMana(sourceId, null, card.getSpellAbility().getCosts()); - return true; + if(player != null) { + player.setCastSourceIdWithAlternateMana(sourceId, null, card.getSpellAbility().getCosts()); + return true; + } } else { this.discard(); } diff --git a/Mage.Sets/src/mage/cards/k/KozilekTheGreatDistortion.java b/Mage.Sets/src/mage/cards/k/KozilekTheGreatDistortion.java index 693c957fee0..9f97442b73a 100644 --- a/Mage.Sets/src/mage/cards/k/KozilekTheGreatDistortion.java +++ b/Mage.Sets/src/mage/cards/k/KozilekTheGreatDistortion.java @@ -154,9 +154,11 @@ class KozilekDiscardCost extends CostImpl { } } Player controller = game.getPlayer(ability.getControllerId()); - for (Card card : controller.getHand().getCards(game)) { - if (stackCMC.contains(card.getConvertedManaCost())) { - return true; + if(controller != null) { + for (Card card : controller.getHand().getCards(game)) { + if (stackCMC.contains(card.getConvertedManaCost())) { + return true; + } } } return false; diff --git a/Mage.Sets/src/mage/cards/l/LaquatussCreativity.java b/Mage.Sets/src/mage/cards/l/LaquatussCreativity.java index 15dd0d3026b..b2f75203a9e 100644 --- a/Mage.Sets/src/mage/cards/l/LaquatussCreativity.java +++ b/Mage.Sets/src/mage/cards/l/LaquatussCreativity.java @@ -57,9 +57,11 @@ class LaquatussCreativityEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getFirstTarget()); - int handCount = player.getHand().count(new FilterCard(), game); - player.drawCards(handCount, game); - player.discard(handCount, false, source, game); + if(player != null) { + int handCount = player.getHand().count(new FilterCard(), game); + player.drawCards(handCount, game); + player.discard(handCount, false, source, game); + } return false; } } diff --git a/Mage.Sets/src/mage/cards/l/LatNamsLegacy.java b/Mage.Sets/src/mage/cards/l/LatNamsLegacy.java index ba6f8740f50..bb16820bff5 100644 --- a/Mage.Sets/src/mage/cards/l/LatNamsLegacy.java +++ b/Mage.Sets/src/mage/cards/l/LatNamsLegacy.java @@ -55,7 +55,7 @@ class LatNamsLegacyEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (!controller.getHand().isEmpty()) { + if (controller != null && !controller.getHand().isEmpty()) { TargetCard target = new TargetCard(Zone.HAND, new FilterCard("card to shuffle into your library")); controller.choose(Outcome.Detriment, controller.getHand(), target, game); Card card = controller.getHand().get(target.getFirstTarget(), game); diff --git a/Mage.Sets/src/mage/cards/l/LayBare.java b/Mage.Sets/src/mage/cards/l/LayBare.java index c65533fe61c..14e5802710c 100644 --- a/Mage.Sets/src/mage/cards/l/LayBare.java +++ b/Mage.Sets/src/mage/cards/l/LayBare.java @@ -58,7 +58,7 @@ class LayBareEffect extends OneShotEffect { Card target = (Card) game.getLastKnownInformation(targetPointer.getFirst(game, source), Zone.STACK); if (target != null) { Player controller = game.getPlayer(target.getOwnerId()); - if (controller != null) { + if (controller != null && player != null) { player.lookAtCards("Lay Bare", controller.getHand(), game); return true; } diff --git a/Mage.Sets/src/mage/cards/l/LeechriddenSwamp.java b/Mage.Sets/src/mage/cards/l/LeechriddenSwamp.java index 3dfbf128f09..37b3ac106fc 100644 --- a/Mage.Sets/src/mage/cards/l/LeechriddenSwamp.java +++ b/Mage.Sets/src/mage/cards/l/LeechriddenSwamp.java @@ -2,6 +2,7 @@ package mage.cards.l; import java.util.UUID; + import mage.Mana; import mage.ObjectColor; import mage.abilities.Ability; @@ -26,7 +27,6 @@ import mage.players.Player; import mage.players.Players; /** - * * @author jeffwadsworth */ public final class LeechriddenSwamp extends CardImpl { @@ -38,7 +38,7 @@ public final class LeechriddenSwamp extends CardImpl { } public LeechriddenSwamp(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.LAND},""); + super(ownerId, setInfo, new CardType[]{CardType.LAND}, ""); this.subtype.add(SubType.SWAMP); // ({tap}: Add {B}.) @@ -70,28 +70,28 @@ class LeechriddenSwampLoseLifeEffect extends OneShotEffect { private static final String effectText = "each opponent loses 1 life"; - LeechriddenSwampLoseLifeEffect ( ) { + LeechriddenSwampLoseLifeEffect() { super(Outcome.Damage); - staticText = effectText; + staticText = effectText; } - LeechriddenSwampLoseLifeEffect ( LeechriddenSwampLoseLifeEffect effect ) { - super(effect); + LeechriddenSwampLoseLifeEffect(LeechriddenSwampLoseLifeEffect effect) { + super(effect); } @Override public boolean apply(Game game, Ability source) { - Players players = game.getPlayers(); - for ( Player player : players.values() ) { - if ( !player.getId().equals(source.getControllerId()) ) { + Players players = game.getPlayers(); + for (Player player : players.values()) { + if (!player.getId().equals(source.getControllerId())) { player.loseLife(1, game, false); } - } - return true; + } + return true; } @Override public LeechriddenSwampLoseLifeEffect copy() { - return new LeechriddenSwampLoseLifeEffect(this); + return new LeechriddenSwampLoseLifeEffect(this); } } diff --git a/Mage.Sets/src/mage/cards/m/MagusOfTheMind.java b/Mage.Sets/src/mage/cards/m/MagusOfTheMind.java index ba06aae6439..5ee6f042a78 100644 --- a/Mage.Sets/src/mage/cards/m/MagusOfTheMind.java +++ b/Mage.Sets/src/mage/cards/m/MagusOfTheMind.java @@ -80,7 +80,6 @@ class MagusOfTheMindEffect extends OneShotEffect { MageObject sourceObject = source.getSourceObject(game); CastSpellLastTurnWatcher watcher = (CastSpellLastTurnWatcher) game.getState().getWatchers().get(CastSpellLastTurnWatcher.class.getSimpleName()); int stormCount = watcher.getAmountOfSpellsAllPlayersCastOnCurrentTurn() + 1; - System.out.println(stormCount); if (controller != null && sourceObject != null) { controller.shuffleLibrary(source, game); if (controller.getLibrary().hasCards()) { diff --git a/Mage.Sets/src/mage/cards/m/ManaVortex.java b/Mage.Sets/src/mage/cards/m/ManaVortex.java index 9123e0c6c5f..afe645b9f6d 100644 --- a/Mage.Sets/src/mage/cards/m/ManaVortex.java +++ b/Mage.Sets/src/mage/cards/m/ManaVortex.java @@ -82,7 +82,7 @@ class CounterSourceEffect extends OneShotEffect { } if(spell != null){ Player controller = game.getPlayer(source.getControllerId()); - if(controller.chooseUse(Outcome.Detriment, "Sacrifice a land to not counter " + spell.getName() + '?', source, game)){ + if(controller != null && controller.chooseUse(Outcome.Detriment, "Sacrifice a land to not counter " + spell.getName() + '?', source, game)){ SacrificeTargetCost cost = new SacrificeTargetCost(new TargetControlledPermanent(new FilterControlledLandPermanent())); if(cost.pay(source, game, source.getSourceId(), source.getControllerId(), false, null)){ game.informPlayers(controller.getLogName() + " sacrifices a land to not counter " + spell.getName() + '.'); diff --git a/Mage.Sets/src/mage/cards/m/ManipulateFate.java b/Mage.Sets/src/mage/cards/m/ManipulateFate.java index 853220f6fe8..9603ec9d5de 100644 --- a/Mage.Sets/src/mage/cards/m/ManipulateFate.java +++ b/Mage.Sets/src/mage/cards/m/ManipulateFate.java @@ -66,16 +66,18 @@ class ManipulateFateEffect extends SearchEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - if (player.searchLibrary(target, game)) { - for (UUID targetId : getTargets()) { - Card card = player.getLibrary().getCard(targetId, game); - if (card != null) { - card.moveToExile(null, null, targetId, game); + if(player != null) { + if (player.searchLibrary(target, game)) { + for (UUID targetId : getTargets()) { + Card card = player.getLibrary().getCard(targetId, game); + if (card != null) { + card.moveToExile(null, null, targetId, game); + } } + return true; } - return true; + player.shuffleLibrary(source, game); } - player.shuffleLibrary(source, game); return false; } diff --git a/Mage.Sets/src/mage/cards/m/MasterOfTheWildHunt.java b/Mage.Sets/src/mage/cards/m/MasterOfTheWildHunt.java index c3b9f96e9e6..a4bb0aa626e 100644 --- a/Mage.Sets/src/mage/cards/m/MasterOfTheWildHunt.java +++ b/Mage.Sets/src/mage/cards/m/MasterOfTheWildHunt.java @@ -97,8 +97,10 @@ class MasterOfTheWildHuntEffect extends OneShotEffect { wolves.add(permanent.getId()); } Player player = game.getPlayer(target.getControllerId()); - player.assignDamage(target.getPower().getValue(), wolves, "Wolf", target.getId(), game); - return true; + if(player != null) { + player.assignDamage(target.getPower().getValue(), wolves, "Wolf", target.getId(), game); + return true; + } } return false; } diff --git a/Mage.Sets/src/mage/cards/m/MechanizedProduction.java b/Mage.Sets/src/mage/cards/m/MechanizedProduction.java index 5e2a63b90d1..1ed9da08de1 100644 --- a/Mage.Sets/src/mage/cards/m/MechanizedProduction.java +++ b/Mage.Sets/src/mage/cards/m/MechanizedProduction.java @@ -5,6 +5,7 @@ import java.util.HashMap; import java.util.Map; import java.util.Map.Entry; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.effects.OneShotEffect; @@ -27,7 +28,6 @@ import mage.target.common.TargetControlledPermanent; import mage.util.CardUtil; /** - * * @author LevelX2 */ public final class MechanizedProduction extends CardImpl { @@ -86,15 +86,17 @@ class MechanizedProductionEffect extends OneShotEffect { } Map countNames = new HashMap<>(); for (Permanent permanent : game.getBattlefield().getAllActivePermanents(new FilterArtifactPermanent(), source.getControllerId(), game)) { - int counter = countNames.getOrDefault(permanent.getName(),0); + int counter = countNames.getOrDefault(permanent.getName(), 0); countNames.put(permanent.getName(), counter + 1); } for (Entry entry : countNames.entrySet()) { if (entry.getValue() > 7) { Player controller = game.getPlayer(source.getControllerId()); - game.informPlayers(controller.getLogName() + " controls eight or more artifacts with the same name as one another (" + entry.getKey() + ")."); - controller.won(game); - return true; + if (controller != null) { + game.informPlayers(controller.getLogName() + " controls eight or more artifacts with the same name as one another (" + entry.getKey() + ")."); + controller.won(game); + return true; + } } } return true; diff --git a/Mage.Sets/src/mage/cards/m/MnemonicNexus.java b/Mage.Sets/src/mage/cards/m/MnemonicNexus.java index f1464aade34..8acec9890e8 100644 --- a/Mage.Sets/src/mage/cards/m/MnemonicNexus.java +++ b/Mage.Sets/src/mage/cards/m/MnemonicNexus.java @@ -50,6 +50,9 @@ class MnemonicNexusEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player sourcePlayer = game.getPlayer(source.getControllerId()); + if(sourcePlayer == null){ + return false; + } for (UUID playerId: game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { Player player = game.getPlayer(playerId); if (player != null) { diff --git a/Mage.Sets/src/mage/cards/m/MoltenInfluence.java b/Mage.Sets/src/mage/cards/m/MoltenInfluence.java index d7188dba64c..05acc1f376a 100644 --- a/Mage.Sets/src/mage/cards/m/MoltenInfluence.java +++ b/Mage.Sets/src/mage/cards/m/MoltenInfluence.java @@ -61,7 +61,7 @@ class MoltenInfluenceEffect extends OneShotEffect { if (spell != null) { Player player = game.getPlayer(spell.getControllerId()); String message = "Have Molten Influence do 4 damage to you?"; - if (player.chooseUse(Outcome.Damage, message, source, game)) { + if (player != null && player.chooseUse(Outcome.Damage, message, source, game)) { player.damage(4, source.getSourceId(), game, false, true); return true; } else { diff --git a/Mage.Sets/src/mage/cards/m/MultanisDecree.java b/Mage.Sets/src/mage/cards/m/MultanisDecree.java index 637e51995fb..1286263e5e5 100644 --- a/Mage.Sets/src/mage/cards/m/MultanisDecree.java +++ b/Mage.Sets/src/mage/cards/m/MultanisDecree.java @@ -62,7 +62,7 @@ class MultanisDecreeDestroyEffect extends OneShotEffect { enchantmentsDestoyed++; } } - if(enchantmentsDestoyed > 0) { + if(enchantmentsDestoyed > 0 && controller != null) { controller.gainLife(enchantmentsDestoyed * 2, game, source); } return false; diff --git a/Mage.Sets/src/mage/cards/m/MyojinOfNightsReach.java b/Mage.Sets/src/mage/cards/m/MyojinOfNightsReach.java index b5c642008de..9f6f424fd3c 100644 --- a/Mage.Sets/src/mage/cards/m/MyojinOfNightsReach.java +++ b/Mage.Sets/src/mage/cards/m/MyojinOfNightsReach.java @@ -74,8 +74,10 @@ class MyojinOfNightsReachEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { for (UUID opponentId : game.getOpponents(source.getControllerId())) { Player opponent = game.getPlayer(opponentId); - for (Card c : opponent.getHand().getCards(game)) { - opponent.discard(c, source, game); + if(opponent != null) { + for (Card c : opponent.getHand().getCards(game)) { + opponent.discard(c, source, game); + } } } return true; diff --git a/Mage.Sets/src/mage/cards/n/NecromancersStockpile.java b/Mage.Sets/src/mage/cards/n/NecromancersStockpile.java index 68d4e77f9b7..640496dabca 100644 --- a/Mage.Sets/src/mage/cards/n/NecromancersStockpile.java +++ b/Mage.Sets/src/mage/cards/n/NecromancersStockpile.java @@ -67,14 +67,16 @@ class NecromancersStockpileDiscardTargetCost extends CostImpl { public boolean pay(Ability ability, Game game, UUID sourceId, UUID controllerId, boolean noMana, Cost costToPay) { if (targets.choose(Outcome.Discard, controllerId, sourceId, game)) { Player player = game.getPlayer(controllerId); - for (UUID targetId : targets.get(0).getTargets()) { - Card card = player.getHand().get(targetId, game); - if (card == null) { - return false; - } - isZombieCard = card.hasSubtype(SubType.ZOMBIE, game); - paid |= player.discard(card, null, game); + if(player != null) { + for (UUID targetId : targets.get(0).getTargets()) { + Card card = player.getHand().get(targetId, game); + if (card == null) { + return false; + } + isZombieCard = card.hasSubtype(SubType.ZOMBIE, game); + paid |= player.discard(card, null, game); + } } } return paid; diff --git a/Mage.Sets/src/mage/cards/n/Necroplasm.java b/Mage.Sets/src/mage/cards/n/Necroplasm.java index 2c1b4a94438..9974d502997 100644 --- a/Mage.Sets/src/mage/cards/n/Necroplasm.java +++ b/Mage.Sets/src/mage/cards/n/Necroplasm.java @@ -81,7 +81,9 @@ class NecroplasmEffect extends OneShotEffect { FilterCreaturePermanent filter = new FilterCreaturePermanent(); filter.add(new ConvertedManaCostPredicate(ComparisonType.EQUAL_TO, numCounters)); for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game)) { - permanent.destroy(source.getSourceId(), game, false); + if(permanent != null) { + permanent.destroy(source.getSourceId(), game, false); + } } return true; } diff --git a/Mage.Sets/src/mage/cards/n/NicolBolasGodPharaoh.java b/Mage.Sets/src/mage/cards/n/NicolBolasGodPharaoh.java index af68ba9102e..ce50458307a 100644 --- a/Mage.Sets/src/mage/cards/n/NicolBolasGodPharaoh.java +++ b/Mage.Sets/src/mage/cards/n/NicolBolasGodPharaoh.java @@ -193,8 +193,10 @@ class NicolBolasGodPharaohFromExileEffect extends AsThoughEffectImpl { Card card = game.getCard(sourceId); if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) { Player player = game.getPlayer(affectedControllerId); - player.setCastSourceIdWithAlternateMana(sourceId, null, card.getSpellAbility().getCosts()); - return true; + if(player != null) { + player.setCastSourceIdWithAlternateMana(sourceId, null, card.getSpellAbility().getCosts()); + return true; + } } } return false; diff --git a/Mage.Sets/src/mage/cards/o/OpenTheVaults.java b/Mage.Sets/src/mage/cards/o/OpenTheVaults.java index b1dd78e5c4b..be29721888d 100644 --- a/Mage.Sets/src/mage/cards/o/OpenTheVaults.java +++ b/Mage.Sets/src/mage/cards/o/OpenTheVaults.java @@ -60,7 +60,8 @@ class OpenTheVaultsEffect extends OneShotEffect { if (controller != null) { LinkedHashSet cardsToReturn = new LinkedHashSet<>(); for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - Cards graveyard = game.getPlayer(playerId).getGraveyard(); + Player player = game.getPlayer(playerId); + Cards graveyard = player.getGraveyard(); for (UUID cardId : graveyard) { Card card = game.getCard(cardId); if (card != null diff --git a/Mage.Sets/src/mage/cards/o/OtherworldAtlas.java b/Mage.Sets/src/mage/cards/o/OtherworldAtlas.java index 3f49b89fe5b..660200e5888 100644 --- a/Mage.Sets/src/mage/cards/o/OtherworldAtlas.java +++ b/Mage.Sets/src/mage/cards/o/OtherworldAtlas.java @@ -62,7 +62,7 @@ class OtherworldAtlasDrawEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player sourcePlayer = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanent(source.getSourceId()); - if (permanent != null) { + if (permanent != null && sourcePlayer != null) { int amount = permanent.getCounters(game).getCount(CounterType.CHARGE); if (amount > 0) { for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { diff --git a/Mage.Sets/src/mage/cards/p/PatronOfTheVein.java b/Mage.Sets/src/mage/cards/p/PatronOfTheVein.java index 41a704dd0df..2e21f6d8c84 100644 --- a/Mage.Sets/src/mage/cards/p/PatronOfTheVein.java +++ b/Mage.Sets/src/mage/cards/p/PatronOfTheVein.java @@ -144,6 +144,9 @@ class PatronOfTheVeinExileCreatureEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); + if(controller == null){ + return false; + } MageObject sourceObject = source.getSourceObject(game); Card card = game.getCard(this.getTargetPointer().getFirst(game, source)); diff --git a/Mage.Sets/src/mage/cards/p/Phantasmagorian.java b/Mage.Sets/src/mage/cards/p/Phantasmagorian.java index 60557d6b6d8..cbb8fcb36e2 100644 --- a/Mage.Sets/src/mage/cards/p/Phantasmagorian.java +++ b/Mage.Sets/src/mage/cards/p/Phantasmagorian.java @@ -75,7 +75,8 @@ class CounterSourceEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) { Player player = game.getPlayer(playerId); cost.clearPaid(); - if (cost.canPay(source, source.getSourceId(), player.getId(), game) + if (player != null + && cost.canPay(source, source.getSourceId(), player.getId(), game) && player.chooseUse(outcome, "Discard three cards to counter " + sourceObject.getIdName() + '?', source, game)) { if (cost.pay(source, game, source.getSourceId(), playerId, false, null)) { game.informPlayers(player.getLogName() + " discards 3 cards to counter " + sourceObject.getIdName() + '.'); diff --git a/Mage.Sets/src/mage/cards/p/PhyrexianPurge.java b/Mage.Sets/src/mage/cards/p/PhyrexianPurge.java index f6860e52d4e..da92e7b58a4 100644 --- a/Mage.Sets/src/mage/cards/p/PhyrexianPurge.java +++ b/Mage.Sets/src/mage/cards/p/PhyrexianPurge.java @@ -43,8 +43,10 @@ public final class PhyrexianPurge extends CardImpl { if (ability instanceof SpellAbility) { ability.getTargets().clear(); Player you = game.getPlayer(ownerId); - int maxTargets = you.getLife() / 3; - ability.addTarget(new TargetCreaturePermanent(0, maxTargets)); + if(you != null) { + int maxTargets = you.getLife() / 3; + ability.addTarget(new TargetCreaturePermanent(0, maxTargets)); + } } } diff --git a/Mage.Sets/src/mage/cards/p/PirsWhim.java b/Mage.Sets/src/mage/cards/p/PirsWhim.java index 09ea5499bbb..9ff41c79c64 100644 --- a/Mage.Sets/src/mage/cards/p/PirsWhim.java +++ b/Mage.Sets/src/mage/cards/p/PirsWhim.java @@ -64,7 +64,7 @@ class PirsWhimEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); ChooseFriendsAndFoes choice = new ChooseFriendsAndFoes(); - if (!choice.chooseFriendOrFoe(controller, source, game)) { + if (controller != null && !choice.chooseFriendOrFoe(controller, source, game)) { return false; } for (Player player : choice.getFriends()) { diff --git a/Mage.Sets/src/mage/cards/p/PossessedPortal.java b/Mage.Sets/src/mage/cards/p/PossessedPortal.java index e20da683ba0..c970a34258d 100644 --- a/Mage.Sets/src/mage/cards/p/PossessedPortal.java +++ b/Mage.Sets/src/mage/cards/p/PossessedPortal.java @@ -101,7 +101,7 @@ class PossessedPortalEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player = game.getPlayer(playerId); Cost discardCost = new DiscardCardCost(); - if (discardCost.canPay(source, source.getSourceId(), playerId, game) + if (player != null && discardCost.canPay(source, source.getSourceId(), playerId, game) && player.chooseUse(Outcome.Discard, "Discard a card? (Otherwise sacrifice a permanent)", source, game)) { discardCost.pay(source, game, source.getSourceId(), playerId, true, null); } diff --git a/Mage.Sets/src/mage/cards/p/PreeminentCaptain.java b/Mage.Sets/src/mage/cards/p/PreeminentCaptain.java index 552d957cb2b..9207889fda4 100644 --- a/Mage.Sets/src/mage/cards/p/PreeminentCaptain.java +++ b/Mage.Sets/src/mage/cards/p/PreeminentCaptain.java @@ -71,7 +71,7 @@ class PreeminentCaptainEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); TargetCardInHand target = new TargetCardInHand(filter); - if (target.canChoose(controller.getId(), game) + if (controller != null && target.canChoose(controller.getId(), game) && target.choose(getOutcome(), controller.getId(), source.getSourceId(), game)) { if (!target.getTargets().isEmpty()) { UUID cardId = target.getFirstTarget(); diff --git a/Mage.Sets/src/mage/cards/p/PsychicVortex.java b/Mage.Sets/src/mage/cards/p/PsychicVortex.java index 9cf553a4ed1..31cd032e07d 100644 --- a/Mage.Sets/src/mage/cards/p/PsychicVortex.java +++ b/Mage.Sets/src/mage/cards/p/PsychicVortex.java @@ -72,7 +72,7 @@ class PsychicVortexCost extends CostImpl { @Override public boolean canPay(Ability ability, UUID sourceId, UUID controllerId, Game game) { Player controller = game.getPlayer(controllerId); - return controller.getLibrary().hasCards(); + return controller != null && controller.getLibrary().hasCards(); } @Override diff --git a/Mage.Sets/src/mage/cards/r/Ransack.java b/Mage.Sets/src/mage/cards/r/Ransack.java index 32e69f711fe..4fe3889c39d 100644 --- a/Mage.Sets/src/mage/cards/r/Ransack.java +++ b/Mage.Sets/src/mage/cards/r/Ransack.java @@ -73,7 +73,7 @@ class RansackEffect extends OneShotEffect { Set cards = player.getLibrary().getTopCards(game, number); Cards cardsRemaining = new CardsImpl(); cardsRemaining.addAll(cards); - TargetCard target = new TargetCard((true ? 0 : number), number, Zone.LIBRARY, filter); + TargetCard target = new TargetCard(0, number, Zone.LIBRARY, filter); if (player.choose(Outcome.DrawCard, cardsRemaining, target, game)) { Cards pickedCards = new CardsImpl(target.getTargets()); cardsRemaining.removeAll(pickedCards); diff --git a/Mage.Sets/src/mage/cards/r/RaziasPurification.java b/Mage.Sets/src/mage/cards/r/RaziasPurification.java index 56ba6553e55..dc9c802b808 100644 --- a/Mage.Sets/src/mage/cards/r/RaziasPurification.java +++ b/Mage.Sets/src/mage/cards/r/RaziasPurification.java @@ -61,7 +61,7 @@ class RaziasPurificationEffect extends OneShotEffect { Target target1 = new TargetControlledPermanent(1, 1, new FilterControlledPermanent(), true); - if (target1.canChoose(player.getId(), game)) { + if (player != null && target1.canChoose(player.getId(), game)) { int chosenPermanents = 0; while (player.canRespond() && !target1.isChosen() && target1.canChoose(player.getId(), game) && chosenPermanents < 3) { player.chooseTarget(Outcome.Benefit, target1, source, game); diff --git a/Mage.Sets/src/mage/cards/r/RegnaTheRedeemer.java b/Mage.Sets/src/mage/cards/r/RegnaTheRedeemer.java index 12dd708519e..adcf7f0b302 100644 --- a/Mage.Sets/src/mage/cards/r/RegnaTheRedeemer.java +++ b/Mage.Sets/src/mage/cards/r/RegnaTheRedeemer.java @@ -79,7 +79,7 @@ class RegnaTheRedeemerCondition extends IntCompareCondition { if (watcher != null) { for (UUID playerId : game.getPlayerList()) { Player player = game.getPlayer(playerId); - if (!player.hasOpponent(source.getControllerId(), game)) { + if (player != null && !player.hasOpponent(source.getControllerId(), game)) { gainedLife = watcher.getLiveGained(playerId); if (gainedLife > 0) { break; diff --git a/Mage.Sets/src/mage/cards/r/RegnasSanction.java b/Mage.Sets/src/mage/cards/r/RegnasSanction.java index fef3d117ba1..3ea9507512b 100644 --- a/Mage.Sets/src/mage/cards/r/RegnasSanction.java +++ b/Mage.Sets/src/mage/cards/r/RegnasSanction.java @@ -2,6 +2,7 @@ package mage.cards.r; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.common.TapAllEffect; @@ -22,7 +23,6 @@ import mage.players.Player; import mage.target.TargetPermanent; /** - * * @author TheElk801 */ public final class RegnasSanction extends CardImpl { @@ -64,7 +64,7 @@ class RegnasSanctionEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); ChooseFriendsAndFoes choice = new ChooseFriendsAndFoes(); - if (!choice.chooseFriendOrFoe(controller, source, game)) { + if (controller != null || !choice.chooseFriendOrFoe(controller, source, game)) { return false; } FilterCreaturePermanent filterToTap = new FilterCreaturePermanent(); diff --git a/Mage.Sets/src/mage/cards/r/Retribution.java b/Mage.Sets/src/mage/cards/r/Retribution.java index 2c0a7214ad3..274f71fd506 100644 --- a/Mage.Sets/src/mage/cards/r/Retribution.java +++ b/Mage.Sets/src/mage/cards/r/Retribution.java @@ -68,7 +68,7 @@ class RetributionEffect extends OneShotEffect { Permanent creature = game.getPermanent(targetId); if (creature != null) { Player controllerOfCreature = game.getPlayer(creature.getControllerId()); - if ((count == 0 + if ((count == 0 && controllerOfCreature != null && controllerOfCreature.chooseUse(Outcome.Sacrifice, "Sacrifice " + creature.getLogName() + '?', source, game)) || (count == 1 && !sacrificeDone)) { diff --git a/Mage.Sets/src/mage/cards/s/SanctumPrelate.java b/Mage.Sets/src/mage/cards/s/SanctumPrelate.java index 5fcd464ced4..9cb660d8c83 100644 --- a/Mage.Sets/src/mage/cards/s/SanctumPrelate.java +++ b/Mage.Sets/src/mage/cards/s/SanctumPrelate.java @@ -2,6 +2,7 @@ package mage.cards.s; import java.util.UUID; + import mage.MageInt; import mage.MageObject; import mage.abilities.Ability; @@ -19,13 +20,12 @@ import mage.game.stack.Spell; import mage.players.Player; /** - * * @author maxlebedev */ public final class SanctumPrelate extends CardImpl { public SanctumPrelate(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{W}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{W}{W}"); this.subtype.add(SubType.HUMAN); this.subtype.add(SubType.CLERIC); this.power = new MageInt(2); @@ -62,15 +62,17 @@ class ChooseNumberEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + int numberChoice = controller.announceXMana(0, Integer.MAX_VALUE, "Choose a number. Noncreature spells with the chosen converted mana cost can't be cast", game, source); + game.getState().setValue(source.getSourceId().toString(), numberChoice); - int numberChoice = controller.announceXMana(0, Integer.MAX_VALUE, "Choose a number. Noncreature spells with the chosen converted mana cost can't be cast", game, source); - game.getState().setValue(source.getSourceId().toString(), numberChoice); - - Permanent permanent = game.getPermanentEntering(source.getSourceId()); - permanent.addInfo("chosen players", "Chosen Number: "+ numberChoice +"", game); - - game.informPlayers(permanent.getLogName() + ", chosen number: "+numberChoice); + Permanent permanent = game.getPermanentEntering(source.getSourceId()); + if(permanent != null) { + permanent.addInfo("chosen players", "Chosen Number: " + numberChoice + "", game); + game.informPlayers(permanent.getLogName() + ", chosen number: " + numberChoice); + } + } return true; } @@ -87,6 +89,7 @@ class ChooseNumberEffect extends OneShotEffect { class SanctumPrelateReplacementEffect extends ContinuousRuleModifyingEffectImpl { Integer choiceValue; + public SanctumPrelateReplacementEffect() { super(Duration.WhileOnBattlefield, Outcome.Detriment); staticText = "Noncreature spells with the chosen converted mana cost can't be cast"; @@ -124,8 +127,8 @@ class SanctumPrelateReplacementEffect extends ContinuousRuleModifyingEffectImpl public boolean applies(GameEvent event, Ability source, Game game) { choiceValue = (Integer) game.getState().getValue(source.getSourceId().toString()); Spell spell = game.getStack().getSpell(event.getTargetId()); - - if (spell != null && !spell.isCreature()){ + + if (spell != null && !spell.isCreature()) { return spell.getConvertedManaCost() == choiceValue; } return false; diff --git a/Mage.Sets/src/mage/cards/s/SarkhanTheMad.java b/Mage.Sets/src/mage/cards/s/SarkhanTheMad.java index 921f4fd270b..9fdeaddc8b8 100644 --- a/Mage.Sets/src/mage/cards/s/SarkhanTheMad.java +++ b/Mage.Sets/src/mage/cards/s/SarkhanTheMad.java @@ -119,10 +119,13 @@ class SarkhanTheMadSacEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent permanent = game.getPermanent(source.getTargets().getFirstTarget()); if (permanent != null) { - Player player = game.getPlayer(permanent.getControllerId()); permanent.sacrifice(this.getId(), game); - Token dragonToken = new DragonToken2(); - dragonToken.putOntoBattlefield(1, game, this.getId(), player.getId()); + + Player player = game.getPlayer(permanent.getControllerId()); + if(player != null) { + Token dragonToken = new DragonToken2(); + dragonToken.putOntoBattlefield(1, game, this.getId(), player.getId()); + } } return false; } diff --git a/Mage.Sets/src/mage/cards/s/ScribNibblers.java b/Mage.Sets/src/mage/cards/s/ScribNibblers.java index 93806d4abd1..8b47ffbf42f 100644 --- a/Mage.Sets/src/mage/cards/s/ScribNibblers.java +++ b/Mage.Sets/src/mage/cards/s/ScribNibblers.java @@ -75,7 +75,7 @@ class ScribNibblersEffect extends OneShotEffect { if (targetPlayer != null && targetPlayer.getLibrary().hasCards()) { Card card = targetPlayer.getLibrary().getFromTop(game); card.moveToExile(id, "Scrib Nibblers Exile", source.getSourceId(), game); - if (card.isLand()) { + if (card.isLand() && you != null) { you.gainLife(1, game, source); return true; } diff --git a/Mage.Sets/src/mage/cards/s/SeasonOfTheWitch.java b/Mage.Sets/src/mage/cards/s/SeasonOfTheWitch.java index 35cc67e2c3e..fcde9f08880 100644 --- a/Mage.Sets/src/mage/cards/s/SeasonOfTheWitch.java +++ b/Mage.Sets/src/mage/cards/s/SeasonOfTheWitch.java @@ -124,6 +124,9 @@ class CouldAttackThisTurnWatcher extends Watcher { public void watch(GameEvent event, Game game) { if (event.getType() == GameEvent.EventType.DECLARE_ATTACKERS_STEP_PRE) { Player activePlayer = game.getPlayer(game.getActivePlayerId()); + if(activePlayer == null){ + return; + } for (Permanent permanent : game.getBattlefield().getAllActivePermanents(activePlayer.getId())) { if (permanent.isCreature()) { for (UUID defender : game.getCombat().getDefenders()) { diff --git a/Mage.Sets/src/mage/cards/s/SeeBeyond.java b/Mage.Sets/src/mage/cards/s/SeeBeyond.java index 45be2d1d1dd..74728b840cc 100644 --- a/Mage.Sets/src/mage/cards/s/SeeBeyond.java +++ b/Mage.Sets/src/mage/cards/s/SeeBeyond.java @@ -52,17 +52,19 @@ class SeeBeyondEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - controller.drawCards(2, game); - if (!controller.getHand().isEmpty()) { - TargetCard target = new TargetCard(Zone.HAND, new FilterCard("card to shuffle into your library")); - controller.choose(Outcome.Detriment, controller.getHand(), target, game); - Card card = controller.getHand().get(target.getFirstTarget(), game); - if (card != null) { - controller.moveCards(card, Zone.LIBRARY, source, game); - controller.shuffleLibrary(source, game); - } - return true; + if(controller != null) { + controller.drawCards(2, game); + if (!controller.getHand().isEmpty()) { + TargetCard target = new TargetCard(Zone.HAND, new FilterCard("card to shuffle into your library")); + controller.choose(Outcome.Detriment, controller.getHand(), target, game); + Card card = controller.getHand().get(target.getFirstTarget(), game); + if (card != null) { + controller.moveCards(card, Zone.LIBRARY, source, game); + controller.shuffleLibrary(source, game); + } + return true; + } } return true; } diff --git a/Mage.Sets/src/mage/cards/s/SeedsOfInnocence.java b/Mage.Sets/src/mage/cards/s/SeedsOfInnocence.java index 4c704e23e46..d5eb50421e7 100644 --- a/Mage.Sets/src/mage/cards/s/SeedsOfInnocence.java +++ b/Mage.Sets/src/mage/cards/s/SeedsOfInnocence.java @@ -61,7 +61,9 @@ class SeedsOfInnocenceEffect extends OneShotEffect { Player artifactController = game.getPlayer(artifact.getControllerId()); int cmc = artifact.getConvertedManaCost(); if (artifact.destroy(source.getSourceId(), game, true)) { - artifactController.gainLife(cmc, game, source); + if(artifactController != null) { + artifactController.gainLife(cmc, game, source); + } } } return true; diff --git a/Mage.Sets/src/mage/cards/s/SelvalaHeartOfTheWilds.java b/Mage.Sets/src/mage/cards/s/SelvalaHeartOfTheWilds.java index 34e2daf97d8..8b1325c6187 100644 --- a/Mage.Sets/src/mage/cards/s/SelvalaHeartOfTheWilds.java +++ b/Mage.Sets/src/mage/cards/s/SelvalaHeartOfTheWilds.java @@ -133,31 +133,4 @@ class GreatestPowerPredicate implements Predicate { public String toString() { return "Greatest Power"; } -} - -class GreatestPowerYouControlValue implements DynamicValue { - - @Override - public int calculate(Game game, Ability sourceAbility, Effect effect) { - Player player = game.getPlayer(sourceAbility.getControllerId()); - int amount = 0; - if (player != null) { - for (Permanent permanent : game.getBattlefield().getActivePermanents(new FilterControlledCreaturePermanent(), sourceAbility.getControllerId(), game)) { - if (permanent.getPower().getValue() > amount) { - amount = permanent.getPower().getValue(); - } - } - } - return amount; - } - - @Override - public DynamicValue copy() { - return new GreatestPowerYouControlValue(); - } - - @Override - public String getMessage() { - return "Add X mana in any combination of colors, where X is the greatest power among creatures you control."; - } -} +} \ No newline at end of file diff --git a/Mage.Sets/src/mage/cards/s/SemblanceAnvil.java b/Mage.Sets/src/mage/cards/s/SemblanceAnvil.java index 34372611f2f..4b6a0acc3f2 100644 --- a/Mage.Sets/src/mage/cards/s/SemblanceAnvil.java +++ b/Mage.Sets/src/mage/cards/s/SemblanceAnvil.java @@ -62,7 +62,7 @@ class SemblanceAnvilEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); - if (!player.getHand().isEmpty()) { + if (player != null && !player.getHand().isEmpty()) { TargetCard target = new TargetCard(Zone.HAND, filter); player.choose(Outcome.Benefit, player.getHand(), target, game); Card card = player.getHand().get(target.getFirstTarget(), game); diff --git a/Mage.Sets/src/mage/cards/s/SharedFate.java b/Mage.Sets/src/mage/cards/s/SharedFate.java index 6f581fac8fb..af6e235b33c 100644 --- a/Mage.Sets/src/mage/cards/s/SharedFate.java +++ b/Mage.Sets/src/mage/cards/s/SharedFate.java @@ -133,7 +133,7 @@ class SharedFatePlayEffect extends AsThoughEffectImpl { if (exileId != null) { ExileZone exileZone = game.getExile().getExileZone(exileId); if (exileZone != null && exileZone.contains(objectId)) { - if (player.chooseUse(outcome, "Play " + game.getCard(objectId).getIdName() + '?', source, game)) { + if (player != null && player.chooseUse(outcome, "Play " + game.getCard(objectId).getIdName() + '?', source, game)) { return true; } } diff --git a/Mage.Sets/src/mage/cards/s/ShiftyDoppelganger.java b/Mage.Sets/src/mage/cards/s/ShiftyDoppelganger.java index 79ea220f12f..c73a0b3f5bf 100644 --- a/Mage.Sets/src/mage/cards/s/ShiftyDoppelganger.java +++ b/Mage.Sets/src/mage/cards/s/ShiftyDoppelganger.java @@ -81,7 +81,7 @@ class ShiftyDoppelgangerExileEffect extends OneShotEffect { boolean putCreature = false; UUID creatureId = UUID.randomUUID(); Player player = game.getPlayer(source.getControllerId()); - if (player.chooseUse(Outcome.PutCardInPlay, "Put " + filter.getMessage() + " from your hand onto the battlefield?", source, game)) { + if (player != null && player.chooseUse(Outcome.PutCardInPlay, "Put " + filter.getMessage() + " from your hand onto the battlefield?", source, game)) { TargetCardInHand target = new TargetCardInHand(filter); if (player.choose(Outcome.PutCreatureInPlay, target, source.getSourceId(), game)) { Card card = game.getCard(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/s/SinsOfThePast.java b/Mage.Sets/src/mage/cards/s/SinsOfThePast.java index 8e86dc46890..21aa8edb355 100644 --- a/Mage.Sets/src/mage/cards/s/SinsOfThePast.java +++ b/Mage.Sets/src/mage/cards/s/SinsOfThePast.java @@ -100,8 +100,10 @@ class SinsOfThePastCastFromGraveyardEffect extends AsThoughEffectImpl { public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) { if (sourceId.equals(this.getTargetPointer().getFirst(game, source)) && affectedControllerId.equals(source.getControllerId())) { Player player = game.getPlayer(affectedControllerId); - player.setCastSourceIdWithAlternateMana(sourceId, null, null); - return true; + if(player != null) { + player.setCastSourceIdWithAlternateMana(sourceId, null, null); + return true; + } } return false; } diff --git a/Mage.Sets/src/mage/cards/s/SkullStorm.java b/Mage.Sets/src/mage/cards/s/SkullStorm.java index 164cf6e3033..5f1d8d884f8 100644 --- a/Mage.Sets/src/mage/cards/s/SkullStorm.java +++ b/Mage.Sets/src/mage/cards/s/SkullStorm.java @@ -65,13 +65,13 @@ class SkullStormEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { game.getOpponents(source.getControllerId()).forEach((playerId) -> { Player player = game.getPlayer(playerId); - if (!(player == null)) { + if (player != null) { FilterPermanent filter = new FilterCreaturePermanent(); filter.add(new ControllerIdPredicate(playerId)); if (game.getBattlefield().getActivePermanents( filter, source.getControllerId(), game ).isEmpty()) { - int lifeToLose = (int) Math.ceil(player.getLife() / 2); + int lifeToLose = (int) Math.ceil(player.getLife() / 2f); player.loseLife(lifeToLose, game, false); } else { Effect effect = new SacrificeEffect( diff --git a/Mage.Sets/src/mage/cards/s/SlaveringNulls.java b/Mage.Sets/src/mage/cards/s/SlaveringNulls.java index c1a9958c7dd..5cdd25f835a 100644 --- a/Mage.Sets/src/mage/cards/s/SlaveringNulls.java +++ b/Mage.Sets/src/mage/cards/s/SlaveringNulls.java @@ -81,7 +81,7 @@ class SlaveringNullsTriggeredAbility extends TriggeredAbilityImpl { if (game.getBattlefield().countAll(filter, controllerId, game) > 0) { Permanent slaveringNulls = game.getPermanent(event.getSourceId()); Player player = game.getPlayer(event.getTargetId()); - if (slaveringNulls != null) { + if (slaveringNulls != null && player != null) { Effect effect = this.getEffects().get(0); effect.setTargetPointer(new FixedTarget(player.getId())); return true; diff --git a/Mage.Sets/src/mage/cards/s/SoltariGuerrillas.java b/Mage.Sets/src/mage/cards/s/SoltariGuerrillas.java index 6d45a47b12f..7d9fed18c70 100644 --- a/Mage.Sets/src/mage/cards/s/SoltariGuerrillas.java +++ b/Mage.Sets/src/mage/cards/s/SoltariGuerrillas.java @@ -2,6 +2,7 @@ package mage.cards.s; import java.util.UUID; + import mage.MageInt; import mage.abilities.Ability; import mage.abilities.common.SimpleActivatedAbility; @@ -23,13 +24,12 @@ import mage.players.Player; import mage.target.common.TargetCreaturePermanent; /** - * * @author LevelX2 */ public final class SoltariGuerrillas extends CardImpl { public SoltariGuerrillas(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{R}{W}"); + super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{R}{W}"); this.subtype.add(SubType.SOLTARI); this.subtype.add(SubType.SOLDIER); this.power = new MageInt(3); @@ -67,14 +67,16 @@ class SoltariGuerrillasReplacementEffect extends PreventionEffectImpl { @Override public boolean checksEventType(GameEvent event, Game game) { - return event.getType() == GameEvent.EventType.DAMAGE_PLAYER; + return event.getType() == GameEvent.EventType.DAMAGE_PLAYER; } @Override public boolean applies(GameEvent event, Ability source, Game game) { if (event.getSourceId().equals(source.getSourceId())) { Player controller = game.getPlayer(source.getControllerId()); - return controller.hasOpponent(event.getTargetId(), game); + if (controller != null) { + return controller.hasOpponent(event.getTargetId(), game); + } } return false; } diff --git a/Mage.Sets/src/mage/cards/s/SpellboundDragon.java b/Mage.Sets/src/mage/cards/s/SpellboundDragon.java index 49b588390f0..e7f03140a9a 100644 --- a/Mage.Sets/src/mage/cards/s/SpellboundDragon.java +++ b/Mage.Sets/src/mage/cards/s/SpellboundDragon.java @@ -70,15 +70,17 @@ class SpellboundDragonEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player you = game.getPlayer(source.getControllerId()); Permanent dragon = game.getPermanent(source.getSourceId()); - you.drawCards(1, game); - TargetDiscard target = new TargetDiscard(you.getId()); - you.choose(Outcome.Discard, target, source.getSourceId(), game); - Card card = you.getHand().get(target.getFirstTarget(), game); - if (card != null && you.discard(card, source, game)) { - int cmc = card.getConvertedManaCost(); - if (dragon != null) { - game.addEffect(new BoostSourceEffect(cmc, 0, Duration.EndOfTurn), source); - return true; + if(you != null) { + you.drawCards(1, game); + TargetDiscard target = new TargetDiscard(you.getId()); + you.choose(Outcome.Discard, target, source.getSourceId(), game); + Card card = you.getHand().get(target.getFirstTarget(), game); + if (card != null && you.discard(card, source, game)) { + int cmc = card.getConvertedManaCost(); + if (dragon != null) { + game.addEffect(new BoostSourceEffect(cmc, 0, Duration.EndOfTurn), source); + return true; + } } } return false; diff --git a/Mage.Sets/src/mage/cards/s/Spelljack.java b/Mage.Sets/src/mage/cards/s/Spelljack.java index 5a752d2c047..f966eb20915 100644 --- a/Mage.Sets/src/mage/cards/s/Spelljack.java +++ b/Mage.Sets/src/mage/cards/s/Spelljack.java @@ -115,7 +115,9 @@ class SpelljackCastFromExileEffect extends AsThoughEffectImpl { if (card != null) { if (game.getState().getZone(sourceId) == Zone.EXILED) { Player player = game.getPlayer(affectedControllerId); - player.setCastSourceIdWithAlternateMana(sourceId, null, null); + if(player != null) { + player.setCastSourceIdWithAlternateMana(sourceId, null, null); + } return true; } else { this.discard(); diff --git a/Mage.Sets/src/mage/cards/s/SphinxOfTheChimes.java b/Mage.Sets/src/mage/cards/s/SphinxOfTheChimes.java index 5647a877043..5d81e776167 100644 --- a/Mage.Sets/src/mage/cards/s/SphinxOfTheChimes.java +++ b/Mage.Sets/src/mage/cards/s/SphinxOfTheChimes.java @@ -91,6 +91,9 @@ class TargetTwoNonLandCardsWithSameNameInHand extends TargetCardInHand { Set newPossibleTargets = new HashSet<>(); Set possibleTargets = new HashSet<>(); Player player = game.getPlayer(sourceControllerId); + if(player == null){ + return newPossibleTargets; + } for (Card card : player.getHand().getCards(filter, game)) { possibleTargets.add(card.getId()); } @@ -126,6 +129,9 @@ class TargetTwoNonLandCardsWithSameNameInHand extends TargetCardInHand { public boolean canChoose(UUID sourceControllerId, Game game) { Cards cardsToCheck = new CardsImpl(); Player player = game.getPlayer(sourceControllerId); + if(player == null){ + return false; + } for (Card card : player.getHand().getCards(filter, game)) { cardsToCheck.add(card.getId()); } @@ -154,7 +160,7 @@ class TargetTwoNonLandCardsWithSameNameInHand extends TargetCardInHand { FilterCard nameFilter = new FilterCard(); nameFilter.add(new NamePredicate(card.isSplitCard() ? ((SplitCard) card).getLeftHalfCard().getName() : card.getName())); Player player = game.getPlayer(card.getOwnerId()); - if (player.getHand().getCards(nameFilter, game).size() > 1) { + if (player != null && player.getHand().getCards(nameFilter, game).size() > 1) { return true; } } diff --git a/Mage.Sets/src/mage/cards/s/SquanderedResources.java b/Mage.Sets/src/mage/cards/s/SquanderedResources.java index 08222b4d801..9a51bf738ab 100644 --- a/Mage.Sets/src/mage/cards/s/SquanderedResources.java +++ b/Mage.Sets/src/mage/cards/s/SquanderedResources.java @@ -108,6 +108,9 @@ class SquanderedResourcesEffect extends ManaEffect { Mana mana = new Mana(); if (!choice.getChoices().isEmpty()) { Player player = game.getPlayer(source.getControllerId()); + if(player == null){ + return mana; + } if (choice.getChoices().size() == 1) { choice.setChoice(choice.getChoices().iterator().next()); } else { diff --git a/Mage.Sets/src/mage/cards/s/StandOrFall.java b/Mage.Sets/src/mage/cards/s/StandOrFall.java index 8bdbcefd8fa..923722f51b4 100644 --- a/Mage.Sets/src/mage/cards/s/StandOrFall.java +++ b/Mage.Sets/src/mage/cards/s/StandOrFall.java @@ -84,7 +84,7 @@ class StandOrFallEffect extends OneShotEffect { Player targetPlayer = game.getPlayer(opponents.iterator().next()); if (opponents.size() > 1) { TargetOpponent targetOpponent = new TargetOpponent(true); - if (player.chooseTarget(Outcome.Neutral, targetOpponent, source, game)) { + if (player != null && player.chooseTarget(Outcome.Neutral, targetOpponent, source, game)) { targetPlayer = game.getPlayer(targetOpponent.getFirstTarget()); game.informPlayers(player.getLogName() + " chose " + targetPlayer.getLogName() + " as the defending player"); } diff --git a/Mage.Sets/src/mage/cards/s/StarCompass.java b/Mage.Sets/src/mage/cards/s/StarCompass.java index 707f2203082..1cca2f5b2ee 100644 --- a/Mage.Sets/src/mage/cards/s/StarCompass.java +++ b/Mage.Sets/src/mage/cards/s/StarCompass.java @@ -103,6 +103,9 @@ class StarCompassManaEffect extends ManaEffect { } if (!choice.getChoices().isEmpty()) { Player player = game.getPlayer(source.getControllerId()); + if(player == null){ + return false; + } if (choice.getChoices().size() == 1) { choice.setChoice(choice.getChoices().iterator().next()); } else { @@ -175,6 +178,9 @@ class StarCompassManaEffect extends ManaEffect { } if (!choice.getChoices().isEmpty()) { Player player = game.getPlayer(source.getControllerId()); + if(player == null){ + return null; + } if (choice.getChoices().size() == 1) { choice.setChoice(choice.getChoices().iterator().next()); } else { diff --git a/Mage.Sets/src/mage/cards/s/SteamVines.java b/Mage.Sets/src/mage/cards/s/SteamVines.java index 3ea35f78e8b..5861920b9bc 100644 --- a/Mage.Sets/src/mage/cards/s/SteamVines.java +++ b/Mage.Sets/src/mage/cards/s/SteamVines.java @@ -85,7 +85,9 @@ class SteamVinesEffect extends OneShotEffect { Player landsController = game.getPlayer(enchantedLand.getControllerId()); if (game.getState().getZone(enchantedLand.getId()) == Zone.BATTLEFIELD) { // if 2 or more Steam Vines were on a land enchantedLand.destroy(source.getId(), game, false); - landsController.damage(1, source.getSourceId(), game, false, true); + if(landsController != null) { + landsController.damage(1, source.getSourceId(), game, false, true); + } } if (!game.getBattlefield().getAllActivePermanents(CardType.LAND).isEmpty()) { //lands are available on the battlefield Target target = new TargetLandPermanent(); diff --git a/Mage.Sets/src/mage/cards/s/StolenGoods.java b/Mage.Sets/src/mage/cards/s/StolenGoods.java index 2341ff2fa60..578d83d51f7 100644 --- a/Mage.Sets/src/mage/cards/s/StolenGoods.java +++ b/Mage.Sets/src/mage/cards/s/StolenGoods.java @@ -2,6 +2,7 @@ package mage.cards.s; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.effects.AsThoughEffectImpl; import mage.abilities.effects.ContinuousEffect; @@ -21,7 +22,6 @@ import mage.target.targetpointer.FixedTarget; import mage.util.CardUtil; /** - * * @author noxx */ public final class StolenGoods extends CardImpl { @@ -111,8 +111,10 @@ class StolenGoodsCastFromExileEffect extends AsThoughEffectImpl { Card card = game.getCard(sourceId); if (card != null && game.getState().getZone(sourceId) == Zone.EXILED) { Player player = game.getPlayer(affectedControllerId); - player.setCastSourceIdWithAlternateMana(sourceId, null, card.getSpellAbility().getCosts()); - return true; + if (player != null) { + player.setCastSourceIdWithAlternateMana(sourceId, null, card.getSpellAbility().getCosts()); + return true; + } } } return false; diff --git a/Mage.Sets/src/mage/cards/s/StruggleSurvive.java b/Mage.Sets/src/mage/cards/s/StruggleSurvive.java index 5eb205a59b5..10e45160ed7 100644 --- a/Mage.Sets/src/mage/cards/s/StruggleSurvive.java +++ b/Mage.Sets/src/mage/cards/s/StruggleSurvive.java @@ -69,13 +69,17 @@ class SurviveEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player sourcePlayer = game.getPlayer(source.getControllerId()); - for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { - Player player = game.getPlayer(playerId); - if (player != null) { - for (Card card : player.getGraveyard().getCards(game)) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + if(sourcePlayer != null) { + for (UUID playerId : game.getState().getPlayersInRange(sourcePlayer.getId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + for (Card card : player.getGraveyard().getCards(game)) { + if(card != null) { + card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + } + } + player.shuffleLibrary(source, game); } - player.shuffleLibrary(source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/s/SuturedGhoul.java b/Mage.Sets/src/mage/cards/s/SuturedGhoul.java index 0a79824eacf..1bca0b01575 100644 --- a/Mage.Sets/src/mage/cards/s/SuturedGhoul.java +++ b/Mage.Sets/src/mage/cards/s/SuturedGhoul.java @@ -78,7 +78,7 @@ class SuturedGhoulEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); Permanent permanent = game.getPermanentEntering(source.getSourceId()); - if (permanent == null) { + if (permanent == null || controller == null) { return false; } if (!controller.getGraveyard().isEmpty()) { diff --git a/Mage.Sets/src/mage/cards/s/SwansOfBrynArgoll.java b/Mage.Sets/src/mage/cards/s/SwansOfBrynArgoll.java index 728dbe7a809..c97e5c43383 100644 --- a/Mage.Sets/src/mage/cards/s/SwansOfBrynArgoll.java +++ b/Mage.Sets/src/mage/cards/s/SwansOfBrynArgoll.java @@ -79,17 +79,23 @@ class SwansOfBrynArgollEffect extends PreventionEffectImpl { CommandObject emblem = (CommandObject)game.getEmblem(sourceOfDamage.getId()); if (spell != null) { Player controllerOfSpell = game.getPlayer(spell.getControllerId()); - controllerOfSpell.drawCards(preventionEffectData.getPreventedDamage(), game); - passed = true; + if(controllerOfSpell != null) { + controllerOfSpell.drawCards(preventionEffectData.getPreventedDamage(), game); + passed = true; + } } if (permanent != null) { Player controllerOfPermanent = game.getPlayer(permanent.getControllerId()); - controllerOfPermanent.drawCards(preventionEffectData.getPreventedDamage(), game); - passed = true; + if(controllerOfPermanent != null) { + controllerOfPermanent.drawCards(preventionEffectData.getPreventedDamage(), game); + passed = true; + } } if (emblem != null) { Player controllerOfEmblem = game.getPlayer(emblem.getControllerId()); - controllerOfEmblem.drawCards(preventionEffectData.getPreventedDamage(), game); + if(controllerOfEmblem != null) { + controllerOfEmblem.drawCards(preventionEffectData.getPreventedDamage(), game); + } passed = true; } if (!passed) { diff --git a/Mage.Sets/src/mage/cards/s/SwayOfTheStars.java b/Mage.Sets/src/mage/cards/s/SwayOfTheStars.java index 12282fe8e7c..7379681a6eb 100644 --- a/Mage.Sets/src/mage/cards/s/SwayOfTheStars.java +++ b/Mage.Sets/src/mage/cards/s/SwayOfTheStars.java @@ -2,6 +2,7 @@ package mage.cards.s; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.effects.Effect; import mage.abilities.effects.OneShotEffect; @@ -19,13 +20,12 @@ import mage.game.permanent.Permanent; import mage.players.Player; /** - * * @author LevelX2 */ public final class SwayOfTheStars extends CardImpl { public SwayOfTheStars(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{8}{U}{U}"); + super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{8}{U}{U}"); // Each player shuffles their hand, graveyard, and permanents he or she owns into their library, then draws seven cards. Each player's life total becomes 7. this.getSpellAbility().addEffect(new SwayOfTheStarsEffect()); @@ -60,18 +60,19 @@ class SwayOfTheStarsEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - - for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { - Player player = game.getPlayer(playerId); - if (player != null) { - player.moveCards(player.getHand(), Zone.LIBRARY, source, game); - player.moveCards(player.getGraveyard(), Zone.LIBRARY, source, game); - FilterPermanent filter = new FilterPermanent(); - filter.add(new OwnerIdPredicate(playerId)); - for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), source.getSourceId(), game)) { - permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + if (controller != null) { + for (UUID playerId : game.getState().getPlayersInRange(controller.getId(), game)) { + Player player = game.getPlayer(playerId); + if (player != null) { + player.moveCards(player.getHand(), Zone.LIBRARY, source, game); + player.moveCards(player.getGraveyard(), Zone.LIBRARY, source, game); + FilterPermanent filter = new FilterPermanent(); + filter.add(new OwnerIdPredicate(playerId)); + for (Permanent permanent : game.getBattlefield().getActivePermanents(filter, controller.getId(), source.getSourceId(), game)) { + permanent.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + } + player.shuffleLibrary(source, game); } - player.shuffleLibrary(source, game); } } return true; diff --git a/Mage.Sets/src/mage/cards/t/TalusPaladin.java b/Mage.Sets/src/mage/cards/t/TalusPaladin.java index 2619c545e02..e1bd393fefe 100644 --- a/Mage.Sets/src/mage/cards/t/TalusPaladin.java +++ b/Mage.Sets/src/mage/cards/t/TalusPaladin.java @@ -112,7 +112,7 @@ class TalusPaladinEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player player = game.getPlayer(source.getControllerId()); Permanent taluspPaladin = game.getPermanent(source.getSourceId()); - if (taluspPaladin != null) { + if (taluspPaladin != null && player != null) { StringBuilder sb = new StringBuilder(); sb.append("Put a +1/+1 counter on Talus Paladin?"); if (!player.chooseUse(Outcome.Benefit, sb.toString(), source, game)) { diff --git a/Mage.Sets/src/mage/cards/t/TemporalExtortion.java b/Mage.Sets/src/mage/cards/t/TemporalExtortion.java index b3555349f80..c71e1b9d9ef 100644 --- a/Mage.Sets/src/mage/cards/t/TemporalExtortion.java +++ b/Mage.Sets/src/mage/cards/t/TemporalExtortion.java @@ -63,8 +63,8 @@ class TemporalExtortionCounterSourceEffect extends OneShotEffect { if (sourceObject != null) { for (UUID playerId : game.getState().getPlayerList(source.getControllerId())) { Player player = game.getPlayer(playerId); - if (player.chooseUse(outcome, "Pay half your life, rounded up to counter " + sourceObject.getIdName() + '?', source, game)) { - Integer amount = (int) Math.ceil(player.getLife() / 2f); + if (player != null && player.chooseUse(outcome, "Pay half your life, rounded up to counter " + sourceObject.getIdName() + '?', source, game)) { + int amount = (int) Math.ceil(player.getLife() / 2f); player.loseLife(amount, game, false); game.informPlayers(player.getLogName() + " pays half their life, rounded up to counter " + sourceObject.getIdName() + '.'); Spell spell = game.getStack().getSpell(source.getSourceId()); diff --git a/Mage.Sets/src/mage/cards/t/TrespassersCurse.java b/Mage.Sets/src/mage/cards/t/TrespassersCurse.java index 49b3dbdc6a2..1caf05620ec 100644 --- a/Mage.Sets/src/mage/cards/t/TrespassersCurse.java +++ b/Mage.Sets/src/mage/cards/t/TrespassersCurse.java @@ -116,7 +116,7 @@ class TrespassersCurseEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controllerOfCreature = game.getPlayer(this.getTargetPointer().getFirst(game, source)); Player controller = game.getPlayer(source.getControllerId()); - if (controllerOfCreature != null) { + if (controllerOfCreature != null && controller != null) { controllerOfCreature.loseLife(1, game, false); controller.gainLife(1, game, source); return true; diff --git a/Mage.Sets/src/mage/cards/u/UndyingBeast.java b/Mage.Sets/src/mage/cards/u/UndyingBeast.java index d7117e01eaa..20bf25c5a6e 100644 --- a/Mage.Sets/src/mage/cards/u/UndyingBeast.java +++ b/Mage.Sets/src/mage/cards/u/UndyingBeast.java @@ -63,8 +63,10 @@ class UndyingBeastEffect extends OneShotEffect { Card card = game.getCard(source.getSourceId()); if (card != null && game.getState().getZone(source.getSourceId()) == Zone.GRAVEYARD) { Player owner = game.getPlayer(card.getOwnerId()); - owner.getGraveyard().remove(card); - return card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + if(owner != null) { + owner.getGraveyard().remove(card); + return card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, true); + } } return true; } diff --git a/Mage.Sets/src/mage/cards/u/UneshCriosphinxSovereign.java b/Mage.Sets/src/mage/cards/u/UneshCriosphinxSovereign.java index d48aeec950d..392d9c4ffb7 100644 --- a/Mage.Sets/src/mage/cards/u/UneshCriosphinxSovereign.java +++ b/Mage.Sets/src/mage/cards/u/UneshCriosphinxSovereign.java @@ -150,7 +150,7 @@ class UneshCriosphinxSovereignEffect extends OneShotEffect { Player opponent = game.getPlayer(opponents.iterator().next()); TargetCard target = new TargetCard(0, cards.size(), Zone.LIBRARY, new FilterCard("cards to put in the first pile")); List pile1 = new ArrayList<>(); - if (opponent.choose(Outcome.Neutral, cards, target, game)) { + if (opponent != null && opponent.choose(Outcome.Neutral, cards, target, game)) { List targets = target.getTargets(); for (UUID targetId : targets) { Card card = cards.get(targetId, game); diff --git a/Mage.Sets/src/mage/cards/v/VaporSnare.java b/Mage.Sets/src/mage/cards/v/VaporSnare.java index a06a1a75f01..cbf801fdf06 100644 --- a/Mage.Sets/src/mage/cards/v/VaporSnare.java +++ b/Mage.Sets/src/mage/cards/v/VaporSnare.java @@ -79,7 +79,7 @@ class VaporSnareEffect extends OneShotEffect { Player player = game.getPlayer(source.getControllerId()); TargetPermanent target = new TargetPermanent(1, 1, filter, false); - if (target.canChoose(player.getId(), game)) { + if (player != null && target.canChoose(player.getId(), game)) { player.choose(Outcome.Sacrifice, target, source.getSourceId(), game); Permanent permanent = game.getPermanent(target.getFirstTarget()); diff --git a/Mage.Sets/src/mage/cards/v/VesuvanShapeshifter.java b/Mage.Sets/src/mage/cards/v/VesuvanShapeshifter.java index 404b0334c3a..5794410ba0e 100644 --- a/Mage.Sets/src/mage/cards/v/VesuvanShapeshifter.java +++ b/Mage.Sets/src/mage/cards/v/VesuvanShapeshifter.java @@ -125,7 +125,7 @@ class VesuvanShapeshifterEffect extends OneShotEffect { TargetCreaturePermanent target = new TargetCreaturePermanent(0, 1, filter, false); - if (controller.chooseTarget(Outcome.BecomeCreature, target, source, game) && !target.getTargets().isEmpty()) { + if (controller != null && controller.chooseTarget(Outcome.BecomeCreature, target, source, game) && !target.getTargets().isEmpty()) { Permanent copyFromCreature = game.getPermanentOrLKIBattlefield(target.getFirstTarget()); if (copyFromCreature != null) { game.copyPermanent(Duration.Custom, copyFromCreature, copyToCreature.getId(), source, new VesuvanShapeShifterFaceUpApplier()); diff --git a/Mage.Sets/src/mage/cards/v/VigilForTheLost.java b/Mage.Sets/src/mage/cards/v/VigilForTheLost.java index b5de68f55e5..41b030ed94e 100644 --- a/Mage.Sets/src/mage/cards/v/VigilForTheLost.java +++ b/Mage.Sets/src/mage/cards/v/VigilForTheLost.java @@ -3,6 +3,7 @@ package mage.cards.v; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.TriggeredAbilityImpl; import mage.abilities.costs.mana.ManaCostsImpl; @@ -20,18 +21,17 @@ import mage.game.permanent.Permanent; import mage.players.Player; /** - * * @author Loki */ public final class VigilForTheLost extends CardImpl { - public VigilForTheLost (UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{W}"); + public VigilForTheLost(UUID ownerId, CardSetInfo setInfo) { + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{W}"); this.addAbility(new VigilForTheLostTriggeredAbility()); } - public VigilForTheLost (final VigilForTheLost card) { + public VigilForTheLost(final VigilForTheLost card) { super(card); } @@ -63,8 +63,8 @@ class VigilForTheLostTriggeredAbility extends TriggeredAbilityImpl { @Override public boolean checkTrigger(GameEvent event, Game game) { - if (((ZoneChangeEvent)event).getToZone() == Zone.GRAVEYARD && - ((ZoneChangeEvent)event).getFromZone() == Zone.BATTLEFIELD) { + if (((ZoneChangeEvent) event).getToZone() == Zone.GRAVEYARD && + ((ZoneChangeEvent) event).getFromZone() == Zone.BATTLEFIELD) { Permanent p = (Permanent) game.getLastKnownInformation(event.getTargetId(), Zone.BATTLEFIELD); if (p.isControlledBy(this.getControllerId()) && p.isCreature()) { return true; @@ -95,11 +95,13 @@ class VigilForTheLostEffect extends OneShotEffect { cost.clearPaid(); if (cost.payOrRollback(source, game, source.getSourceId(), source.getControllerId())) { Player player = game.getPlayer(source.getControllerId()); - player.gainLife(cost.getX(), game, source); - return true; - } else { - return false; + if (player != null) { + player.gainLife(cost.getX(), game, source); + return true; + } } + return false; + } @Override diff --git a/Mage.Sets/src/mage/cards/v/VirtussManeuver.java b/Mage.Sets/src/mage/cards/v/VirtussManeuver.java index 70880e200f5..e122eaf4de3 100644 --- a/Mage.Sets/src/mage/cards/v/VirtussManeuver.java +++ b/Mage.Sets/src/mage/cards/v/VirtussManeuver.java @@ -69,7 +69,7 @@ class VirtussManeuverEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); ChooseFriendsAndFoes choice = new ChooseFriendsAndFoes(); - if (!choice.chooseFriendOrFoe(controller, source, game)) { + if (controller != null && !choice.chooseFriendOrFoe(controller, source, game)) { return false; } Map getBackMap = new HashMap<>(); diff --git a/Mage.Sets/src/mage/cards/v/VolrathsDungeon.java b/Mage.Sets/src/mage/cards/v/VolrathsDungeon.java index 3c0680016d7..f3dbd4513a9 100644 --- a/Mage.Sets/src/mage/cards/v/VolrathsDungeon.java +++ b/Mage.Sets/src/mage/cards/v/VolrathsDungeon.java @@ -89,8 +89,11 @@ class PayLifeActivePlayerCost extends CostImpl { int lifeToPayAmount = amount.calculate(game, ability, null); Player activatingPlayer = game.getPlayer(game.getActivePlayerId()); if (activatingPlayer != null - && activatingPlayer.chooseUse(Outcome.LoseLife, "Do you wish to pay + lifeToPayAmount + life?", ability, game)) { - this.paid = game.getPlayer(game.getActivePlayerId()).loseLife(lifeToPayAmount, game, false) == lifeToPayAmount; + && activatingPlayer.chooseUse(Outcome.LoseLife, "Do you wish to pay "+ lifeToPayAmount +" life?", ability, game)) { + Player player = game.getPlayer(game.getActivePlayerId()); + if(player != null) { + this.paid = player.loseLife(lifeToPayAmount, game, false) == lifeToPayAmount; + } } return paid; } diff --git a/Mage.Sets/src/mage/cards/w/WarrenWeirding.java b/Mage.Sets/src/mage/cards/w/WarrenWeirding.java index 2e341db538e..f3b2a62a0bb 100644 --- a/Mage.Sets/src/mage/cards/w/WarrenWeirding.java +++ b/Mage.Sets/src/mage/cards/w/WarrenWeirding.java @@ -2,6 +2,7 @@ package mage.cards.w; import java.util.UUID; + import mage.abilities.Ability; import mage.abilities.effects.ContinuousEffect; import mage.abilities.effects.Effect; @@ -31,13 +32,12 @@ import mage.target.common.TargetControlledPermanent; import mage.target.targetpointer.FixedTarget; /** - * * @author LevelX2 */ public final class WarrenWeirding extends CardImpl { public WarrenWeirding(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.TRIBAL,CardType.SORCERY},"{1}{B}"); + super(ownerId, setInfo, new CardType[]{CardType.TRIBAL, CardType.SORCERY}, "{1}{B}"); this.subtype.add(SubType.GOBLIN); @@ -64,19 +64,21 @@ class WarrenWeirdingEffect extends OneShotEffect { filterGoblin.add(new SubtypePredicate(SubType.GOBLIN)); } - WarrenWeirdingEffect ( ) { + WarrenWeirdingEffect() { super(Outcome.Sacrifice); staticText = "Target player sacrifices a creature. If a Goblin is sacrificed this way, that player creates two 1/1 black Goblin Rogue creature tokens, and those tokens gain haste until end of turn"; } - WarrenWeirdingEffect ( WarrenWeirdingEffect effect ) { + WarrenWeirdingEffect(WarrenWeirdingEffect effect) { super(effect); } @Override public boolean apply(Game game, Ability source) { Player player = game.getPlayer(getTargetPointer().getFirst(game, source)); - + if (player == null) { + return false; + } FilterControlledPermanent filter = new FilterControlledPermanent("creature"); filter.add(new CardTypePredicate(CardType.CREATURE)); filter.add(new ControllerIdPredicate(player.getId())); diff --git a/Mage.Sets/src/mage/cards/w/Woeleecher.java b/Mage.Sets/src/mage/cards/w/Woeleecher.java index b2bf5484ba5..4d72992df23 100644 --- a/Mage.Sets/src/mage/cards/w/Woeleecher.java +++ b/Mage.Sets/src/mage/cards/w/Woeleecher.java @@ -75,7 +75,7 @@ class WoeleecherEffect extends OneShotEffect { public boolean apply(Game game, Ability source) { Permanent target = game.getPermanent(source.getFirstTarget()); Player you = game.getPlayer(source.getControllerId()); - if (target != null) { + if (target != null && you != null) { numberCountersOriginal = target.getCounters(game).getCount(CounterType.M1M1); target.removeCounters(CounterType.M1M1.createInstance(), game); numberCountersAfter = target.getCounters(game).getCount(CounterType.M1M1); diff --git a/Mage.Sets/src/mage/cards/w/WordOfUndoing.java b/Mage.Sets/src/mage/cards/w/WordOfUndoing.java index af5518c6ff0..7491e892474 100644 --- a/Mage.Sets/src/mage/cards/w/WordOfUndoing.java +++ b/Mage.Sets/src/mage/cards/w/WordOfUndoing.java @@ -64,7 +64,7 @@ class WordOfUndoingReturnToHandEffect extends OneShotEffect { Set attachments = new LinkedHashSet<>(); Player player = game.getPlayer(source.getControllerId()); Permanent target = game.getPermanent(getTargetPointer().getFirst(game, source)); - if (target != null) { + if (target != null && player != null) { for (UUID attachmentId : target.getAttachments()) { Permanent attachment = game.getPermanent(attachmentId); if (attachment != null && attachment.isControlledBy(source.getControllerId()) diff --git a/Mage.Sets/src/mage/cards/w/WorldQueller.java b/Mage.Sets/src/mage/cards/w/WorldQueller.java index 20950189b1a..0e2853b21f1 100644 --- a/Mage.Sets/src/mage/cards/w/WorldQueller.java +++ b/Mage.Sets/src/mage/cards/w/WorldQueller.java @@ -119,7 +119,7 @@ class WorldQuellerEffect extends OneShotEffect { for (UUID playerId : game.getState().getPlayersInRange(source.getControllerId(), game)) { Player player2 = game.getPlayer(playerId); - if (target.canChoose(playerId, game)) { + if (player2 != null && target.canChoose(playerId, game)) { while (player2.canRespond() && !target.isChosen() && target.canChoose(playerId, game)) { player2.chooseTarget(Outcome.Sacrifice, target, source, game); }