Update Word of Command mana payment check conditions

This commit is contained in:
Lyu Zong-Hong
2021-03-28 15:09:01 +09:00
parent 6a56e29474
commit 7fc85a47be
7 changed files with 41 additions and 15 deletions

View File

@@ -1531,7 +1531,7 @@ public class ComputerUtilMana {
public boolean apply(final Card c) { public boolean apply(final Card c) {
for (final SpellAbility am : getAIPlayableMana(c)) { for (final SpellAbility am : getAIPlayableMana(c)) {
am.setActivatingPlayer(ai); am.setActivatingPlayer(ai);
if (!checkPlayable || am.canPlay()) { if (!checkPlayable || (am.canPlay() && am.checkRestrictions(ai))) {
return true; return true;
} }
} }

View File

@@ -2,12 +2,13 @@ package forge.game;
import forge.card.ColorSet; import forge.card.ColorSet;
import forge.card.MagicColor; import forge.card.MagicColor;
import forge.card.mana.ManaAtom;
import forge.game.ability.AbilityUtils; import forge.game.ability.AbilityUtils;
import forge.game.card.Card; import forge.game.card.Card;
import forge.game.card.CardState; import forge.game.card.CardState;
import forge.game.cost.Cost; import forge.game.cost.Cost;
import forge.game.mana.ManaCostBeingPaid;
import forge.game.player.Player; import forge.game.player.Player;
import forge.game.spellability.AbilityManaPart;
import forge.game.spellability.SpellAbility; import forge.game.spellability.SpellAbility;
import forge.game.staticability.StaticAbility; import forge.game.staticability.StaticAbility;
import forge.util.Expressions; import forge.util.Expressions;
@@ -191,17 +192,24 @@ public class ForgeScript {
return false; return false;
} }
} else if (property.equals("ManaAbilityCantPaidFor")) { } else if (property.equals("ManaAbilityCantPaidFor")) {
if (!sa.isManaAbility()) {
return false;
}
SpellAbility paidFor = sourceController.getPaidForSA(); SpellAbility paidFor = sourceController.getPaidForSA();
do { if (paidFor == null) {
AbilityManaPart mana = sa.getManaPart(); return false;
if (paidFor != null && mana.meetsManaRestrictions(paidFor) && !mana.getExpressChoice().isEmpty()) { }
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;
}
}
if (manaCost.isAnyPartPayableWith((byte) ManaAtom.GENERIC, sourceController.getManaPool())) {
colorCanUse |= ManaAtom.GENERIC;
}
if (sa.isManaAbilityFor(paidFor, colorCanUse)) {
return false; return false;
} }
sa = sa.getSubAbility();
} while(sa != null);
} else if (sa.getHostCard() != null) { } else if (sa.getHostCard() != null) {
return sa.getHostCard().hasProperty(property, sourceController, source, spellAbility); return sa.getHostCard().hasProperty(property, sourceController, source, spellAbility);
} }

View File

@@ -22,6 +22,7 @@ import forge.game.card.Card;
import forge.game.card.CardCollection; import forge.game.card.CardCollection;
import forge.game.card.CardFactoryUtil; import forge.game.card.CardFactoryUtil;
import forge.game.cost.Cost; import forge.game.cost.Cost;
import forge.game.mana.ManaCostBeingPaid;
import forge.game.player.Player; import forge.game.player.Player;
import forge.game.replacement.ReplacementEffect; import forge.game.replacement.ReplacementEffect;
import forge.game.replacement.ReplacementHandler; import forge.game.replacement.ReplacementHandler;
@@ -312,7 +313,11 @@ public class PlayEffect extends SpellAbilityEffect {
tgtSA.setSVar("IsCastFromPlayEffect", "True"); tgtSA.setSVar("IsCastFromPlayEffect", "True");
// Add controlled by player to target SA so when the spell is resolving, the controller would be changed again // Add controlled by player to target SA so when the spell is resolving, the controller would be changed again
if (controlledByPlayer != null) {
tgtSA.setControlledByPlayer(controlledByTimeStamp, controlledByPlayer); 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 (controller.getController().playSaFromPlayEffect(tgtSA)) {
if (remember) { if (remember) {
@@ -335,6 +340,7 @@ public class PlayEffect extends SpellAbilityEffect {
// Remove controlled by player if any // Remove controlled by player if any
if (controlledByPlayer != null) { if (controlledByPlayer != null) {
activator.removeController(controlledByTimeStamp); activator.removeController(controlledByTimeStamp);
activator.popPaidForSA();
} }
} // end resolve } // end resolve

View File

@@ -63,6 +63,7 @@ import forge.game.cost.CostRemoveCounter;
import forge.game.event.GameEventCardStatsChanged; 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.mana.ManaCostBeingPaid;
import forge.game.player.Player; import forge.game.player.Player;
import forge.game.player.PlayerCollection; import forge.game.player.PlayerCollection;
import forge.game.replacement.ReplacementEffect; import forge.game.replacement.ReplacementEffect;
@@ -110,6 +111,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
private Player activatingPlayer = null; private Player activatingPlayer = null;
private Player targetingPlayer = null; private Player targetingPlayer = null;
private Pair<Long, Player> controlledByPlayer = null; private Pair<Long, Player> controlledByPlayer = null;
private ManaCostBeingPaid manaCostBeingPaid = null;
private SpellAbility grantorOriginal = null; private SpellAbility grantorOriginal = null;
private StaticAbility grantorStatic = 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 isSpell() { return false; }
public boolean isAbility() { return true; } public boolean isAbility() { return true; }
public boolean isActivatedAbility() { return false; } public boolean isActivatedAbility() { return false; }

View File

@@ -518,6 +518,7 @@ public class MagicStack /* extends MyObservable */ implements Iterable<SpellAbil
sa.getActivatingPlayer().removeController(sa.getControlledByPlayer().getLeft()); sa.getActivatingPlayer().removeController(sa.getControlledByPlayer().getLeft());
// Cleanup controlled by player states // Cleanup controlled by player states
sa.setControlledByPlayer(-1, null); sa.setControlledByPlayer(-1, null);
sa.setManaCostBeingPaid(null);
} }
game.fireEvent(new GameEventSpellResolved(sa, thisHasFizzled)); game.fireEvent(new GameEventSpellResolved(sa, thisHasFizzled));

View File

@@ -57,9 +57,6 @@ public abstract class InputPayMana extends InputSyncronizedBase {
game = player.getGame(); game = player.getGame();
saPaidFor = saPaidFor0; saPaidFor = saPaidFor0;
// Set current paid for SA for player to be able to reference it later
player.pushPaidForSA(saPaidFor);
//if player is floating mana, show mana pool to make it easier to use that mana //if player is floating mana, show mana pool to make it easier to use that mana
wasFloatingMana = !player.getManaPool().isEmpty(); wasFloatingMana = !player.getManaPool().isEmpty();
if (wasFloatingMana) { if (wasFloatingMana) {
@@ -69,7 +66,8 @@ public abstract class InputPayMana extends InputSyncronizedBase {
@Override @Override
protected void onStop() { protected void onStop() {
// Clear current paid for SA // Clear current Mana cost being paid for SA
saPaidFor.setManaCostBeingPaid(null);
player.popPaidForSA(); player.popPaidForSA();
if (wasFloatingMana) { //hide mana pool if it was shown due to floating mana if (wasFloatingMana) { //hide mana pool if it was shown due to floating mana

View File

@@ -19,6 +19,10 @@ public class InputPayManaOfCostPayment extends InputPayMana {
manaCost = cost; manaCost = cost;
extraMatrix = matrix; extraMatrix = matrix;
applyMatrix(); applyMatrix();
// Set Mana cost being paid for SA to be able to reference it later
player.pushPaidForSA(saPaidFor);
saPaidFor.setManaCostBeingPaid(manaCost);
} }
private static final long serialVersionUID = 3467312982164195091L; private static final long serialVersionUID = 3467312982164195091L;