* Daretti, Scrap Savant - Fixed a bug that the game is locked if multiple delayed triggered abilities from the emlem trigger.

This commit is contained in:
LevelX2 2015-03-09 01:03:21 +01:00
parent dfebed44a5
commit ecc3c8b1e4
4 changed files with 38 additions and 16 deletions

View file

@ -63,4 +63,10 @@ public class AbilityView extends CardView {
public CardView getSourceCard() { public CardView getSourceCard() {
return this.sourceCard; return this.sourceCard;
} }
public void setName(String name) {
this.name = name;
}
} }

View file

@ -46,6 +46,7 @@ import static mage.constants.Zone.GRAVEYARD;
import static mage.constants.Zone.STACK; import static mage.constants.Zone.STACK;
import mage.game.Game; import mage.game.Game;
import mage.game.GameState; import mage.game.GameState;
import mage.game.command.Emblem;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.target.targetpointer.TargetPointer; import mage.target.targetpointer.TargetPointer;
@ -65,32 +66,41 @@ public class CardsView extends LinkedHashMap<UUID, CardView> {
public CardsView ( Collection<? extends Ability> abilities, Game game ) { public CardsView ( Collection<? extends Ability> abilities, Game game ) {
for ( Ability ability : abilities ) { for ( Ability ability : abilities ) {
Card sourceCard = null; MageObject sourceObject = null;
AbilityView abilityView = null;
switch ( ability.getZone() ) { switch ( ability.getZone() ) {
case ALL: case ALL:
case EXILED: case EXILED:
case GRAVEYARD: case GRAVEYARD:
sourceCard = game.getCard(ability.getSourceId()); sourceObject = game.getCard(ability.getSourceId());
break; break;
case BATTLEFIELD: case BATTLEFIELD:
sourceCard = game.getPermanent(ability.getSourceId()); sourceObject = game.getPermanent(ability.getSourceId());
if (sourceCard == null) { if (sourceObject == null) {
sourceCard = (Permanent)game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD); sourceObject = (Permanent)game.getLastKnownInformation(ability.getSourceId(), Zone.BATTLEFIELD);
} }
break; break;
case STACK: case STACK:
sourceCard = game.getCard(ability.getSourceId()); sourceObject = game.getObject(ability.getSourceId());
break; break;
case COMMAND: case COMMAND:
sourceCard = game.getCard(ability.getSourceId()); sourceObject = game.getObject(ability.getSourceId());
if (sourceCard == null) { if (sourceObject instanceof Emblem) {
ability.newId(); Card planeswalkerCard = game.getCard(((Emblem)sourceObject).getSourceId());
this.put(ability.getId(), new AbilityView(ability, "Emblem", new CardView("Emblem"))); if (planeswalkerCard != null) {
abilityView = new AbilityView(ability, "Emblem " + planeswalkerCard.getName(), new CardView(sourceObject));
abilityView.setName("Emblem " + planeswalkerCard.getName());
abilityView.setExpansionSetCode(planeswalkerCard.getExpansionSetCode());
} else {
throw new IllegalArgumentException("Source card for emblem not found.");
}
} }
break; break;
} }
if (sourceCard != null) { if (sourceObject != null) {
AbilityView abilityView = new AbilityView(ability, sourceCard.getLogName(), new CardView(sourceCard)); if (abilityView == null) {
abilityView = new AbilityView(ability, sourceObject.getLogName(), new CardView(sourceObject));
}
if (ability.getTargets().size() > 0) { if (ability.getTargets().size() > 0) {
abilityView.setTargets(ability.getTargets()); abilityView.setTargets(ability.getTargets());
} else { } else {

View file

@ -45,6 +45,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone; import mage.constants.Zone;
import mage.counters.CounterType; import mage.counters.CounterType;
import mage.filter.FilterCard; import mage.filter.FilterCard;
@ -180,7 +181,7 @@ class DarettiSacrificeEffect extends OneShotEffect {
class DarettiScrapSavantEmblem extends Emblem { class DarettiScrapSavantEmblem extends Emblem {
// You get an emblem with "Whenever an artifact is put into your graveyard from the battlefield, return that card to the battlefield at the beginning of the next end step." // You get an emblem with "Whenever an artifact is put into your graveyard from the battlefield, return that card to the battlefield at the beginning of the next end step."
public DarettiScrapSavantEmblem() { public DarettiScrapSavantEmblem() {
this.setName("EMBLEM: Daretti, Scrap Savant"); this.setName("Emblem - Daretti");
this.getAbilities().add(new DarettiScrapSavantTriggeredAbility()); this.getAbilities().add(new DarettiScrapSavantTriggeredAbility());
} }
} }
@ -246,7 +247,7 @@ class DarettiScrapSavantEffect extends OneShotEffect {
Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect(); Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
effect.setTargetPointer(new FixedTarget(card.getId())); effect.setTargetPointer(new FixedTarget(card.getId()));
effect.setText("return that card to the battlefield at the beginning of the next end step"); effect.setText("return that card to the battlefield at the beginning of the next end step");
DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(effect); DelayedTriggeredAbility delayedAbility = new AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone.COMMAND, effect, TargetController.ANY);
delayedAbility.setSourceId(source.getSourceId()); delayedAbility.setSourceId(source.getSourceId());
delayedAbility.setControllerId(source.getControllerId()); delayedAbility.setControllerId(source.getControllerId());
delayedAbility.setSourceObject(source.getSourceObject(game)); delayedAbility.setSourceObject(source.getSourceObject(game));

View file

@ -34,9 +34,9 @@ import static mage.constants.TargetController.ANY;
import static mage.constants.TargetController.CONTROLLER_ATTACHED_TO; import static mage.constants.TargetController.CONTROLLER_ATTACHED_TO;
import static mage.constants.TargetController.OPPONENT; import static mage.constants.TargetController.OPPONENT;
import static mage.constants.TargetController.YOU; import static mage.constants.TargetController.YOU;
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.events.GameEvent.EventType;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
/** /**
@ -52,11 +52,16 @@ public class AtTheBeginOfNextEndStepDelayedTriggeredAbility extends DelayedTrigg
} }
public AtTheBeginOfNextEndStepDelayedTriggeredAbility(Effect effect, TargetController targetController) { public AtTheBeginOfNextEndStepDelayedTriggeredAbility(Effect effect, TargetController targetController) {
this(Zone.ALL, effect, targetController);
}
public AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone zone, Effect effect, TargetController targetController) {
super(effect); super(effect);
this.zone = zone;
this.targetController = targetController; this.targetController = targetController;
} }
public AtTheBeginOfNextEndStepDelayedTriggeredAbility(AtTheBeginOfNextEndStepDelayedTriggeredAbility ability) { public AtTheBeginOfNextEndStepDelayedTriggeredAbility(final AtTheBeginOfNextEndStepDelayedTriggeredAbility ability) {
super(ability); super(ability);
this.targetController = ability.targetController; this.targetController = ability.targetController;
} }