* Fixed some possible null pointer exceptions.

This commit is contained in:
LevelX2 2017-01-22 22:46:14 +01:00
parent 719f88b3c8
commit 0014c7dcc5
3 changed files with 21 additions and 4 deletions

View file

@ -60,9 +60,12 @@ public class InvaderParasite extends CardImpl {
this.power = new MageInt(3); this.power = new MageInt(3);
this.toughness = new MageInt(2); this.toughness = new MageInt(2);
// Imprint - When Invader Parasite enters the battlefield, exile target land.
Ability ability = new EntersBattlefieldTriggeredAbility(new InvaderParasiteImprintEffect(), false); Ability ability = new EntersBattlefieldTriggeredAbility(new InvaderParasiteImprintEffect(), false);
ability.addTarget(new TargetLandPermanent()); ability.addTarget(new TargetLandPermanent());
this.addAbility(ability); this.addAbility(ability);
// Whenever a land with the same name as the exiled card enters the battlefield under an opponent's control, Invader Parasite deals 2 damage to that player.
this.addAbility(new InvaderParasiteTriggeredAbility()); this.addAbility(new InvaderParasiteTriggeredAbility());
} }
@ -77,6 +80,7 @@ public class InvaderParasite extends CardImpl {
} }
class InvaderParasiteImprintEffect extends OneShotEffect { class InvaderParasiteImprintEffect extends OneShotEffect {
InvaderParasiteImprintEffect() { InvaderParasiteImprintEffect() {
super(Outcome.Exile); super(Outcome.Exile);
staticText = "exile target land"; staticText = "exile target land";
@ -104,6 +108,7 @@ class InvaderParasiteImprintEffect extends OneShotEffect {
} }
class InvaderParasiteTriggeredAbility extends TriggeredAbilityImpl { class InvaderParasiteTriggeredAbility extends TriggeredAbilityImpl {
InvaderParasiteTriggeredAbility() { InvaderParasiteTriggeredAbility() {
super(Zone.BATTLEFIELD, new DamageTargetEffect(2)); super(Zone.BATTLEFIELD, new DamageTargetEffect(2));
} }
@ -125,12 +130,12 @@ class InvaderParasiteTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) { if (game.getOpponents(this.controllerId).contains(event.getPlayerId())) {
Permanent p = game.getPermanent(event.getTargetId()); Permanent targetPermanent = game.getPermanent(event.getTargetId());
Permanent sourcePermanent = game.getPermanent(getSourceId()); Permanent sourcePermanent = game.getPermanent(getSourceId());
if (p != null && sourcePermanent != null) { if (targetPermanent != null && sourcePermanent != null) {
if (sourcePermanent.getImprinted().size() > 0) { if (sourcePermanent.getImprinted().size() > 0) {
Card imprintedCard = game.getCard(sourcePermanent.getImprinted().get(0)); Card imprintedCard = game.getCard(sourcePermanent.getImprinted().get(0));
if (p.getName().equals(imprintedCard.getName())) { if (imprintedCard != null && targetPermanent.getName().equals(imprintedCard.getName())) {
for (Effect effect : this.getEffects()) { for (Effect effect : this.getEffects()) {
effect.setTargetPointer(new FixedTarget(event.getPlayerId())); effect.setTargetPointer(new FixedTarget(event.getPlayerId()));
} }

View file

@ -29,6 +29,8 @@ package mage.abilities.mana;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import mage.Mana; import mage.Mana;
import mage.abilities.Abilities; import mage.abilities.Abilities;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -161,6 +163,7 @@ class AnyColorLandsProduceManaEffect extends ManaEffect {
} }
private Mana getManaTypes(Game game, Ability source) { private Mana getManaTypes(Game game, Ability source) {
Logger.getLogger(this.getClass().getName()).log(Level.WARNING, "needed to identify endless loop causing cards: {0}", source.getSourceObject(game).getName());
List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game); List<Permanent> lands = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getSourceId(), game);
Mana types = new Mana(); Mana types = new Mana();
for (Permanent land : lands) { for (Permanent land : lands) {

View file

@ -3293,6 +3293,9 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean moveCardToGraveyardWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) { public boolean moveCardToGraveyardWithInfo(Card card, UUID sourceId, Game game, Zone fromZone) {
if (card == null) {
return false;
}
boolean result = false; boolean result = false;
// Zone fromZone = game.getState().getZone(card.getId()); // Zone fromZone = game.getState().getZone(card.getId());
if (card.moveToZone(Zone.GRAVEYARD, sourceId, game, fromZone != null ? fromZone == Zone.BATTLEFIELD : false)) { if (card.moveToZone(Zone.GRAVEYARD, sourceId, game, fromZone != null ? fromZone == Zone.BATTLEFIELD : false)) {
@ -3317,6 +3320,9 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean moveCardToLibraryWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean toTop, boolean withName) { public boolean moveCardToLibraryWithInfo(Card card, UUID sourceId, Game game, Zone fromZone, boolean toTop, boolean withName) {
if (card == null) {
return false;
}
boolean result = false; boolean result = false;
if (card.moveToZone(Zone.LIBRARY, sourceId, game, toTop)) { if (card.moveToZone(Zone.LIBRARY, sourceId, game, toTop)) {
if (!game.isSimulation()) { if (!game.isSimulation()) {
@ -3346,6 +3352,9 @@ public abstract class PlayerImpl implements Player, Serializable {
@Override @Override
public boolean moveCardToExileWithInfo(Card card, UUID exileId, String exileName, UUID sourceId, Game game, Zone fromZone, boolean withName) { public boolean moveCardToExileWithInfo(Card card, UUID exileId, String exileName, UUID sourceId, Game game, Zone fromZone, boolean withName) {
if (card == null) {
return false;
}
boolean result = false; boolean result = false;
if (card.moveToExile(exileId, exileName, sourceId, game)) { if (card.moveToExile(exileId, exileName, sourceId, game)) {
if (!game.isSimulation()) { if (!game.isSimulation()) {