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

View file

@ -45,6 +45,7 @@ import mage.cards.CardImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.FilterCard;
@ -180,7 +181,7 @@ class DarettiSacrificeEffect extends OneShotEffect {
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."
public DarettiScrapSavantEmblem() {
this.setName("EMBLEM: Daretti, Scrap Savant");
this.setName("Emblem - Daretti");
this.getAbilities().add(new DarettiScrapSavantTriggeredAbility());
}
}
@ -246,7 +247,7 @@ class DarettiScrapSavantEffect extends OneShotEffect {
Effect effect = new ReturnFromGraveyardToBattlefieldTargetEffect();
effect.setTargetPointer(new FixedTarget(card.getId()));
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.setControllerId(source.getControllerId());
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.OPPONENT;
import static mage.constants.TargetController.YOU;
import mage.constants.Zone;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
/**
@ -52,11 +52,16 @@ public class AtTheBeginOfNextEndStepDelayedTriggeredAbility extends DelayedTrigg
}
public AtTheBeginOfNextEndStepDelayedTriggeredAbility(Effect effect, TargetController targetController) {
this(Zone.ALL, effect, targetController);
}
public AtTheBeginOfNextEndStepDelayedTriggeredAbility(Zone zone, Effect effect, TargetController targetController) {
super(effect);
this.zone = zone;
this.targetController = targetController;
}
public AtTheBeginOfNextEndStepDelayedTriggeredAbility(AtTheBeginOfNextEndStepDelayedTriggeredAbility ability) {
public AtTheBeginOfNextEndStepDelayedTriggeredAbility(final AtTheBeginOfNextEndStepDelayedTriggeredAbility ability) {
super(ability);
this.targetController = ability.targetController;
}