mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
Update Word of Command mana payment check conditions
This commit is contained in:
@@ -2,12 +2,13 @@ package forge.game;
|
||||
|
||||
import forge.card.ColorSet;
|
||||
import forge.card.MagicColor;
|
||||
import forge.card.mana.ManaAtom;
|
||||
import forge.game.ability.AbilityUtils;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.card.CardState;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.mana.ManaCostBeingPaid;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.AbilityManaPart;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
import forge.game.staticability.StaticAbility;
|
||||
import forge.util.Expressions;
|
||||
@@ -191,17 +192,24 @@ public class ForgeScript {
|
||||
return false;
|
||||
}
|
||||
} else if (property.equals("ManaAbilityCantPaidFor")) {
|
||||
if (!sa.isManaAbility()) {
|
||||
SpellAbility paidFor = sourceController.getPaidForSA();
|
||||
if (paidFor == null) {
|
||||
return false;
|
||||
}
|
||||
SpellAbility paidFor = sourceController.getPaidForSA();
|
||||
do {
|
||||
AbilityManaPart mana = sa.getManaPart();
|
||||
if (paidFor != null && mana.meetsManaRestrictions(paidFor) && !mana.getExpressChoice().isEmpty()) {
|
||||
return false;
|
||||
ManaCostBeingPaid manaCost = paidFor.getManaCostBeingPaid();
|
||||
// The following code is taken from InputPayMana.java, to determine if this mana ability can pay for SA currently being paid
|
||||
byte colorCanUse = 0;
|
||||
for (final byte color : ManaAtom.MANATYPES) {
|
||||
if (manaCost.isAnyPartPayableWith(color, sourceController.getManaPool())) {
|
||||
colorCanUse |= color;
|
||||
}
|
||||
sa = sa.getSubAbility();
|
||||
} while(sa != null);
|
||||
}
|
||||
if (manaCost.isAnyPartPayableWith((byte) ManaAtom.GENERIC, sourceController.getManaPool())) {
|
||||
colorCanUse |= ManaAtom.GENERIC;
|
||||
}
|
||||
if (sa.isManaAbilityFor(paidFor, colorCanUse)) {
|
||||
return false;
|
||||
}
|
||||
} else if (sa.getHostCard() != null) {
|
||||
return sa.getHostCard().hasProperty(property, sourceController, source, spellAbility);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@ import forge.game.card.Card;
|
||||
import forge.game.card.CardCollection;
|
||||
import forge.game.card.CardFactoryUtil;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.mana.ManaCostBeingPaid;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.replacement.ReplacementEffect;
|
||||
import forge.game.replacement.ReplacementHandler;
|
||||
@@ -312,7 +313,11 @@ public class PlayEffect extends SpellAbilityEffect {
|
||||
tgtSA.setSVar("IsCastFromPlayEffect", "True");
|
||||
|
||||
// Add controlled by player to target SA so when the spell is resolving, the controller would be changed again
|
||||
tgtSA.setControlledByPlayer(controlledByTimeStamp, controlledByPlayer);
|
||||
if (controlledByPlayer != null) {
|
||||
tgtSA.setControlledByPlayer(controlledByTimeStamp, controlledByPlayer);
|
||||
activator.pushPaidForSA(tgtSA);
|
||||
tgtSA.setManaCostBeingPaid(new ManaCostBeingPaid(tgtSA.getPayCosts().getCostMana().getManaCostFor(tgtSA), tgtSA.getPayCosts().getCostMana().getRestiction()));
|
||||
}
|
||||
|
||||
if (controller.getController().playSaFromPlayEffect(tgtSA)) {
|
||||
if (remember) {
|
||||
@@ -335,6 +340,7 @@ public class PlayEffect extends SpellAbilityEffect {
|
||||
// Remove controlled by player if any
|
||||
if (controlledByPlayer != null) {
|
||||
activator.removeController(controlledByTimeStamp);
|
||||
activator.popPaidForSA();
|
||||
}
|
||||
} // end resolve
|
||||
|
||||
|
||||
@@ -63,6 +63,7 @@ import forge.game.cost.CostRemoveCounter;
|
||||
import forge.game.event.GameEventCardStatsChanged;
|
||||
import forge.game.keyword.Keyword;
|
||||
import forge.game.mana.Mana;
|
||||
import forge.game.mana.ManaCostBeingPaid;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerCollection;
|
||||
import forge.game.replacement.ReplacementEffect;
|
||||
@@ -110,6 +111,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
private Player activatingPlayer = null;
|
||||
private Player targetingPlayer = null;
|
||||
private Pair<Long, Player> controlledByPlayer = null;
|
||||
private ManaCostBeingPaid manaCostBeingPaid = null;
|
||||
|
||||
private SpellAbility grantorOriginal = null;
|
||||
private StaticAbility grantorStatic = null;
|
||||
@@ -474,6 +476,13 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
}
|
||||
}
|
||||
|
||||
public ManaCostBeingPaid getManaCostBeingPaid() {
|
||||
return manaCostBeingPaid;
|
||||
}
|
||||
public void setManaCostBeingPaid(ManaCostBeingPaid costBeingPaid) {
|
||||
manaCostBeingPaid = costBeingPaid;
|
||||
}
|
||||
|
||||
public boolean isSpell() { return false; }
|
||||
public boolean isAbility() { return true; }
|
||||
public boolean isActivatedAbility() { return false; }
|
||||
|
||||
@@ -518,6 +518,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
|
||||
sa.getActivatingPlayer().removeController(sa.getControlledByPlayer().getLeft());
|
||||
// Cleanup controlled by player states
|
||||
sa.setControlledByPlayer(-1, null);
|
||||
sa.setManaCostBeingPaid(null);
|
||||
}
|
||||
|
||||
game.fireEvent(new GameEventSpellResolved(sa, thisHasFizzled));
|
||||
|
||||
Reference in New Issue
Block a user