mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Use a trigger to play cards from suspend.
This commit is contained in:
@@ -1224,6 +1224,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
final Map<String, Object> runParams = new TreeMap<String, Object>();
|
final Map<String, Object> runParams = new TreeMap<String, Object>();
|
||||||
runParams.put("Card", this);
|
runParams.put("Card", this);
|
||||||
runParams.put("CounterType", counterName);
|
runParams.put("CounterType", counterName);
|
||||||
|
runParams.put("NewCounterAmount", newValue > 0 ? newValue : 0);
|
||||||
for (int i = 0; i < delta; i++) {
|
for (int i = 0; i < delta; i++) {
|
||||||
getGame().getTriggerHandler().runTrigger(TriggerType.CounterRemoved, runParams, false);
|
getGame().getTriggerHandler().runTrigger(TriggerType.CounterRemoved, runParams, false);
|
||||||
}
|
}
|
||||||
@@ -1235,9 +1236,6 @@ public class Card extends GameEntity implements Comparable<Card> {
|
|||||||
getGame().getAction().sacrifice(this, null);
|
getGame().getAction().sacrifice(this, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.hasSuspend() && getGame().isCardExiled(this)) {
|
|
||||||
getOwner().getController().playFromSuspend(this);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Play the Subtract Counter sound
|
// Play the Subtract Counter sound
|
||||||
|
|||||||
@@ -191,6 +191,9 @@ public class PlayEffect extends SpellAbilityEffect {
|
|||||||
tgtCard.setSVar("IsEncoded", "Number$1");
|
tgtCard.setSVar("IsEncoded", "Number$1");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if(sa.hasParam("SuspendCast")) {
|
||||||
|
tgtCard.setSuspendCast(true);
|
||||||
|
}
|
||||||
// lands will be played
|
// lands will be played
|
||||||
if (tgtCard.isLand()) {
|
if (tgtCard.isLand()) {
|
||||||
controller.playLand(tgtCard);
|
controller.playLand(tgtCard);
|
||||||
|
|||||||
@@ -2348,6 +2348,21 @@ public class CardFactoryUtil {
|
|||||||
final String cost = k[2];
|
final String cost = k[2];
|
||||||
card.addSpellAbility(abilitySuspend(card, cost, timeCounters));
|
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
|
} // Suspend
|
||||||
|
|
||||||
if (hasKeyword(card, "Fading") != -1) {
|
if (hasKeyword(card, "Fading") != -1) {
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ public class TriggerCounterRemoved extends Trigger {
|
|||||||
public final boolean performTest(final java.util.Map<String, Object> runParams2) {
|
public final boolean performTest(final java.util.Map<String, Object> runParams2) {
|
||||||
final Card addedTo = (Card) runParams2.get("Card");
|
final Card addedTo = (Card) runParams2.get("Card");
|
||||||
final CounterType addedType = (CounterType) runParams2.get("CounterType");
|
final CounterType addedType = (CounterType) runParams2.get("CounterType");
|
||||||
|
final Integer addedNewCounterAmount = (Integer) runParams2.get("NewCounterAmount");
|
||||||
|
|
||||||
if (this.mapParams.containsKey("ValidCard")) {
|
if (this.mapParams.containsKey("ValidCard")) {
|
||||||
if (!addedTo.isValid(this.mapParams.get("ValidCard").split(","), this.getHostCard().getController(),
|
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;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -98,7 +98,7 @@ public abstract class PlayerController {
|
|||||||
* TODO: Write javadoc for this method.
|
* TODO: Write javadoc for this method.
|
||||||
* @param c
|
* @param c
|
||||||
*/
|
*/
|
||||||
public abstract void playFromSuspend(Card c);
|
//public abstract void playFromSuspend(Card c);
|
||||||
public abstract boolean playCascade(Card cascadedCard, Card sourceCard);
|
public abstract boolean playCascade(Card cascadedCard, Card sourceCard);
|
||||||
public abstract void playSpellAbilityForFree(SpellAbility copySA);
|
public abstract void playSpellAbilityForFree(SpellAbility copySA);
|
||||||
|
|
||||||
|
|||||||
@@ -89,11 +89,11 @@ public class PlayerControllerAi extends PlayerController {
|
|||||||
* TODO: Write javadoc for this method.
|
* TODO: Write javadoc for this method.
|
||||||
* @param c
|
* @param c
|
||||||
*/
|
*/
|
||||||
public void playFromSuspend(Card c) {
|
/**public void playFromSuspend(Card c) {
|
||||||
final List<SpellAbility> choices = c.getBasicSpells();
|
final List<SpellAbility> choices = c.getBasicSpells();
|
||||||
c.setSuspendCast(true);
|
c.setSuspendCast(true);
|
||||||
getAi().chooseAndPlaySa(choices, true, true);
|
getAi().chooseAndPlaySa(choices, true, true);
|
||||||
}
|
}**/
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.game.player.PlayerController#playCascade(java.util.List, forge.Card)
|
* @see forge.game.player.PlayerController#playCascade(java.util.List, forge.Card)
|
||||||
|
|||||||
@@ -96,10 +96,10 @@ public class PlayerControllerHuman extends PlayerController {
|
|||||||
* TODO: Write javadoc for this method.
|
* TODO: Write javadoc for this method.
|
||||||
* @param c
|
* @param c
|
||||||
*/
|
*/
|
||||||
public void playFromSuspend(Card c) {
|
/**public void playFromSuspend(Card c) {
|
||||||
c.setSuspendCast(true);
|
c.setSuspendCast(true);
|
||||||
HumanPlay.playCardWithoutPayingManaCost(player, c);
|
HumanPlay.playCardWithoutPayingManaCost(player, c);
|
||||||
}
|
}**/
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.game.player.PlayerController#playCascade(java.util.List, forge.Card)
|
* @see forge.game.player.PlayerController#playCascade(java.util.List, forge.Card)
|
||||||
|
|||||||
Reference in New Issue
Block a user