mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Merge pull request #1607 from tool4ever/managainfix
Fix crash when spending mana produced by a gained ability with triggers
This commit is contained in:
@@ -29,6 +29,7 @@ import forge.card.MagicColor;
|
||||
import forge.card.mana.ManaAtom;
|
||||
import forge.card.mana.ManaCostShard;
|
||||
import forge.game.GameActionUtil;
|
||||
import forge.game.IHasSVars;
|
||||
import forge.game.ability.AbilityKey;
|
||||
import forge.game.ability.ApiType;
|
||||
import forge.game.card.Card;
|
||||
@@ -72,6 +73,7 @@ public class AbilityManaPart implements java.io.Serializable {
|
||||
private transient List<Mana> lastManaProduced = Lists.newArrayList();
|
||||
|
||||
private transient Card sourceCard;
|
||||
private transient IHasSVars sVarHolder;
|
||||
|
||||
|
||||
// Spells paid with this mana spell can't be countered.
|
||||
@@ -85,8 +87,13 @@ public class AbilityManaPart implements java.io.Serializable {
|
||||
* @param sourceCard
|
||||
* a {@link forge.game.card.Card} object.
|
||||
*/
|
||||
public AbilityManaPart(final SpellAbility sourceSA, final Map<String, String> params) {
|
||||
this(sourceSA.getHostCard(), params);
|
||||
sVarHolder = sourceSA;
|
||||
}
|
||||
public AbilityManaPart(final Card sourceCard, final Map<String, String> params) {
|
||||
this.sourceCard = sourceCard;
|
||||
sVarHolder = sourceCard;
|
||||
|
||||
origProduced = params.getOrDefault("Produced", "1");
|
||||
this.manaRestrictions = params.getOrDefault("RestrictValid", "");
|
||||
@@ -260,7 +267,7 @@ public class AbilityManaPart implements java.io.Serializable {
|
||||
return;
|
||||
|
||||
TriggerHandler handler = card.getGame().getTriggerHandler();
|
||||
Trigger trig = TriggerHandler.parseTrigger(sourceCard.getSVar(this.triggersWhenSpent), sourceCard, false);
|
||||
Trigger trig = TriggerHandler.parseTrigger(sVarHolder.getSVar(this.triggersWhenSpent), sourceCard, false);
|
||||
handler.registerOneTrigger(trig);
|
||||
}
|
||||
|
||||
|
||||
@@ -1111,7 +1111,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
|
||||
clone.setPayCosts(getPayCosts().copy());
|
||||
if (manaPart != null) {
|
||||
clone.manaPart = new AbilityManaPart(host, mapParams);
|
||||
clone.manaPart = new AbilityManaPart(this, mapParams);
|
||||
}
|
||||
|
||||
// need to copy the damage tables
|
||||
|
||||
@@ -3,6 +3,6 @@ ManaCost:2
|
||||
Types:Artifact Creature Myr
|
||||
PT:5/6
|
||||
Text:Spend only mana produced by creatures to cast this spell.
|
||||
A:SP$ PermanentCreature | Cost$ Mana<2\Creature>
|
||||
A:SP$ PermanentCreature | Cost$ Mana<2\Creature.inZoneBattlefield>
|
||||
AI:RemoveDeck:Random
|
||||
Oracle:Spend only mana produced by creatures to cast this spell.
|
||||
|
||||
@@ -3,7 +3,7 @@ ManaCost:no cost
|
||||
Types:Land
|
||||
K:CARDNAME enters the battlefield tapped.
|
||||
A:AB$ Mana | Cost$ T | Produced$ Combo ColorIdentity | TriggersWhenSpent$ TrigScry | SpellDescription$ Add one mana of any color in your commander's color identity. When that mana is spent to cast a creature spell that shares a creature type with your commander, scry 1. (Look at the top card of your library. You may put that card on the bottom of your library.)
|
||||
SVar:TrigScry:Mode$ SpellCast | ValidCard$ Creature.sharesCreatureTypeWith Commander | OneOff$ True | Execute$ DBScry | TriggerDescription$ When mana produced by CARDNAME is spent to cast a creature spell that shares a creature type with your commander, scry 1.
|
||||
SVar:TrigScry:Mode$ SpellCast | ValidCard$ Creature.sharesCreatureTypeWith Commander | Execute$ DBScry | TriggerDescription$ When mana produced by CARDNAME is spent to cast a creature spell that shares a creature type with your commander, scry 1.
|
||||
SVar:DBScry:DB$ Scry | ScryNum$ 1
|
||||
AI:RemoveDeck:NonCommander
|
||||
Oracle:Path of Ancestry enters the battlefield tapped.\n{T}: Add one mana of any color in your commander's color identity. When that mana is spent to cast a creature spell that shares a creature type with your commander, scry 1. (Look at the top card of your library. You may put that card on the bottom of your library.)
|
||||
|
||||
@@ -21,6 +21,6 @@ Name:Primal Wellspring
|
||||
ManaCost:no cost
|
||||
Types:Land
|
||||
A:AB$ Mana | Cost$ T | Produced$ Any | TriggersWhenSpent$ TrigCopy | SpellDescription$ Add one mana of any color. When that mana is spent to cast an instant or sorcery spell, copy that spell and you may choose new targets for the copy.
|
||||
SVar:TrigCopy:Mode$ SpellCast | ValidCard$ Instant,Sorcery | OneOff$ True | Execute$ TrigCopyMain | TriggerDescription$ When that mana is spent to cast an instant or sorcery spell, copy that spell and you may choose new targets for the copy.
|
||||
SVar:TrigCopy:Mode$ SpellCast | ValidCard$ Instant,Sorcery | Execute$ TrigCopyMain | TriggerDescription$ When that mana is spent to cast an instant or sorcery spell, copy that spell and you may choose new targets for the copy.
|
||||
SVar:TrigCopyMain:DB$ CopySpellAbility | Defined$ TriggeredSpellAbility | MayChooseTarget$ True
|
||||
Oracle:(Transforms from Primal Amulet.)\n{T}: Add one mana of any color. When that mana is spent to cast an instant or sorcery spell, copy that spell and you may choose new targets for the copy.
|
||||
|
||||
@@ -2,6 +2,6 @@ Name:Pyromancer's Goggles
|
||||
ManaCost:5
|
||||
Types:Legendary Artifact
|
||||
A:AB$ Mana | Cost$ T | Produced$ R | TriggersWhenSpent$ TrigCopy | SpellDescription$ Add {R}. When that mana is spent to cast a red instant or sorcery spell, copy that spell and you may choose new targets for the copy.
|
||||
SVar:TrigCopy:Mode$ SpellCast | ValidCard$ Instant.Red,Sorcery.Red | OneOff$ True | Execute$ TrigCopyMain | TriggerDescription$ When that mana is spent to cast a red instant or sorcery spell, copy that spell and you may choose new targets for the copy.
|
||||
SVar:TrigCopy:Mode$ SpellCast | ValidCard$ Instant.Red,Sorcery.Red | Execute$ TrigCopyMain | TriggerDescription$ When that mana is spent to cast a red instant or sorcery spell, copy that spell and you may choose new targets for the copy.
|
||||
SVar:TrigCopyMain:DB$ CopySpellAbility | Defined$ TriggeredSpellAbility | MayChooseTarget$ True
|
||||
Oracle:{T}: Add {R}. When that mana is spent to cast a red instant or sorcery spell, copy that spell and you may choose new targets for the copy.
|
||||
|
||||
Reference in New Issue
Block a user