God-Eternal Bontu - fixed game freeze with NPE error

This commit is contained in:
Oleg Agafonov 2019-04-18 08:44:44 +04:00
parent ee051ef478
commit 886b96072e
4 changed files with 35 additions and 43 deletions

View file

@ -1,7 +1,5 @@
package mage.cards.f; package mage.cards.f;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.ZoneChangeTriggeredAbility; import mage.abilities.common.ZoneChangeTriggeredAbility;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
@ -23,14 +21,15 @@ import mage.target.TargetPermanent;
import mage.target.common.TargetCreaturePermanent; import mage.target.common.TargetCreaturePermanent;
import mage.target.targetpointer.FixedTarget; import mage.target.targetpointer.FixedTarget;
import java.util.UUID;
/** /**
*
* @author L_J * @author L_J
*/ */
public final class FuneralMarch extends CardImpl { public final class FuneralMarch extends CardImpl {
public FuneralMarch(UUID ownerId, CardSetInfo setInfo) { public FuneralMarch(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{1}{B}{B}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{B}{B}");
this.subtype.add(SubType.AURA); this.subtype.add(SubType.AURA);
// Enchant creature // Enchant creature
@ -73,17 +72,19 @@ class FuneralMarchTriggeredAbility extends ZoneChangeTriggeredAbility {
public boolean checkTrigger(GameEvent event, Game game) { public boolean checkTrigger(GameEvent event, Game game) {
Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId()); Permanent enchantment = game.getPermanentOrLKIBattlefield(this.getSourceId());
if (enchantment != null && enchantment.getAttachedTo() != null && event.getTargetId().equals(enchantment.getAttachedTo())) { if (enchantment != null && enchantment.getAttachedTo() != null && event.getTargetId().equals(enchantment.getAttachedTo())) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event; if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
if ((fromZone == null || zEvent.getFromZone() == fromZone) && (toZone == null || zEvent.getToZone() == toZone)) { ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
for (Effect effect : getEffects()) { if ((fromZone == null || zEvent.getFromZone() == fromZone) && (toZone == null || zEvent.getToZone() == toZone)) {
if (zEvent.getTarget() != null) { for (Effect effect : getEffects()) {
Permanent attachedTo = (Permanent) game.getLastKnownInformation(enchantment.getAttachedTo(), Zone.BATTLEFIELD, enchantment.getAttachedToZoneChangeCounter()); if (zEvent.getTarget() != null) {
if (attachedTo != null) { Permanent attachedTo = (Permanent) game.getLastKnownInformation(enchantment.getAttachedTo(), Zone.BATTLEFIELD, enchantment.getAttachedToZoneChangeCounter());
effect.setTargetPointer(new FixedTarget(attachedTo.getControllerId())); if (attachedTo != null) {
effect.setTargetPointer(new FixedTarget(attachedTo.getControllerId()));
}
} }
} }
return true;
} }
return true;
} }
} }
return false; return false;

View file

@ -1,38 +1,33 @@
package mage.cards.w; package mage.cards.w;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.BeginningOfUpkeepTriggeredAbility; import mage.abilities.common.BeginningOfUpkeepTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.costs.Cost; import mage.abilities.costs.Cost;
import mage.abilities.costs.common.SacrificeTargetCost; import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.*;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterControlledLandPermanent; import mage.filter.common.FilterControlledLandPermanent;
import mage.game.Game; import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.ZoneChangeEvent; import mage.game.events.ZoneChangeEvent;
import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetControlledPermanent; import mage.target.common.TargetControlledPermanent;
import java.util.UUID;
/** /**
*
* @author L_J * @author L_J
*/ */
public final class WormsOfTheEarth extends CardImpl { public final class WormsOfTheEarth extends CardImpl {
public WormsOfTheEarth(UUID ownerId, CardSetInfo setInfo) { public WormsOfTheEarth(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{B}{B}{B}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{B}{B}{B}");
// Players can't play lands. // Players can't play lands.
this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new WormsOfTheEarthPlayEffect())); this.addAbility(new SimpleStaticAbility(Zone.BATTLEFIELD, new WormsOfTheEarthPlayEffect()));
@ -104,7 +99,7 @@ class WormsOfTheEarthEnterEffect extends ContinuousRuleModifyingEffectImpl {
@Override @Override
public boolean checksEventType(GameEvent event, Game game) { public boolean checksEventType(GameEvent event, Game game) {
return GameEvent.EventType.ZONE_CHANGE == event.getType(); return event.getType() == GameEvent.EventType.ZONE_CHANGE;
} }
@Override @Override
@ -112,9 +107,7 @@ class WormsOfTheEarthEnterEffect extends ContinuousRuleModifyingEffectImpl {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event; ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
if (zEvent.getToZone() == Zone.BATTLEFIELD) { if (zEvent.getToZone() == Zone.BATTLEFIELD) {
Card card = game.getCard(zEvent.getTargetId()); Card card = game.getCard(zEvent.getTargetId());
if (card != null && card.isLand()) { return card != null && card.isLand();
return true;
}
} }
return false; return false;
} }

View file

@ -1,4 +1,3 @@
package mage.abilities.common; package mage.abilities.common;
import mage.MageObjectReference; import mage.MageObjectReference;
@ -28,10 +27,12 @@ public class GodEternalDiesTriggeredAbility extends TriggeredAbilityImpl {
@Override @Override
public boolean checkEventType(GameEvent event, Game game) { public boolean checkEventType(GameEvent event, Game game) {
ZoneChangeEvent zEvent = (ZoneChangeEvent) event; if (event.getType() == GameEvent.EventType.ZONE_CHANGE) {
return zEvent.getFromZone() == Zone.BATTLEFIELD ZoneChangeEvent zEvent = (ZoneChangeEvent) event;
&& (zEvent.getToZone() == Zone.GRAVEYARD return zEvent.getFromZone() == Zone.BATTLEFIELD
|| zEvent.getToZone() == Zone.EXILED); && (zEvent.getToZone() == Zone.GRAVEYARD || zEvent.getToZone() == Zone.EXILED);
}
return false;
} }
@Override @Override

View file

@ -1,4 +1,3 @@
package mage.abilities.keyword; package mage.abilities.keyword;
import mage.abilities.Ability; import mage.abilities.Ability;
@ -19,19 +18,17 @@ import mage.game.events.GameEvent.EventType;
import mage.game.events.ZoneChangeEvent; import mage.game.events.ZoneChangeEvent;
/** /**
*
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
* * <p>
* * <p>
* 702.82. Unearth * 702.82. Unearth
* * <p>
* 702.82a Unearth is an activated ability that functions while the card with * 702.82a Unearth is an activated ability that functions while the card with
* unearth is in a graveyard. "Unearth [cost]" means "[Cost]: Return this card * unearth is in a graveyard. "Unearth [cost]" means "[Cost]: Return this card
* from your graveyard to the battlefield. It gains haste. Exile it at the * from your graveyard to the battlefield. It gains haste. Exile it at the
* beginning of the next end step. If it would leave the battlefield, exile it * beginning of the next end step. If it would leave the battlefield, exile it
* instead of putting it anywhere else. Activate this ability only any time you * instead of putting it anywhere else. Activate this ability only any time you
* could cast a sorcery." * could cast a sorcery."
*
*/ */
public class UnearthAbility extends ActivatedAbilityImpl { public class UnearthAbility extends ActivatedAbilityImpl {
@ -111,7 +108,7 @@ class UnearthLeavesBattlefieldEffect extends ReplacementEffectImpl {
@Override @Override
public boolean checksEventType(GameEvent event, Game game) { public boolean checksEventType(GameEvent event, Game game) {
return EventType.ZONE_CHANGE == event.getType(); return event.getType() == EventType.ZONE_CHANGE;
} }
@Override @Override