mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
InputPayReturnCost.java removed for there's already input to select cards, and the very discard can be done from outside of input.
This commit is contained in:
1
.gitattributes
vendored
1
.gitattributes
vendored
@@ -13813,7 +13813,6 @@ src/main/java/forge/control/input/InputPayManaExecuteCommands.java svneol=native
|
|||||||
src/main/java/forge/control/input/InputPayManaOfCostPayment.java -text
|
src/main/java/forge/control/input/InputPayManaOfCostPayment.java -text
|
||||||
src/main/java/forge/control/input/InputPayManaSimple.java svneol=native#text/plain
|
src/main/java/forge/control/input/InputPayManaSimple.java svneol=native#text/plain
|
||||||
src/main/java/forge/control/input/InputPayManaX.java -text
|
src/main/java/forge/control/input/InputPayManaX.java -text
|
||||||
src/main/java/forge/control/input/InputPayReturnCost.java -text
|
|
||||||
src/main/java/forge/control/input/InputPayment.java -text
|
src/main/java/forge/control/input/InputPayment.java -text
|
||||||
src/main/java/forge/control/input/InputSelectCards.java -text
|
src/main/java/forge/control/input/InputSelectCards.java -text
|
||||||
src/main/java/forge/control/input/InputSelectCardsFromList.java -text
|
src/main/java/forge/control/input/InputSelectCardsFromList.java -text
|
||||||
|
|||||||
@@ -1,185 +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.control.input;
|
|
||||||
|
|
||||||
import java.util.List;
|
|
||||||
import forge.Card;
|
|
||||||
import forge.CardLists;
|
|
||||||
import forge.Singletons;
|
|
||||||
import forge.card.cardfactory.CardFactoryUtil;
|
|
||||||
import forge.card.cost.CostReturn;
|
|
||||||
import forge.card.spellability.SpellAbility;
|
|
||||||
import forge.game.zone.PlayerZone;
|
|
||||||
import forge.game.zone.ZoneType;
|
|
||||||
import forge.gui.match.CMatchUI;
|
|
||||||
import forge.view.ButtonUtil;
|
|
||||||
|
|
||||||
//if cost is paid, Command.execute() is called
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Input_PayManaCost_Ability class.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @author Forge
|
|
||||||
* @version $Id: InputPayManaCostAbility.java 15673 2012-05-23 14:01:35Z ArsenalNut $
|
|
||||||
*/
|
|
||||||
public class InputPayReturnCost extends InputSyncronizedBase implements InputPayment {
|
|
||||||
/**
|
|
||||||
* Constant <code>serialVersionUID=2685832214529141991L</code>.
|
|
||||||
*/
|
|
||||||
private static final long serialVersionUID = 8701146064257627671L;
|
|
||||||
|
|
||||||
private int numChosen = 0;
|
|
||||||
private int numRequired = 0;
|
|
||||||
private List<Card> choiceList;
|
|
||||||
private CostReturn returnCost;
|
|
||||||
private SpellAbility ability;
|
|
||||||
|
|
||||||
private boolean bPaid;
|
|
||||||
public boolean isPaid() { return bPaid; }
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Constructor for InputPayReturnCost.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param cost
|
|
||||||
* a {@link forge.card.cost.CostSacrifice} object.
|
|
||||||
* @param sa
|
|
||||||
* a {@link forge.card.spellability.SpellAbility} object.
|
|
||||||
* @param paidCommand
|
|
||||||
* a {@link forge.Command} object.
|
|
||||||
* @param unpaidCommand
|
|
||||||
* a {@link forge.Command} object.
|
|
||||||
*/
|
|
||||||
public InputPayReturnCost(final CostReturn cost, final SpellAbility sa) {
|
|
||||||
final Card source = sa.getSourceCard();
|
|
||||||
|
|
||||||
|
|
||||||
this.ability = sa;
|
|
||||||
this.returnCost = cost;
|
|
||||||
this.choiceList = CardLists.getValidCards(Singletons.getControl().getPlayer().getCardsIn(ZoneType.Battlefield), cost.getType().split(";"), Singletons.getControl().getPlayer(), source);
|
|
||||||
String amountString = cost.getAmount();
|
|
||||||
this.numRequired = amountString.matches("[0-9][0-9]?") ? Integer.parseInt(amountString)
|
|
||||||
: CardFactoryUtil.xCount(source, source.getSVar(amountString));
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public void showMessage() {
|
|
||||||
final StringBuilder msg = new StringBuilder("Return ");
|
|
||||||
final int nLeft = this.numRequired - this.numChosen;
|
|
||||||
msg.append(nLeft).append(" ");
|
|
||||||
msg.append(this.returnCost.getDescriptiveType());
|
|
||||||
if (nLeft > 1) {
|
|
||||||
msg.append("s");
|
|
||||||
}
|
|
||||||
msg.append(" to your hand");
|
|
||||||
if (!this.returnCost.getList().isEmpty()) {
|
|
||||||
msg.append("\r\nSelected:\r\n");
|
|
||||||
for (Card selected : this.returnCost.getList()) {
|
|
||||||
msg.append(selected + "\r\n");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
CMatchUI.SINGLETON_INSTANCE.showMessage(msg.toString());
|
|
||||||
if (nLeft > 0) {
|
|
||||||
ButtonUtil.enableOnlyCancel();
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
ButtonUtil.enableAllFocusOk();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public void selectButtonCancel() {
|
|
||||||
this.cancel();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public void selectButtonOK() {
|
|
||||||
this.done();
|
|
||||||
}
|
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
|
||||||
@Override
|
|
||||||
public void selectCard(final Card card) {
|
|
||||||
if (this.choiceList.contains(card) && this.numChosen < numRequired) {
|
|
||||||
this.numChosen++;
|
|
||||||
this.returnCost.addToList(card);
|
|
||||||
card.setUsedToPay(true);
|
|
||||||
this.choiceList.remove(card);
|
|
||||||
this.showMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* unselectCard.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param card
|
|
||||||
* a {@link forge.Card} object.
|
|
||||||
* @param zone
|
|
||||||
* a {@link forge.game.zone.PlayerZone} object.
|
|
||||||
*/
|
|
||||||
public void unselectCard(final Card card, final PlayerZone zone) {
|
|
||||||
if (this.returnCost.getList().contains(card)) {
|
|
||||||
this.numChosen--;
|
|
||||||
card.setUsedToPay(false);
|
|
||||||
this.returnCost.getList().remove(card);
|
|
||||||
this.choiceList.add(card);
|
|
||||||
this.showMessage();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* executes paid commmand.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void done() {
|
|
||||||
|
|
||||||
// actually sacrifice the cards
|
|
||||||
for (Card selected : this.returnCost.getList()) {
|
|
||||||
selected.setUsedToPay(false);
|
|
||||||
Singletons.getModel().getGame().getAction().moveTo(ZoneType.Hand, selected);
|
|
||||||
}
|
|
||||||
this.returnCost.addListToHash(ability, "Returned");
|
|
||||||
bPaid = true;
|
|
||||||
this.stop();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* executes unpaid commmand.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
*/
|
|
||||||
public void cancel() {
|
|
||||||
for (Card selected : this.returnCost.getList()) {
|
|
||||||
selected.setUsedToPay(false);
|
|
||||||
}
|
|
||||||
bPaid = false;
|
|
||||||
this.stop();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -59,8 +59,9 @@ import forge.card.spellability.SpellAbility;
|
|||||||
import forge.card.spellability.SpellAbilityRestriction;
|
import forge.card.spellability.SpellAbilityRestriction;
|
||||||
import forge.control.input.InputPayDiscardCostWithCommands;
|
import forge.control.input.InputPayDiscardCostWithCommands;
|
||||||
import forge.control.input.InputPayManaExecuteCommands;
|
import forge.control.input.InputPayManaExecuteCommands;
|
||||||
import forge.control.input.InputPayReturnCost;
|
|
||||||
import forge.control.input.InputPayment;
|
import forge.control.input.InputPayment;
|
||||||
|
import forge.control.input.InputSelectCards;
|
||||||
|
import forge.control.input.InputSelectCardsFromList;
|
||||||
import forge.game.event.CardDamagedEvent;
|
import forge.game.event.CardDamagedEvent;
|
||||||
import forge.game.event.LifeLossEvent;
|
import forge.game.event.LifeLossEvent;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
@@ -530,19 +531,33 @@ public final class GameActionUtil {
|
|||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = 0; i < amount; i++) {
|
List<Card> toSac = p.getController().choosePermanentsToSacrifice(list, amount, ability, false, false);
|
||||||
if (list.isEmpty()) {
|
if ( toSac.size() != amount ) {
|
||||||
hasPaid = false;
|
hasPaid = false;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
Object o = GuiChoose.one("Select a card to sacrifice", list);
|
for(Card c : toSac) {
|
||||||
if (o != null) {
|
|
||||||
final Card c = (Card) o;
|
|
||||||
|
|
||||||
Singletons.getModel().getGame().getAction().sacrifice(c, ability);
|
Singletons.getModel().getGame().getAction().sacrifice(c, ability);
|
||||||
|
|
||||||
list.remove(c);
|
|
||||||
}
|
}
|
||||||
|
remainingParts.remove(part);
|
||||||
|
}
|
||||||
|
|
||||||
|
else if (part instanceof CostReturn) {
|
||||||
|
List<Card> choiceList = CardLists.getValidCards(p.getCardsIn(ZoneType.Battlefield), part.getType().split(";"), p, source);
|
||||||
|
String amountString = part.getAmount();
|
||||||
|
int amount = amountString.matches("[0-9][0-9]?") ? Integer.parseInt(amountString) : CardFactoryUtil.xCount(source, source.getSVar(amountString));
|
||||||
|
|
||||||
|
InputSelectCards inp = new InputSelectCardsFromList(amount, amount, choiceList);
|
||||||
|
inp.setMessage("Select cards to return to hand");
|
||||||
|
inp.setCancelWithSelectedAllowed(true);
|
||||||
|
|
||||||
|
FThreads.setInputAndWait(inp);
|
||||||
|
if( inp.hasCancelled() || inp.getSelected().size() != amount) {
|
||||||
|
hasPaid = false;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
for(Card c : inp.getSelected()) {
|
||||||
|
p.getGame().getAction().moveTo(ZoneType.Hand, c);
|
||||||
}
|
}
|
||||||
remainingParts.remove(part);
|
remainingParts.remove(part);
|
||||||
}
|
}
|
||||||
@@ -574,19 +589,14 @@ public final class GameActionUtil {
|
|||||||
//the following costs need inputs and can't be combined at the moment
|
//the following costs need inputs and can't be combined at the moment
|
||||||
|
|
||||||
|
|
||||||
InputPayment toSet = null;
|
InputPayment toSet = null;;
|
||||||
if (costPart instanceof CostReturn) {
|
if (costPart instanceof CostDiscard) {
|
||||||
toSet = new InputPayReturnCost((CostReturn) costPart, ability);
|
|
||||||
}
|
|
||||||
else if (costPart instanceof CostDiscard) {
|
|
||||||
toSet = new InputPayDiscardCostWithCommands((CostDiscard) costPart, ability);
|
toSet = new InputPayDiscardCostWithCommands((CostDiscard) costPart, ability);
|
||||||
}
|
}
|
||||||
else if (costPart instanceof CostPartMana) {
|
else if (costPart instanceof CostPartMana) {
|
||||||
toSet = new InputPayManaExecuteCommands(game, source + "\r\n", ability.getManaCost().toString());
|
toSet = new InputPayManaExecuteCommands(game, source + "\r\n", ability.getManaCost().toString());
|
||||||
}
|
}
|
||||||
|
if (null != toSet) {
|
||||||
if (toSet != null) {
|
|
||||||
|
|
||||||
FThreads.setInputAndWait(toSet);
|
FThreads.setInputAndWait(toSet);
|
||||||
if (toSet.isPaid() ) {
|
if (toSet.isPaid() ) {
|
||||||
paid.execute();
|
paid.execute();
|
||||||
@@ -594,6 +604,7 @@ public final class GameActionUtil {
|
|||||||
unpaid.execute();
|
unpaid.execute();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// not restricted to combat damage, not restricted to dealing damage to
|
// not restricted to combat damage, not restricted to dealing damage to
|
||||||
|
|||||||
Reference in New Issue
Block a user