mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-15 10:18:01 +00:00
Fix AbilityMana triggering too early on spent mana
This commit is contained in:
committed by
Hans Mackowiak
parent
46c39b454c
commit
3fdac76ed0
@@ -20,14 +20,11 @@ package forge.game.mana;
|
|||||||
import com.google.common.collect.ArrayListMultimap;
|
import com.google.common.collect.ArrayListMultimap;
|
||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Multimap;
|
import com.google.common.collect.Multimap;
|
||||||
import forge.GameCommand;
|
|
||||||
import forge.card.MagicColor;
|
import forge.card.MagicColor;
|
||||||
import forge.card.mana.ManaAtom;
|
import forge.card.mana.ManaAtom;
|
||||||
import forge.card.mana.ManaCostShard;
|
import forge.card.mana.ManaCostShard;
|
||||||
import forge.game.GlobalRuleChange;
|
import forge.game.GlobalRuleChange;
|
||||||
import forge.game.card.Card;
|
|
||||||
import forge.game.event.EventValueChangeType;
|
import forge.game.event.EventValueChangeType;
|
||||||
import forge.game.event.GameEventCardStatsChanged;
|
|
||||||
import forge.game.event.GameEventManaPool;
|
import forge.game.event.GameEventManaPool;
|
||||||
import forge.game.event.GameEventZone;
|
import forge.game.event.GameEventZone;
|
||||||
import forge.game.phase.PhaseType;
|
import forge.game.phase.PhaseType;
|
||||||
@@ -222,44 +219,6 @@ public class ManaPool extends ManaConversionMatrix implements Iterable<Mana> {
|
|||||||
manaCost.payMana(mana, this);
|
manaCost.payMana(mana, this);
|
||||||
removeMana(mana);
|
removeMana(mana);
|
||||||
|
|
||||||
if (test) {
|
|
||||||
// If just testing, should I be running special mana bonuses?
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (mana.addsNoCounterMagic(sa) && sa.getHostCard() != null) {
|
|
||||||
sa.getHostCard().setCanCounter(false);
|
|
||||||
}
|
|
||||||
if (sa.isSpell() && sa.getHostCard() != null) {
|
|
||||||
final Card host = sa.getHostCard();
|
|
||||||
if (mana.addsKeywords(sa) && mana.addsKeywordsType()
|
|
||||||
&& host.getType().hasStringType(mana.getManaAbility().getAddsKeywordsType())) {
|
|
||||||
final long timestamp = host.getGame().getNextTimestamp();
|
|
||||||
final List<String> kws = Arrays.asList(mana.getAddedKeywords().split(" & "));
|
|
||||||
host.addChangedCardKeywords(kws, null, false, false, timestamp);
|
|
||||||
if (mana.addsKeywordsUntil()) {
|
|
||||||
final GameCommand untilEOT = new GameCommand() {
|
|
||||||
private static final long serialVersionUID = -8285169579025607693L;
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void run() {
|
|
||||||
host.removeChangedCardKeywords(timestamp);
|
|
||||||
host.getGame().fireEvent(new GameEventCardStatsChanged(host));
|
|
||||||
}
|
|
||||||
};
|
|
||||||
String until = mana.getManaAbility().getAddsKeywordsUntil();
|
|
||||||
if ("UntilEOT".equals(until)) {
|
|
||||||
host.getGame().getEndOfTurn().addUntil(untilEOT);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
if (mana.addsCounters(sa)) {
|
|
||||||
mana.getManaAbility().createETBCounters(host, this.owner);
|
|
||||||
}
|
|
||||||
if (mana.triggersWhenSpent()) {
|
|
||||||
mana.getManaAbility().addTriggersWhenSpent(sa, host);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ import com.google.common.collect.Iterables;
|
|||||||
import com.google.common.collect.Lists;
|
import com.google.common.collect.Lists;
|
||||||
import com.google.common.collect.Maps;
|
import com.google.common.collect.Maps;
|
||||||
|
|
||||||
|
import forge.GameCommand;
|
||||||
import forge.card.CardStateName;
|
import forge.card.CardStateName;
|
||||||
import forge.card.ColorSet;
|
import forge.card.ColorSet;
|
||||||
import forge.card.mana.ManaCost;
|
import forge.card.mana.ManaCost;
|
||||||
@@ -40,6 +41,7 @@ import forge.game.card.CardZoneTable;
|
|||||||
import forge.game.cost.Cost;
|
import forge.game.cost.Cost;
|
||||||
import forge.game.cost.CostPart;
|
import forge.game.cost.CostPart;
|
||||||
import forge.game.cost.CostRemoveCounter;
|
import forge.game.cost.CostRemoveCounter;
|
||||||
|
import forge.game.event.GameEventCardStatsChanged;
|
||||||
import forge.game.keyword.Keyword;
|
import forge.game.keyword.Keyword;
|
||||||
import forge.game.mana.Mana;
|
import forge.game.mana.Mana;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
@@ -465,6 +467,48 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
|||||||
payingMana.clear();
|
payingMana.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void applyPayingManaEffects() {
|
||||||
|
Card host = getHostCard();
|
||||||
|
|
||||||
|
for (Mana mana : getPayingMana()) {
|
||||||
|
if (mana.triggersWhenSpent()) {
|
||||||
|
mana.getManaAbility().addTriggersWhenSpent(this, host);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mana.addsCounters(this)) {
|
||||||
|
mana.getManaAbility().createETBCounters(host, getActivatingPlayer());
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mana.addsNoCounterMagic(this) && host != null) {
|
||||||
|
host.setCanCounter(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (isSpell() && host != null) {
|
||||||
|
if (mana.addsKeywords(this) && mana.addsKeywordsType()
|
||||||
|
&& host.getType().hasStringType(mana.getManaAbility().getAddsKeywordsType())) {
|
||||||
|
final long timestamp = host.getGame().getNextTimestamp();
|
||||||
|
final List<String> kws = Arrays.asList(mana.getAddedKeywords().split(" & "));
|
||||||
|
host.addChangedCardKeywords(kws, null, false, false, timestamp);
|
||||||
|
if (mana.addsKeywordsUntil()) {
|
||||||
|
final GameCommand untilEOT = new GameCommand() {
|
||||||
|
private static final long serialVersionUID = -8285169579025607693L;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
host.removeChangedCardKeywords(timestamp);
|
||||||
|
host.getGame().fireEvent(new GameEventCardStatsChanged(host));
|
||||||
|
}
|
||||||
|
};
|
||||||
|
String until = mana.getManaAbility().getAddsKeywordsUntil();
|
||||||
|
if ("UntilEOT".equals(until)) {
|
||||||
|
host.getGame().getEndOfTurn().addUntil(untilEOT);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public ColorSet getPayingColors() {
|
public ColorSet getPayingColors() {
|
||||||
byte colors = 0;
|
byte colors = 0;
|
||||||
for (Mana m : payingMana) {
|
for (Mana m : payingMana) {
|
||||||
|
|||||||
@@ -299,6 +299,8 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
|||||||
runParams.put(AbilityKey.CurrentCastSpells, Lists.newArrayList(thisTurnCast));
|
runParams.put(AbilityKey.CurrentCastSpells, Lists.newArrayList(thisTurnCast));
|
||||||
game.getTriggerHandler().runTrigger(TriggerType.SpellAbilityCast, runParams, true);
|
game.getTriggerHandler().runTrigger(TriggerType.SpellAbilityCast, runParams, true);
|
||||||
|
|
||||||
|
sp.applyPayingManaEffects();
|
||||||
|
|
||||||
// Run SpellCast triggers
|
// Run SpellCast triggers
|
||||||
if (sp.isSpell()) {
|
if (sp.isSpell()) {
|
||||||
if (source.isCommander() && (ZoneType.Command == source.getCastFrom())
|
if (source.isCommander() && (ZoneType.Command == source.getCastFrom())
|
||||||
|
|||||||
Reference in New Issue
Block a user