* Approach Of The Second Sun - Fixed that it did not always correctly determined if a player has won (fixes #3250).

This commit is contained in:
LevelX2 2017-04-28 14:18:58 +02:00
parent 33f6c629c2
commit 236608cd0f

View file

@ -1,7 +1,6 @@
package mage.cards.a; package mage.cards.a;
import java.util.*; import java.util.*;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.cards.Card;
@ -115,7 +114,7 @@ class ApproachOfTheSecondSunWatcher extends Watcher {
public ApproachOfTheSecondSunWatcher(final ApproachOfTheSecondSunWatcher watcher) { public ApproachOfTheSecondSunWatcher(final ApproachOfTheSecondSunWatcher watcher) {
super(watcher); super(watcher);
approachesCast = new HashMap<>(approachesCast); approachesCast = new HashMap<>(watcher.approachesCast);
} }
@Override @Override
@ -123,19 +122,13 @@ class ApproachOfTheSecondSunWatcher extends Watcher {
if (event.getType() == GameEvent.EventType.SPELL_CAST) { if (event.getType() == GameEvent.EventType.SPELL_CAST) {
Spell spell = game.getStack().getSpell(event.getSourceId()); Spell spell = game.getStack().getSpell(event.getSourceId());
if (spell != null && spell.getName().equals("Approach of the Second Sun")) { if (spell != null && spell.getName().equals("Approach of the Second Sun")) {
int cast = getApproachesCast(event.getPlayerId()); approachesCast.put(event.getPlayerId(), getApproachesCast(event.getPlayerId()) + 1);
approachesCast.put(event.getPlayerId(), cast + 1);
} }
} }
} }
public int getApproachesCast(UUID player) { public int getApproachesCast(UUID player) {
Integer cast = approachesCast.get(player); return approachesCast.getOrDefault(player, 0);
if (cast == null) {
return 0;
} else {
return cast;
}
} }
@Override @Override