mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 20:28:00 +00:00
remove getManaPaid() from SpellAbility because there is already a method getPayingMana()
Remove input/InputPayManaExecuteCommands.java, using Common input instead
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -15580,7 +15580,6 @@ forge-gui/src/main/java/forge/gui/input/InputConfirmMulligan.java svneol=native#
|
||||
forge-gui/src/main/java/forge/gui/input/InputLockUI.java -text
|
||||
forge-gui/src/main/java/forge/gui/input/InputPassPriority.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/gui/input/InputPayMana.java -text
|
||||
forge-gui/src/main/java/forge/gui/input/InputPayManaExecuteCommands.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/gui/input/InputPayManaOfCostPayment.java -text
|
||||
forge-gui/src/main/java/forge/gui/input/InputPayManaSimple.java svneol=native#text/plain
|
||||
forge-gui/src/main/java/forge/gui/input/InputPayManaX.java -text
|
||||
|
||||
@@ -109,7 +109,7 @@ public class ComputerUtilMana {
|
||||
}
|
||||
else {
|
||||
if ( ai.getManaPool().tryPayCostWithMana(sa, cost, mana) && !test)
|
||||
sa.getManaPaid().add(mana);
|
||||
sa.getPayingMana().add(mana);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -26,8 +26,8 @@ import forge.game.combat.Combat;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.cost.CostPart;
|
||||
import forge.game.cost.CostPartMana;
|
||||
import forge.game.cost.PaymentDecision;
|
||||
import forge.game.mana.Mana;
|
||||
import forge.game.mana.ManaCostBeingPaid;
|
||||
import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
@@ -717,9 +717,9 @@ public class PlayerControllerAi extends PlayerController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean payManaCost(CostPartMana costPartMana, PaymentDecision pd, SpellAbility sa) {
|
||||
public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa) {
|
||||
// TODO Auto-generated method stub
|
||||
return ComputerUtilMana.payManaCost(player, sa);
|
||||
return ComputerUtilMana.payManaCost(new ManaCostBeingPaid(toPay), sa, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -216,15 +216,18 @@ public class CostExile extends CostPartWithList {
|
||||
}
|
||||
}
|
||||
|
||||
public static final String HashListKey = "Exiled";
|
||||
/* (non-Javadoc)
|
||||
* @see forge.card.cost.CostPartWithList#getHashForList()
|
||||
*/
|
||||
@Override
|
||||
public String getHashForList() {
|
||||
// TODO Auto-generated method stub
|
||||
return "Exiled";
|
||||
return HashListKey;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public <T> T accept(ICostVisitor<T> visitor) {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
@@ -115,12 +115,20 @@ public class CostPartMana extends CostPart {
|
||||
return visitor.visit(this);
|
||||
}
|
||||
|
||||
public ManaCost getManaCostFor(SpellAbility sa) {
|
||||
if ( isExiledCreatureCost() && !sa.getPaidList(CostExile.HashListKey).isEmpty()) // back from the brink
|
||||
return sa.getPaidList(CostExile.HashListKey).get(0).getManaCost();
|
||||
else
|
||||
return getManaToPay();
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean payAsDecided(Player payer, PaymentDecision pd, SpellAbility sa) {
|
||||
// TODO Auto-generated method stub
|
||||
sa.getManaPaid().clear();
|
||||
return payer.getController().payManaCost(this, pd, sa);
|
||||
payer.getManaPool().clearManaPaid(sa, false);
|
||||
|
||||
// decision not used here, the whole payment is interactive!
|
||||
return payer.getController().payManaCost(this, sa);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -171,7 +171,7 @@ public class ManaPool implements Iterable<Mana> {
|
||||
paidAbs.add(saPayment); // assumes some part on the mana produced by the ability will get used
|
||||
for (final Mana mana : abManaPart.getLastManaProduced()) {
|
||||
if( tryPayCostWithMana(saPaidFor, manaCost, mana) )
|
||||
saPaidFor.getManaPaid().add(mana);
|
||||
saPaidFor.getPayingMana().add(mana);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public class ManaPool implements Iterable<Mana> {
|
||||
|
||||
boolean result = manaFound != null && tryPayCostWithMana(saPaidFor, manaCost, manaFound);
|
||||
if(result)
|
||||
saPaidFor.getManaPaid().add(manaFound);
|
||||
saPaidFor.getPayingMana().add(manaFound);
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -206,7 +206,6 @@ public class ManaPool implements Iterable<Mana> {
|
||||
return false;
|
||||
}
|
||||
manaCost.payMana(mana, this);
|
||||
sa.getPayingMana().add(mana);
|
||||
this.removeMana(mana);
|
||||
if (mana.addsNoCounterMagic(sa) && sa.getHostCard() != null) {
|
||||
sa.getHostCard().setCanCounter(false);
|
||||
|
||||
@@ -18,7 +18,6 @@ import forge.game.combat.Combat;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.cost.CostPart;
|
||||
import forge.game.cost.CostPartMana;
|
||||
import forge.game.cost.PaymentDecision;
|
||||
import forge.game.mana.Mana;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.replacement.ReplacementEffect;
|
||||
@@ -223,7 +222,10 @@ public abstract class PlayerController {
|
||||
public List<Card> cheatShuffle(List<Card> list) { return list; }
|
||||
public Collection<? extends PaperCard> complainCardsCantPlayWell(Deck myDeck) { return null; }
|
||||
|
||||
public abstract boolean payManaCost(CostPartMana costPartMana, PaymentDecision pd, SpellAbility sa);
|
||||
public final boolean payManaCost(CostPartMana costPartMana, SpellAbility sa) {
|
||||
return payManaCost(costPartMana.getManaCostFor(sa), costPartMana, sa);
|
||||
}
|
||||
public abstract boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa);
|
||||
|
||||
public abstract Map<Card, ManaCostShard> chooseCardsForConvoke(SpellAbility sa, ManaCost manaCost, List<Card> untappedCreats);
|
||||
|
||||
|
||||
@@ -476,7 +476,7 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
*
|
||||
* @return a {@link java.util.ArrayList} object.
|
||||
*/
|
||||
public ArrayList<Mana> getPayingMana() {
|
||||
public List<Mana> getPayingMana() {
|
||||
return this.payingMana;
|
||||
}
|
||||
|
||||
@@ -491,11 +491,6 @@ public abstract class SpellAbility extends CardTraitBase implements ISpellAbilit
|
||||
return this.paidAbilities;
|
||||
}
|
||||
|
||||
List<Mana> paidMana = new ArrayList<>();
|
||||
public List<Mana> getManaPaid() {
|
||||
return paidMana;
|
||||
}
|
||||
|
||||
// Combined PaidLists
|
||||
/**
|
||||
* <p>
|
||||
|
||||
@@ -44,8 +44,10 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
||||
private boolean bPaid = false;
|
||||
private Boolean canPayManaCost = null;
|
||||
|
||||
protected InputPayMana(SpellAbility saToPayFor) {
|
||||
this.player = saToPayFor.getActivatingPlayer();
|
||||
private boolean locked = false;
|
||||
|
||||
protected InputPayMana(SpellAbility saToPayFor, Player payer) {
|
||||
this.player = payer;
|
||||
this.game = player.getGame();
|
||||
this.saPaidFor = saToPayFor;
|
||||
}
|
||||
@@ -81,6 +83,11 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
||||
* @return a {@link forge.game.mana.ManaCostBeingPaid} object.
|
||||
*/
|
||||
protected void activateManaAbility(final Card card, ManaCostBeingPaid manaCost) {
|
||||
if ( locked ) {
|
||||
System.err.print("Should wait till previous call to playAbility finishes.");
|
||||
return;
|
||||
}
|
||||
|
||||
// make sure computer's lands aren't selected
|
||||
if (card.getController() != player) {
|
||||
return;
|
||||
@@ -190,6 +197,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
||||
onStateChanged();
|
||||
}
|
||||
};
|
||||
locked = true;
|
||||
game.getAction().invoke(proc);
|
||||
}
|
||||
|
||||
@@ -303,6 +311,7 @@ public abstract class InputPayMana extends InputSyncronizedBase {
|
||||
}
|
||||
|
||||
protected final void updateMessage() {
|
||||
locked = false;
|
||||
if (supportAutoPay()) {
|
||||
if (canPayManaCost == null) {
|
||||
//use AI utility to determine if mana cost can be paid if that hasn't been determined yet
|
||||
|
||||
@@ -1,106 +0,0 @@
|
||||
/*
|
||||
* Forge: Play Magic: the Gathering.
|
||||
* Copyright (C) 2011 Forge Team
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package forge.gui.input;
|
||||
|
||||
import forge.card.mana.ManaCost;
|
||||
import forge.game.card.Card;
|
||||
import forge.game.mana.ManaCostBeingPaid;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.spellability.SpellAbility;
|
||||
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
//if cost is paid, Command.execute() is called
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Input_PayManaCost_Ability class.
|
||||
* </p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class InputPayManaExecuteCommands extends InputPayMana {
|
||||
/**
|
||||
* Constant <code>serialVersionUID=3836655722696348713L</code>.
|
||||
*/
|
||||
private static final long serialVersionUID = 3836655722696348713L;
|
||||
|
||||
private ManaCost originalManaCost;
|
||||
private String message = "";
|
||||
|
||||
private boolean bPaid = false;
|
||||
public boolean isPaid() { return bPaid; }
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for Input_PayManaCost_Ability.
|
||||
* </p>
|
||||
*/
|
||||
public InputPayManaExecuteCommands(final Card sourceCard, final Player p, final String prompt, final ManaCost manaCost0) {
|
||||
super(new SpellAbility.EmptySa(sourceCard, p));
|
||||
this.originalManaCost = manaCost0;
|
||||
this.phyLifeToLose = 0;
|
||||
this.message = prompt;
|
||||
|
||||
this.manaCost = new ManaCostBeingPaid(this.originalManaCost);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected final void onPlayerSelected(Player selected, final MouseEvent triggerEvent) {
|
||||
if (player == selected) {
|
||||
if (player.canPayLife(this.phyLifeToLose + 2) && manaCost.payPhyrexian()) {
|
||||
this.phyLifeToLose += 2;
|
||||
}
|
||||
onStateChanged();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void done() {
|
||||
if (this.phyLifeToLose > 0) {
|
||||
player.payLife(this.phyLifeToLose, null);
|
||||
}
|
||||
player.getManaPool().clearManaPaid(this.saPaidFor, false);
|
||||
bPaid = true;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected final void onCancel() {
|
||||
player.getManaPool().refundManaPaid(this.saPaidFor);
|
||||
bPaid = false;
|
||||
this.stop();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
protected String getMessage() {
|
||||
final StringBuilder msg = new StringBuilder(this.message + "\nPay Mana Cost: " + this.manaCost);
|
||||
if (this.phyLifeToLose > 0) {
|
||||
msg.append(" (");
|
||||
msg.append(this.phyLifeToLose);
|
||||
msg.append(" life paid for phyrexian mana)");
|
||||
}
|
||||
|
||||
if (this.manaCost.containsPhyrexianMana()) {
|
||||
msg.append("\n(Click on your life total to pay life for phyrexian mana.)");
|
||||
}
|
||||
return msg.toString();
|
||||
}
|
||||
}
|
||||
@@ -8,8 +8,8 @@ import forge.game.spellability.SpellAbility;
|
||||
import java.awt.event.MouseEvent;
|
||||
|
||||
public class InputPayManaOfCostPayment extends InputPayMana {
|
||||
public InputPayManaOfCostPayment(ManaCostBeingPaid cost, SpellAbility spellAbility) {
|
||||
super(spellAbility);
|
||||
public InputPayManaOfCostPayment(ManaCostBeingPaid cost, SpellAbility spellAbility, Player payer) {
|
||||
super(spellAbility, payer);
|
||||
manaCost = cost;
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public class InputPayManaSimple extends InputPayMana {
|
||||
private final ManaCost originalManaCost;
|
||||
|
||||
public InputPayManaSimple(final Game game, final SpellAbility sa, final ManaCostBeingPaid manaCostToPay) {
|
||||
super(sa);
|
||||
super(sa, sa.getActivatingPlayer());
|
||||
this.originalManaCost = manaCostToPay.toManaCost();
|
||||
this.originalCard = sa.getHostCard();
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ public class InputPayManaX extends InputPayMana {
|
||||
private boolean canceled = false;
|
||||
|
||||
public InputPayManaX(final SpellAbility sa0, final int amountX, final boolean xCanBe0) {
|
||||
super(sa0);
|
||||
super(sa0, sa0.getActivatingPlayer());
|
||||
xPaid = 0;
|
||||
|
||||
if (saPaidFor.hasParam("XColor")) {
|
||||
|
||||
@@ -626,9 +626,13 @@ public class HumanPlay {
|
||||
String promptCurrent = current == null ? "" : "Current Card: " + current;
|
||||
prompt = source + "\n" + promptCurrent;
|
||||
}
|
||||
InputPayMana toSet = new InputPayManaExecuteCommands(source, p, prompt, cost.getCostMana().getManaToPay());
|
||||
toSet.showAndWait();
|
||||
return toSet.isPaid();
|
||||
|
||||
p.getManaPool().clearManaPaid(sourceAbility, false);
|
||||
boolean paid = p.getController().payManaCost(cost.getCostMana(), sourceAbility);
|
||||
if (!paid) {
|
||||
p.getManaPool().refundManaPaid(sourceAbility);
|
||||
}
|
||||
return paid;
|
||||
}
|
||||
|
||||
private static boolean payCostPart(SpellAbility sourceAbility, CostPartWithList cpl, int amount, List<Card> list, String actionName) {
|
||||
@@ -704,7 +708,7 @@ public class HumanPlay {
|
||||
return false;
|
||||
}
|
||||
if (!toPay.isPaid()) {
|
||||
inpPayment = new InputPayManaOfCostPayment(toPay, ability);
|
||||
inpPayment = new InputPayManaOfCostPayment(toPay, ability, activator);
|
||||
inpPayment.showAndWait();
|
||||
if (!inpPayment.isPaid()) {
|
||||
return handleOfferingAndConvoke(ability, true, false);
|
||||
|
||||
@@ -116,7 +116,6 @@ public class HumanPlaySpellAbility {
|
||||
}
|
||||
else {
|
||||
this.enusureAbilityHasDescription(this.ability);
|
||||
this.ability.getActivatingPlayer().getManaPool().clearManaPaid(this.ability, false);
|
||||
game.getStack().addAndUnfreeze(this.ability);
|
||||
}
|
||||
|
||||
|
||||
@@ -26,7 +26,6 @@ import forge.game.combat.Combat;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.cost.CostPart;
|
||||
import forge.game.cost.CostPartMana;
|
||||
import forge.game.cost.PaymentDecision;
|
||||
import forge.game.mana.Mana;
|
||||
import forge.game.phase.PhaseType;
|
||||
import forge.game.player.LobbyPlayer;
|
||||
@@ -1063,13 +1062,7 @@ public class PlayerControllerHuman extends PlayerController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean payManaCost(CostPartMana costPartMana, PaymentDecision pd, SpellAbility sa) {
|
||||
ManaCost toPay;
|
||||
if ( costPartMana.isExiledCreatureCost() ) // back from the brink
|
||||
toPay = sa.getPaidList("Exiled").get(0).getManaCost();
|
||||
else
|
||||
toPay = costPartMana.getManaToPay();
|
||||
|
||||
public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa) {
|
||||
return HumanPlay.payManaCost(toPay, costPartMana, sa, player);
|
||||
}
|
||||
|
||||
|
||||
@@ -29,8 +29,8 @@ import forge.game.combat.CombatUtil;
|
||||
import forge.game.cost.Cost;
|
||||
import forge.game.cost.CostPart;
|
||||
import forge.game.cost.CostPartMana;
|
||||
import forge.game.cost.PaymentDecision;
|
||||
import forge.game.mana.Mana;
|
||||
import forge.game.mana.ManaCostBeingPaid;
|
||||
import forge.game.player.LobbyPlayer;
|
||||
import forge.game.player.Player;
|
||||
import forge.game.player.PlayerActionConfirmMode;
|
||||
@@ -566,9 +566,9 @@ public class PlayerControllerForTests extends PlayerController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean payManaCost(CostPartMana costPartMana, PaymentDecision pd, SpellAbility sa) {
|
||||
public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa) {
|
||||
// TODO Auto-generated method stub
|
||||
return ComputerUtilMana.payManaCost(player, sa);
|
||||
return ComputerUtilMana.payManaCost(new ManaCostBeingPaid(toPay), sa, player);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
Reference in New Issue
Block a user