* Dawns Reflection - Fixed possible null pointer exception.

This commit is contained in:
LevelX2 2017-08-30 17:03:14 +02:00
parent 1c8f11e849
commit 865c0047ae

View file

@ -55,10 +55,9 @@ import mage.target.common.TargetLandPermanent;
public class DawnsReflection extends CardImpl { public class DawnsReflection extends CardImpl {
public DawnsReflection(UUID ownerId, CardSetInfo setInfo) { 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"); this.subtype.add("Aura");
// Enchant land // Enchant land
TargetPermanent auraTarget = new TargetLandPermanent(); TargetPermanent auraTarget = new TargetLandPermanent();
this.getSpellAbility().addTarget(auraTarget); this.getSpellAbility().addTarget(auraTarget);
@ -78,6 +77,7 @@ public class DawnsReflection extends CardImpl {
return new DawnsReflection(this); return new DawnsReflection(this);
} }
} }
class DawnsReflectionTriggeredAbility extends TriggeredManaAbility { class DawnsReflectionTriggeredAbility extends TriggeredManaAbility {
public DawnsReflectionTriggeredAbility() { public DawnsReflectionTriggeredAbility() {
@ -104,14 +104,12 @@ class DawnsReflectionTriggeredAbility extends TriggeredManaAbility {
return enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo()); return enchantment != null && event.getSourceId().equals(enchantment.getAttachedTo());
} }
@Override @Override
public String getRule() { 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 <i>(in addition to the mana the land produces)</i>."; return "Whenever enchanted land is tapped for mana, its controller adds two mana in any combination of colors to his or her mana pool <i>(in addition to the mana the land produces)</i>.";
} }
} }
class DawnsReflectionManaEffect extends ManaEffect { class DawnsReflectionManaEffect extends ManaEffect {
public DawnsReflectionManaEffect() { public DawnsReflectionManaEffect() {
@ -131,18 +129,18 @@ class DawnsReflectionManaEffect extends ManaEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
if(controller != null){ if (controller != null) {
int x = 2; int x = 2;
Mana mana = new Mana(); Mana mana = new Mana();
for(int i = 0; i < x; i++){ for (int i = 0; i < x; i++) {
ChoiceColor choiceColor = new ChoiceColor(); 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); choiceColor.increaseMana(mana);
} }
controller.getManaPool().addMana(mana, game, source); controller.getManaPool().addMana(mana, game, source);
return true; return true;
@ -155,5 +153,4 @@ class DawnsReflectionManaEffect extends ManaEffect {
return null; return null;
} }
} }