mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Correct detection of player when playing InputPayManaExecuteCommands (used by all that propagandas)
Pay X mana (when spell is about to hit stack) is made by payManaX - it might have problems paying costs like 2XX
This commit is contained in:
@@ -956,14 +956,7 @@ public class Card extends GameEntity implements Comparable<Card> {
|
||||
return this.sunburstValue;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Setter for the field <code>colorsPaid</code>.
|
||||
* </p>
|
||||
*
|
||||
* @param s
|
||||
* a String
|
||||
*/
|
||||
// TODO: Append colors instead of replacing
|
||||
public final void setColorsPaid(final String s) {
|
||||
this.colorsPaid = s;
|
||||
}
|
||||
|
||||
@@ -25,7 +25,6 @@ import com.google.common.collect.Iterables;
|
||||
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.phase.CombatUtil;
|
||||
import forge.game.phase.Untap;
|
||||
import forge.game.player.Player;
|
||||
import forge.util.PredicateString;
|
||||
|
||||
@@ -168,12 +167,6 @@ public final class CardPredicates {
|
||||
}
|
||||
};
|
||||
|
||||
public static final Predicate<Card> CANUNTAP = new Predicate<Card>() {
|
||||
@Override
|
||||
public boolean apply(Card c) {
|
||||
return Untap.canUntap(c);
|
||||
}
|
||||
};
|
||||
/**
|
||||
* a Predicate<Card> to get all cards that are untapped.
|
||||
*/
|
||||
|
||||
@@ -462,7 +462,7 @@ public class CardFactorySorceries {
|
||||
game.getAction().moveToPlay(newArtifact[0]);
|
||||
} else {
|
||||
final int diffCost = newCMC - baseCMC;
|
||||
InputPayManaExecuteCommands inp = new InputPayManaExecuteCommands(game, "Pay difference in artifacts CMC", ManaCost.get(diffCost));
|
||||
InputPayManaExecuteCommands inp = new InputPayManaExecuteCommands(p, "Pay difference in artifacts CMC", ManaCost.get(diffCost));
|
||||
FThreads.setInputAndWait(inp);
|
||||
if ( inp.isPaid() )
|
||||
game.getAction().moveToPlay(newArtifact[0]);
|
||||
|
||||
@@ -75,7 +75,7 @@ public class CostPartMana extends CostPart {
|
||||
*
|
||||
* @return the x mana
|
||||
*/
|
||||
public final int getXMana() {
|
||||
public final int getAmountOfX() {
|
||||
return this.amountX;
|
||||
}
|
||||
|
||||
@@ -85,7 +85,7 @@ public class CostPartMana extends CostPart {
|
||||
* @param xCost
|
||||
* the new x mana
|
||||
*/
|
||||
public final void setXMana(final int xCost) {
|
||||
public final void setAmountOfX(final int xCost) {
|
||||
this.amountX = xCost;
|
||||
}
|
||||
|
||||
@@ -210,7 +210,7 @@ public class CostPartMana extends CostPart {
|
||||
// if X cost is a defined value, other than xPaid
|
||||
if (!ability.getSVar("X").equals("Count$xPaid")) {
|
||||
// this currently only works for things about Targeted object
|
||||
manaToAdd = AbilityUtils.calculateAmount(source, "X", ability) * this.getXMana();
|
||||
manaToAdd = AbilityUtils.calculateAmount(source, "X", ability) * this.getAmountOfX();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -221,9 +221,9 @@ public class CostPartMana extends CostPart {
|
||||
if(!inpPayment.isPaid())
|
||||
return false;
|
||||
}
|
||||
if (this.getXMana() > 0) {
|
||||
if (this.getAmountOfX() > 0) {
|
||||
source.setXManaCostPaid(0);
|
||||
InputPayment inpPayment = new InputPayManaX(game, ability, this);
|
||||
InputPayment inpPayment = new InputPayManaX(game, ability, this.getAmountOfX(), this.canXbe0());
|
||||
FThreads.setInputAndWait(inpPayment);
|
||||
if(!inpPayment.isPaid())
|
||||
return false;
|
||||
|
||||
@@ -145,7 +145,7 @@ public class CostUtil {
|
||||
CostPartMana newCostMana = cost2.getCostMana();
|
||||
if (newCostMana != null) {
|
||||
ManaCostBeingPaid oldManaCost = new ManaCostBeingPaid(part.toString());
|
||||
newCostMana.setXMana(oldManaCost.getXcounter() + newCostMana.getXMana());
|
||||
newCostMana.setAmountOfX(oldManaCost.getXcounter() + newCostMana.getAmountOfX());
|
||||
oldManaCost.combineManaCost(newCostMana.toString());
|
||||
newCostMana.setMana(oldManaCost.toString(false));
|
||||
} else {
|
||||
|
||||
@@ -21,7 +21,6 @@ import forge.Singletons;
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
import forge.game.player.Player;
|
||||
import forge.view.ButtonUtil;
|
||||
|
||||
@@ -47,9 +46,6 @@ public class InputPayManaExecuteCommands extends InputPayManaBase implements Inp
|
||||
private boolean bPaid = false;
|
||||
public boolean isPaid() { return bPaid; }
|
||||
|
||||
// only used for X costs:
|
||||
private boolean showOnlyOKButton = false;
|
||||
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -65,30 +61,13 @@ public class InputPayManaExecuteCommands extends InputPayManaBase implements Inp
|
||||
* @param unpaidCommand2
|
||||
* a {@link forge.Command} object.
|
||||
*/
|
||||
public InputPayManaExecuteCommands(final GameState game, final String prompt, final ManaCost manaCost2) {
|
||||
this(game, prompt, manaCost2, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for Input_PayManaCost_Ability.
|
||||
* </p>
|
||||
*
|
||||
* @param prompt
|
||||
* a {@link java.lang.String} object.
|
||||
* @param manaCost2
|
||||
* a {@link java.lang.String} object.
|
||||
* @param paidCommand2
|
||||
* a {@link forge.Command} object.
|
||||
* @param unpaidCommand2
|
||||
* a {@link forge.Command} object.
|
||||
* @param showOKButton
|
||||
* a boolean.
|
||||
*/
|
||||
public InputPayManaExecuteCommands(final GameState game, final String prompt, final ManaCost manaCost2, final boolean showOKButton) {
|
||||
super(game, new SpellAbility(null) {
|
||||
public InputPayManaExecuteCommands(final Player p, final String prompt, final ManaCost manaCost2) {
|
||||
super(p.getGame(), new SpellAbility(null) {
|
||||
@Override
|
||||
public void resolve() {}
|
||||
|
||||
@Override
|
||||
public Player getActivatingPlayer() { return p; }
|
||||
|
||||
@Override
|
||||
public boolean canPlay() { return false; }
|
||||
@@ -98,7 +77,7 @@ public class InputPayManaExecuteCommands extends InputPayManaBase implements Inp
|
||||
this.message = prompt;
|
||||
|
||||
this.manaCost = new ManaCostBeingPaid(this.originalManaCost);
|
||||
this.showOnlyOKButton = showOKButton;
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,20 +127,12 @@ public class InputPayManaExecuteCommands extends InputPayManaBase implements Inp
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void selectButtonOK() {
|
||||
if (this.showOnlyOKButton) {
|
||||
bPaid = false;
|
||||
this.stop();
|
||||
}
|
||||
}
|
||||
public final void selectButtonOK() {}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void showMessage() {
|
||||
ButtonUtil.enableOnlyCancel();
|
||||
if (this.showOnlyOKButton) {
|
||||
ButtonUtil.enableOnlyOk();
|
||||
}
|
||||
final StringBuilder msg = new StringBuilder(this.message + "Pay Mana Cost: " + this.manaCost);
|
||||
if (this.phyLifeToLose > 0) {
|
||||
msg.append(" (");
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.control.input;
|
||||
|
||||
import forge.Card;
|
||||
import forge.card.cost.CostPartMana;
|
||||
import forge.card.mana.ManaCostBeingPaid;
|
||||
import forge.card.spellability.SpellAbility;
|
||||
import forge.game.GameState;
|
||||
@@ -13,19 +12,20 @@ public class InputPayManaX extends InputPayManaBase {
|
||||
private final String colorX;
|
||||
private final String strX;
|
||||
private String colorsPaid;
|
||||
private final CostPartMana costMana;
|
||||
private final boolean xCanBe0;
|
||||
|
||||
|
||||
public InputPayManaX(final GameState game, final SpellAbility sa0, final CostPartMana costMana0)
|
||||
public InputPayManaX(final GameState game, final SpellAbility sa0, final int amountX, final boolean xCanBe0)
|
||||
{
|
||||
super(game, sa0);
|
||||
|
||||
xPaid = 0;
|
||||
colorX = saPaidFor.hasParam("XColor") ? saPaidFor.getParam("XColor") : "";
|
||||
colorsPaid = saPaidFor.getSourceCard().getColorsPaid();
|
||||
costMana = costMana0;
|
||||
strX = Integer.toString(costMana.getXMana());
|
||||
|
||||
strX = Integer.toString(amountX);
|
||||
manaCost = new ManaCostBeingPaid(strX);
|
||||
this.xCanBe0 = xCanBe0;
|
||||
}
|
||||
|
||||
/* (non-Javadoc)
|
||||
@@ -35,7 +35,7 @@ public class InputPayManaX extends InputPayManaBase {
|
||||
public boolean isPaid() {
|
||||
//return !( xPaid == 0 && !costMana.canXbe0() || this.colorX.equals("") && !this.manaCost.toString().equals(strX) );
|
||||
// return !( xPaid == 0 && !costMana.canXbe0()) && !(this.colorX.equals("") && !this.manaCost.toString().equals(strX));
|
||||
return ( xPaid > 0 || costMana.canXbe0()) && (!this.colorX.equals("") || this.manaCost.toString().equals(strX));
|
||||
return ( xPaid > 0 || xCanBe0) && (!this.colorX.equals("") || this.manaCost.toString().equals(strX));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -51,7 +51,7 @@ public class InputPayManaX extends InputPayManaBase {
|
||||
StringBuilder msg = new StringBuilder("Pay X Mana Cost for ");
|
||||
msg.append(saPaidFor.getSourceCard().getName()).append("\n").append(this.xPaid);
|
||||
msg.append(" Paid so far.");
|
||||
if (!costMana.canXbe0()) {
|
||||
if (!xCanBe0) {
|
||||
msg.append(" X Can't be 0.");
|
||||
}
|
||||
|
||||
|
||||
@@ -585,7 +585,7 @@ public final class GameActionUtil {
|
||||
if (!(costPart instanceof CostPartMana ))
|
||||
throw new RuntimeException("GameActionUtil.payCostDuringAbilityResolve - The remaining payment type is not Mana.");
|
||||
|
||||
InputPayment toSet = new InputPayManaExecuteCommands(game, source + "\r\n", ability.getManaCost());
|
||||
InputPayment toSet = new InputPayManaExecuteCommands(p, source + "\r\n", ability.getManaCost());
|
||||
FThreads.setInputAndWait(toSet);
|
||||
return toSet.isPaid();
|
||||
}
|
||||
|
||||
@@ -31,18 +31,13 @@ import forge.CounterType;
|
||||
import forge.FThreads;
|
||||
import forge.GameEntity;
|
||||
import forge.Singletons;
|
||||
import forge.control.input.InputBase;
|
||||
import forge.control.input.InputSelectCards;
|
||||
import forge.control.input.InputSelectCardsFromList;
|
||||
import forge.control.input.InputSyncronizedBase;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtilCard;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.zone.Zone;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.GuiDialog;
|
||||
import forge.gui.match.CMatchUI;
|
||||
import forge.view.ButtonUtil;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -245,7 +240,7 @@ public class Untap extends Phase {
|
||||
final List<Card> creatures = CardLists.filter(player.getCreaturesInPlay(), tappedCanUntap);
|
||||
if (!creatures.isEmpty()) {
|
||||
if (player.isComputer()) {
|
||||
creatures.get(0).untap();
|
||||
ComputerUtilCard.getBestCreatureAI(creatures).untap();
|
||||
} else {
|
||||
final InputSelectCards target = new InputSelectCardsFromList(1, 1, creatures);
|
||||
target.setMessage("Select one creature to untap");
|
||||
|
||||
@@ -275,7 +275,7 @@ public class Upkeep extends Phase {
|
||||
public void resolve() {
|
||||
final boolean isUpkeepPaid;
|
||||
if (controller.isHuman()) {
|
||||
InputPayManaExecuteCommands inp = new InputPayManaExecuteCommands(game, sb, upkeepCost);
|
||||
InputPayManaExecuteCommands inp = new InputPayManaExecuteCommands(controller, sb, upkeepCost);
|
||||
FThreads.setInputAndWait(inp);
|
||||
isUpkeepPaid = inp.isPaid();
|
||||
} else { // computer
|
||||
@@ -360,7 +360,7 @@ public class Upkeep extends Phase {
|
||||
public void resolve() {
|
||||
boolean isUpkeepPaid = false;
|
||||
if (controller.isHuman()) {
|
||||
InputPayManaExecuteCommands inp = new InputPayManaExecuteCommands(game, sb, upkeepCost);
|
||||
InputPayManaExecuteCommands inp = new InputPayManaExecuteCommands(controller, sb, upkeepCost);
|
||||
FThreads.setInputAndWait(inp);
|
||||
isUpkeepPaid = inp.isPaid();
|
||||
} else { // computers
|
||||
@@ -602,7 +602,7 @@ public class Upkeep extends Phase {
|
||||
@Override
|
||||
public void resolve() {
|
||||
if (game.getZoneOf(c).is(ZoneType.Battlefield)) {
|
||||
InputPayManaExecuteCommands inp = new InputPayManaExecuteCommands(game, "Pay Demonic Hordes upkeep cost", cost.getManaCost() /*, true */);
|
||||
InputPayManaExecuteCommands inp = new InputPayManaExecuteCommands(cp, "Pay Demonic Hordes upkeep cost", cost.getManaCost() /*, true */);
|
||||
FThreads.setInputAndWait(inp);
|
||||
if ( !inp.isPaid() )
|
||||
unpaidHordesAb.resolve();
|
||||
|
||||
@@ -47,6 +47,8 @@ import forge.card.trigger.Trigger;
|
||||
import forge.card.trigger.TriggerType;
|
||||
import forge.control.input.InputBase;
|
||||
import forge.control.input.InputPayManaExecuteCommands;
|
||||
import forge.control.input.InputPayManaX;
|
||||
import forge.control.input.InputSynchronized;
|
||||
import forge.game.GameActionUtil;
|
||||
import forge.game.GameState;
|
||||
import forge.game.ai.ComputerUtil;
|
||||
@@ -390,23 +392,9 @@ public class MagicStack extends MyObservable {
|
||||
final int xCost = sa.getXManaCost();
|
||||
Player player = sp.getSourceCard().getController();
|
||||
if (player.isHuman()) {
|
||||
final Runnable payNextX = new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
|
||||
final Card crd = sa.getSourceCard();
|
||||
|
||||
String message = "Pay X cost for " + crd.getName() + " (X=" + crd.getXManaCostPaid() + ")\r\n";
|
||||
InputPayManaExecuteCommands inp = new InputPayManaExecuteCommands(game, message, ManaCost.get(xCost), true);
|
||||
FThreads.setInputAndWait(inp);
|
||||
if ( inp.isPaid() ) {
|
||||
crd.addXManaCostPaid(1);
|
||||
this.run();
|
||||
} else
|
||||
MagicStack.this.push(sa);
|
||||
}
|
||||
};
|
||||
payNextX.run();
|
||||
InputSynchronized inp = new InputPayManaX(game, sa, xCost, true);
|
||||
FThreads.setInputAndWait(inp);
|
||||
MagicStack.this.push(sa);
|
||||
} else {
|
||||
// computer
|
||||
final int neededDamage = CardFactoryUtil.getNeededXDamage(sa);
|
||||
@@ -436,7 +424,7 @@ public class MagicStack extends MyObservable {
|
||||
}
|
||||
};
|
||||
|
||||
Player activating = sp.getActivatingPlayer();
|
||||
final Player activating = sp.getActivatingPlayer();
|
||||
|
||||
if (activating.isHuman()) {
|
||||
sa.getSourceCard().addMultiKickerMagnitude(-1);
|
||||
@@ -446,15 +434,14 @@ public class MagicStack extends MyObservable {
|
||||
abilityIncreaseMultikicker.resolve();
|
||||
int mkMagnitude = sa.getSourceCard().getMultiKickerMagnitude();
|
||||
String prompt = String.format("Multikicker for %s\r\nTimes Kicked: %d\r\n", sa.getSourceCard(), mkMagnitude );
|
||||
InputPayManaExecuteCommands toSet = new InputPayManaExecuteCommands(game, prompt, sp.getMultiKickerManaCost());
|
||||
InputPayManaExecuteCommands toSet = new InputPayManaExecuteCommands(activating, prompt, sp.getMultiKickerManaCost());
|
||||
FThreads.setInputAndWait(toSet);
|
||||
if ( toSet.isPaid() ) {
|
||||
this.run();
|
||||
} else
|
||||
MagicStack.this.push(sa);
|
||||
|
||||
}
|
||||
};
|
||||
};
|
||||
paidCommand.run();
|
||||
} else {
|
||||
// computer
|
||||
@@ -480,7 +467,7 @@ public class MagicStack extends MyObservable {
|
||||
};
|
||||
|
||||
|
||||
Player controller = sp.getSourceCard().getController();
|
||||
final Player controller = sp.getSourceCard().getController();
|
||||
if (controller.isHuman()) {
|
||||
sa.getSourceCard().addReplicateMagnitude(-1);
|
||||
final Runnable addMagnitude = new Runnable() {
|
||||
@@ -488,7 +475,7 @@ public class MagicStack extends MyObservable {
|
||||
public void run() {
|
||||
ability.resolve();
|
||||
String prompt = String.format("Replicate for %s\r\nTimes Replicated: %d\r\n", sa.getSourceCard(), sa.getSourceCard().getReplicateMagnitude());
|
||||
InputPayManaExecuteCommands toSet = new InputPayManaExecuteCommands(game, prompt, sp.getReplicateManaCost());
|
||||
InputPayManaExecuteCommands toSet = new InputPayManaExecuteCommands(controller, prompt, sp.getReplicateManaCost());
|
||||
FThreads.setInputAndWait(toSet);
|
||||
if ( toSet.isPaid() ) {
|
||||
this.run();
|
||||
|
||||
Reference in New Issue
Block a user