From 865c0047ae9cd637191ecdb4d07c5c408fdb3152 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 30 Aug 2017 17:03:14 +0200 Subject: [PATCH] * Dawns Reflection - Fixed possible null pointer exception. --- .../src/mage/cards/d/DawnsReflection.java | 21 ++++++++----------- 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/Mage.Sets/src/mage/cards/d/DawnsReflection.java b/Mage.Sets/src/mage/cards/d/DawnsReflection.java index 17f7aef0b78..aca47bdf035 100644 --- a/Mage.Sets/src/mage/cards/d/DawnsReflection.java +++ b/Mage.Sets/src/mage/cards/d/DawnsReflection.java @@ -55,10 +55,9 @@ import mage.target.common.TargetLandPermanent; public class DawnsReflection extends CardImpl { public DawnsReflection(UUID ownerId, CardSetInfo setInfo) { - super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{3}{G}"); + super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{3}{G}"); this.subtype.add("Aura"); - // Enchant land TargetPermanent auraTarget = new TargetLandPermanent(); this.getSpellAbility().addTarget(auraTarget); @@ -78,6 +77,7 @@ public class DawnsReflection extends CardImpl { return new DawnsReflection(this); } } + class DawnsReflectionTriggeredAbility extends TriggeredManaAbility { public DawnsReflectionTriggeredAbility() { @@ -104,14 +104,12 @@ class DawnsReflectionTriggeredAbility extends TriggeredManaAbility { return enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo()); } - @Override public String getRule() { return "Whenever enchanted land is tapped for mana, its controller adds two mana in any combination of colors to his or her mana pool (in addition to the mana the land produces)."; } } - class DawnsReflectionManaEffect extends ManaEffect { public DawnsReflectionManaEffect() { @@ -131,18 +129,18 @@ class DawnsReflectionManaEffect extends ManaEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if(controller != null){ - int x = 2; - + if (controller != null) { + int x = 2; Mana mana = new Mana(); - for(int i = 0; i < x; i++){ + for (int i = 0; i < x; i++) { ChoiceColor choiceColor = new ChoiceColor(); - while (controller.canRespond() && !controller.choose(Outcome.Benefit, choiceColor, game)) { + while (!controller.choose(Outcome.Benefit, choiceColor, game)) { + if (!controller.isInGame()) { + return false; + } } - choiceColor.increaseMana(mana); } - controller.getManaPool().addMana(mana, game, source); return true; @@ -155,5 +153,4 @@ class DawnsReflectionManaEffect extends ManaEffect { return null; } - }