Use a trigger to play cards from suspend.

This commit is contained in:
RedDeckWins
2013-05-22 23:55:34 +00:00
parent df1aa55d15
commit fb559e7140
7 changed files with 34 additions and 9 deletions

View File

@@ -1224,6 +1224,7 @@ public class Card extends GameEntity implements Comparable<Card> {
final Map<String, Object> runParams = new TreeMap<String, Object>();
runParams.put("Card", this);
runParams.put("CounterType", counterName);
runParams.put("NewCounterAmount", newValue > 0 ? newValue : 0);
for (int i = 0; i < delta; i++) {
getGame().getTriggerHandler().runTrigger(TriggerType.CounterRemoved, runParams, false);
}
@@ -1235,9 +1236,6 @@ public class Card extends GameEntity implements Comparable<Card> {
getGame().getAction().sacrifice(this, null);
}
if (this.hasSuspend() && getGame().isCardExiled(this)) {
getOwner().getController().playFromSuspend(this);
}
}
// Play the Subtract Counter sound

View File

@@ -191,6 +191,9 @@ public class PlayEffect extends SpellAbilityEffect {
tgtCard.setSVar("IsEncoded", "Number$1");
}
}
if(sa.hasParam("SuspendCast")) {
tgtCard.setSuspendCast(true);
}
// lands will be played
if (tgtCard.isLand()) {
controller.playLand(tgtCard);
@@ -230,7 +233,7 @@ public class PlayEffect extends SpellAbilityEffect {
tgtSA.getTarget().setMandatory(true);
}
boolean noManaCost = sa.hasParam("WithoutManaCost");
boolean noManaCost = sa.hasParam("WithoutManaCost");
if (controller.isHuman()) {
SpellAbility newSA = noManaCost ? tgtSA.copyWithNoManaCost() : tgtSA;
HumanPlay.playSpellAbility(activator, newSA);

View File

@@ -2348,6 +2348,21 @@ public class CardFactoryUtil {
final String cost = k[2];
card.addSpellAbility(abilitySuspend(card, cost, timeCounters));
}
StringBuilder trig = new StringBuilder();
trig.append("Mode$ CounterRemoved | TriggerZones$ Exile | ValidCard$ Card.Self | NewCounterAmount$ 0 | Execute$ DBPlay | Secondary$ True | ");
trig.append("TriggerDescription$ When the last time counter is removed from this card, if it's exiled, play it without paying its mana cost if able. ");
trig.append("If you can't, it remains exiled. If you cast a creature spell this way, it gains haste until you lose control of the spell or the permanent it becomes.");
StringBuilder playWithoutCost = new StringBuilder();
playWithoutCost.append("DB$ Play | Defined$ Self | WithoutManaCost$ True | SuspendCast$ True");
final Trigger parsedTrigger = TriggerHandler.parseTrigger(trig.toString(), card, true);
card.addTrigger(parsedTrigger);
card.setSVar("DBPlay",playWithoutCost.toString());
} // Suspend
if (hasKeyword(card, "Fading") != -1) {

View File

@@ -52,6 +52,7 @@ public class TriggerCounterRemoved extends Trigger {
public final boolean performTest(final java.util.Map<String, Object> runParams2) {
final Card addedTo = (Card) runParams2.get("Card");
final CounterType addedType = (CounterType) runParams2.get("CounterType");
final Integer addedNewCounterAmount = (Integer) runParams2.get("NewCounterAmount");
if (this.mapParams.containsKey("ValidCard")) {
if (!addedTo.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(),
@@ -67,6 +68,14 @@ public class TriggerCounterRemoved extends Trigger {
}
}
if (this.mapParams.containsKey("NewCounterAmount")) {
final String amtString = this.mapParams.get("NewCounterAmount");
int amt = Integer.parseInt(amtString);
if(amt != addedNewCounterAmount.intValue()) {
return false;
}
}
return true;
}

View File

@@ -98,7 +98,7 @@ public abstract class PlayerController {
* TODO: Write javadoc for this method.
* @param c
*/
public abstract void playFromSuspend(Card c);
//public abstract void playFromSuspend(Card c);
public abstract boolean playCascade(Card cascadedCard, Card sourceCard);
public abstract void playSpellAbilityForFree(SpellAbility copySA);

View File

@@ -89,11 +89,11 @@ public class PlayerControllerAi extends PlayerController {
* TODO: Write javadoc for this method.
* @param c
*/
public void playFromSuspend(Card c) {
/**public void playFromSuspend(Card c) {
final List<SpellAbility> choices = c.getBasicSpells();
c.setSuspendCast(true);
getAi().chooseAndPlaySa(choices, true, true);
}
}**/
/* (non-Javadoc)
* @see forge.game.player.PlayerController#playCascade(java.util.List, forge.Card)

View File

@@ -96,10 +96,10 @@ public class PlayerControllerHuman extends PlayerController {
* TODO: Write javadoc for this method.
* @param c
*/
public void playFromSuspend(Card c) {
/**public void playFromSuspend(Card c) {
c.setSuspendCast(true);
HumanPlay.playCardWithoutPayingManaCost(player, c);
}
}**/
/* (non-Javadoc)
* @see forge.game.player.PlayerController#playCascade(java.util.List, forge.Card)