[AKH] Approach of the Second Sun fix of cast watcher.

This commit is contained in:
LevelX2 2017-04-17 00:44:08 +02:00
parent 430dbdb5f0
commit b8e952cfb9
2 changed files with 18 additions and 15 deletions

View file

@ -1,5 +1,8 @@
package mage.cards.a; package mage.cards.a;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
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;
@ -8,24 +11,20 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.WatcherScope; import mage.constants.WatcherScope;
import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.stack.Spell;
import mage.players.Player; import mage.players.Player;
import mage.watchers.Watcher; import mage.watchers.Watcher;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import mage.constants.Zone;
import mage.game.stack.Spell;
/** /**
* @author stravant * @author stravant
*/ */
public class ApproachOfTheSecondSun extends CardImpl { public class ApproachOfTheSecondSun extends CardImpl {
public ApproachOfTheSecondSun(UUID ownerId, CardSetInfo setInfo) { public ApproachOfTheSecondSun(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{6}{W}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{6}{W}");
getSpellAbility().addEffect(new ApproachOfTheSecondSunEffect()); getSpellAbility().addEffect(new ApproachOfTheSecondSunEffect());
getSpellAbility().addWatcher(new ApproachOfTheSecondSunWatcher()); getSpellAbility().addWatcher(new ApproachOfTheSecondSunWatcher());
@ -42,10 +41,11 @@ public class ApproachOfTheSecondSun extends CardImpl {
} }
class ApproachOfTheSecondSunEffect extends OneShotEffect { class ApproachOfTheSecondSunEffect extends OneShotEffect {
public ApproachOfTheSecondSunEffect() { public ApproachOfTheSecondSunEffect() {
super(Outcome.Win); super(Outcome.Win);
this.staticText = this.staticText
"If {this} was cast from your hand and you've cast another spell named Approach of the Second Sun this game, you win the game. " = "If {this} was cast from your hand and you've cast another spell named Approach of the Second Sun this game, you win the game. "
+ "Otherwise, put {this} into its owner's library seventh from the top and you gain 7 life."; + "Otherwise, put {this} into its owner's library seventh from the top and you gain 7 life.";
} }
@ -62,8 +62,8 @@ class ApproachOfTheSecondSunEffect extends OneShotEffect {
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) {
ApproachOfTheSecondSunWatcher watcher = ApproachOfTheSecondSunWatcher watcher
(ApproachOfTheSecondSunWatcher) game.getState().getWatchers().get("approachOfTheSecondSunWatcher", source.getControllerId()); = (ApproachOfTheSecondSunWatcher) game.getState().getWatchers().get(ApproachOfTheSecondSunWatcher.class.getName(), source.getControllerId());
if (watcher != null && watcher.getApproachesCast() > 1) { if (watcher != null && watcher.getApproachesCast() > 1) {
// Win the game // Win the game
controller.won(game); controller.won(game);
@ -98,12 +98,12 @@ class ApproachOfTheSecondSunEffect extends OneShotEffect {
} }
} }
class ApproachOfTheSecondSunWatcher extends Watcher { class ApproachOfTheSecondSunWatcher extends Watcher {
private int approachesCast = 0; private int approachesCast = 0;
public ApproachOfTheSecondSunWatcher() { public ApproachOfTheSecondSunWatcher() {
super("approachOfTheSecondSunWatcher", WatcherScope.PLAYER); super(ApproachOfTheSecondSunWatcher.class.getName(), WatcherScope.PLAYER);
} }
public ApproachOfTheSecondSunWatcher(final ApproachOfTheSecondSunWatcher watcher) { public ApproachOfTheSecondSunWatcher(final ApproachOfTheSecondSunWatcher watcher) {
@ -114,7 +114,10 @@ class ApproachOfTheSecondSunWatcher extends Watcher {
@Override @Override
public void watch(GameEvent event, Game game) { public void watch(GameEvent event, Game game) {
if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getPlayerId().equals(this.getControllerId())) { if (event.getType() == GameEvent.EventType.SPELL_CAST && event.getPlayerId().equals(this.getControllerId())) {
++approachesCast; Spell spell = game.getStack().getSpell(event.getSourceId());
if (spell != null && spell.getName().equals("Approach of the Second Sun")) {
++approachesCast;
}
} }
} }

View file

@ -75,7 +75,7 @@ public class UntapTargetEffect extends OneShotEffect {
Target target = mode.getTargets().get(0); Target target = mode.getTargets().get(0);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("Untap "); sb.append("untap ");
if (target.getNumberOfTargets() == 0) { if (target.getNumberOfTargets() == 0) {
sb.append("up to "); sb.append("up to ");
} }