diff --git a/.gitattributes b/.gitattributes
index 94cea2207e7..99e09970f8a 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -13766,7 +13766,7 @@ src/main/java/forge/card/spellability/SpellAbilityVariables.java svneol=native#t
src/main/java/forge/card/spellability/SpellPermanent.java svneol=native#text/plain
src/main/java/forge/card/spellability/Target.java svneol=native#text/plain
src/main/java/forge/card/spellability/TargetChoices.java svneol=native#text/plain
-src/main/java/forge/card/spellability/TargetChooser.java svneol=native#text/plain
+src/main/java/forge/card/spellability/TargetSelection.java svneol=native#text/plain
src/main/java/forge/card/spellability/package-info.java svneol=native#text/plain
src/main/java/forge/card/staticability/StaticAbility.java svneol=native#text/plain
src/main/java/forge/card/staticability/StaticAbilityCantAttackBlock.java -text
diff --git a/src/main/java/forge/card/cost/CostPart.java b/src/main/java/forge/card/cost/CostPart.java
index faf216c8231..703c0e0d648 100644
--- a/src/main/java/forge/card/cost/CostPart.java
+++ b/src/main/java/forge/card/cost/CostPart.java
@@ -91,13 +91,9 @@ public abstract class CostPart {
return this.typeDescription;
}
- /**
- * Gets the descriptive type.
- *
- * @return the descriptive type
- */
public final String getDescriptiveType() {
- return this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
+ String typeDesc = this.getTypeDescription();
+ return typeDesc == null ? this.getType() : typeDesc;
}
/**
diff --git a/src/main/java/forge/card/cost/CostSacrifice.java b/src/main/java/forge/card/cost/CostSacrifice.java
index 14f1de620a1..42375798133 100644
--- a/src/main/java/forge/card/cost/CostSacrifice.java
+++ b/src/main/java/forge/card/cost/CostSacrifice.java
@@ -24,85 +24,20 @@ import forge.CardLists;
import forge.FThreads;
import forge.card.ability.AbilityUtils;
import forge.card.spellability.SpellAbility;
-import forge.control.input.InputPayment;
+import forge.control.input.InputSelectCards;
+import forge.control.input.InputSelectCardsFromList;
import forge.game.GameState;
import forge.game.ai.ComputerUtil;
import forge.game.player.AIPlayer;
import forge.game.player.Player;
import forge.game.zone.ZoneType;
import forge.gui.GuiDialog;
-import forge.gui.match.CMatchUI;
-import forge.view.ButtonUtil;
/**
* The Class CostSacrifice.
*/
public class CostSacrifice extends CostPartWithList {
- /**
- * TODO: Write javadoc for this type.
- *
- */
- public static final class InputPayCostSacrificeFromList extends InputPayCostBase {
- private final CostSacrifice part;
- private final SpellAbility sa;
- private final int nNeeded;
- private final List typeList;
- private static final long serialVersionUID = 2685832214519141903L;
- private int nSacrifices = 0;
-
- /**
- * TODO: Write javadoc for Constructor.
- * @param part
- * @param sa
- * @param nNeeded
- * @param payment
- * @param typeList
- */
- public InputPayCostSacrificeFromList(CostSacrifice part, SpellAbility sa, int nNeeded, List typeList) {
- this.part = part;
- this.sa = sa;
- this.nNeeded = nNeeded;
- this.typeList = typeList;
- }
-
- @Override
- public void showMessage() {
- if (nNeeded == 0) {
- this.done();
- }
-
- final StringBuilder msg = new StringBuilder("Sacrifice ");
- final int nLeft = nNeeded - this.nSacrifices;
- msg.append(nLeft).append(" ");
- msg.append(part.getDescriptiveType());
- if (nLeft > 1) {
- msg.append("s");
- }
-
- CMatchUI.SINGLETON_INSTANCE.showMessage(msg.toString());
- ButtonUtil.enableOnlyCancel();
- }
-
- @Override
- public void selectCard(final Card card) {
- if (typeList.contains(card)) {
- this.nSacrifices++;
- part.executePayment(sa, card);
- typeList.remove(card);
- // in case nothing else to sacrifice
- if (this.nSacrifices == nNeeded) {
- this.done();
- } else if (typeList.isEmpty()) {
- // happen
- this.cancel();
- } else {
- this.showMessage();
- }
- }
- }
- }
-
/**
* Instantiates a new cost sacrifice.
*
@@ -226,9 +161,14 @@ public class CostSacrifice extends CostPartWithList {
if (0 == c.intValue()) {
return true;
}
- InputPayment inp = new InputPayCostSacrificeFromList(this, ability, c, list);
+
+ InputSelectCards inp = new InputSelectCardsFromList(c, c, list);
+ inp.setMessage("Select a " + this.getDescriptiveType() + " to sacrifice (%d left)");
FThreads.setInputAndWait(inp);
- return inp.isPaid();
+ if ( inp.hasCancelled() )
+ return false;
+
+ return executePayment(ability, inp.getSelected());
}
return false;
}
diff --git a/src/main/java/forge/card/cost/CostTapType.java b/src/main/java/forge/card/cost/CostTapType.java
index b398e4ae07e..ac4c6b9c2ac 100644
--- a/src/main/java/forge/card/cost/CostTapType.java
+++ b/src/main/java/forge/card/cost/CostTapType.java
@@ -62,15 +62,6 @@ public class CostTapType extends CostPartWithList {
public boolean isReusable() { return true; }
- /**
- * Gets the description.
- *
- * @return the description
- */
- public final String getDescription() {
- return this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
- }
-
/*
* (non-Javadoc)
*
@@ -82,7 +73,7 @@ public class CostTapType extends CostPartWithList {
sb.append("Tap ");
final Integer i = this.convertAmount();
- final String desc = this.getDescription();
+ final String desc = this.getDescriptiveType();
final String type = this.getType();
if (type.contains("sharesCreatureTypeWith")) {
@@ -206,7 +197,7 @@ public class CostTapType extends CostPartWithList {
InputSelectCards inp = new InputSelectCardsFromList(c, c, typeList);
- inp.setMessage("Select a " + getDescription() + " to tap (%d left)");
+ inp.setMessage("Select a " + getDescriptiveType() + " to tap (%d left)");
FThreads.setInputAndWait(inp);
if ( inp.hasCancelled() )
return false;
diff --git a/src/main/java/forge/card/cost/CostUntapType.java b/src/main/java/forge/card/cost/CostUntapType.java
index 3c2e3c8cbed..004d5cc5362 100644
--- a/src/main/java/forge/card/cost/CostUntapType.java
+++ b/src/main/java/forge/card/cost/CostUntapType.java
@@ -59,15 +59,6 @@ public class CostUntapType extends CostPartWithList {
public boolean isReusable() { return true; }
- /**
- * Gets the description.
- *
- * @return the description
- */
- public final String getDescription() {
- return this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
- }
-
/*
* (non-Javadoc)
*
@@ -79,7 +70,7 @@ public class CostUntapType extends CostPartWithList {
sb.append("Untap ");
final Integer i = this.convertAmount();
- final String desc = this.getDescription();
+ final String desc = this.getDescriptiveType();
sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), " tapped " + desc));
@@ -161,7 +152,7 @@ public class CostUntapType extends CostPartWithList {
}
}
InputSelectCards inp = new InputSelectCardsFromList(c, c, typeList);
- inp.setMessage("Select a " + getDescription() + " to untap (%d left)");
+ inp.setMessage("Select a " + getDescriptiveType() + " to untap (%d left)");
FThreads.setInputAndWait(inp);
if( inp.hasCancelled() || inp.getSelected().size() != c )
return false;
diff --git a/src/main/java/forge/card/spellability/SpellAbilityRequirements.java b/src/main/java/forge/card/spellability/SpellAbilityRequirements.java
index 0d18237f63a..ab6505b2f3a 100644
--- a/src/main/java/forge/card/spellability/SpellAbilityRequirements.java
+++ b/src/main/java/forge/card/spellability/SpellAbilityRequirements.java
@@ -70,7 +70,7 @@ public class SpellAbilityRequirements {
return;
}
- final TargetChooser select = new TargetChooser(ability);
+ final TargetSelection select = new TargetSelection(ability);
// Skip to paying if parent ability doesn't target and has no
// subAbilities.
// (or trigger case where its already targeted)
@@ -113,7 +113,7 @@ public class SpellAbilityRequirements {
}
}
- private void rollbackAbility(Zone fromZone, int zonePosition, TargetChooser select) {
+ private void rollbackAbility(Zone fromZone, int zonePosition, TargetSelection select) {
// cancel ability during target choosing
final Card c = this.ability.getSourceCard();
diff --git a/src/main/java/forge/card/spellability/TargetChooser.java b/src/main/java/forge/card/spellability/TargetSelection.java
similarity index 98%
rename from src/main/java/forge/card/spellability/TargetChooser.java
rename to src/main/java/forge/card/spellability/TargetSelection.java
index 81a84ac61ce..a1f5330ec30 100644
--- a/src/main/java/forge/card/spellability/TargetChooser.java
+++ b/src/main/java/forge/card/spellability/TargetSelection.java
@@ -42,11 +42,11 @@ import forge.gui.GuiChoose;
* @author Forge
* @version $Id$
*/
-public class TargetChooser {
+public class TargetSelection {
private final SpellAbility ability;
- public TargetChooser(final SpellAbility sa) {
+ public TargetSelection(final SpellAbility sa) {
this.ability = sa;
}
@@ -58,7 +58,7 @@ public class TargetChooser {
return this.ability.getSourceCard();
}
- private TargetChooser subSelection = null;
+ private TargetSelection subSelection = null;
private boolean bCancel = false;
private boolean bTargetingDone = false;
@@ -125,7 +125,7 @@ public class TargetChooser {
return true;
// Has Sub Ability
- this.subSelection = new TargetChooser(abSub);
+ this.subSelection = new TargetSelection(abSub);
this.subSelection.clearTargets();
return this.subSelection.chooseTargets();
}
@@ -171,7 +171,7 @@ public class TargetChooser {
*
* @return
*/
- public final List chooseValidInput() {
+ private final List chooseValidInput() {
final Target tgt = this.getTgt();
final GameState game = ability.getActivatingPlayer().getGame();
final List zone = tgt.getZone();
diff --git a/src/main/java/forge/control/input/InputPayManaExecuteCommands.java b/src/main/java/forge/control/input/InputPayManaExecuteCommands.java
index 5d0ee10ac24..4f51d8133fe 100644
--- a/src/main/java/forge/control/input/InputPayManaExecuteCommands.java
+++ b/src/main/java/forge/control/input/InputPayManaExecuteCommands.java
@@ -34,7 +34,7 @@ import forge.view.ButtonUtil;
* @author Forge
* @version $Id$
*/
-public class InputPayManaExecuteCommands extends InputPayManaBase implements InputPayment {
+public class InputPayManaExecuteCommands extends InputPayManaBase {
/**
* Constant serialVersionUID=3836655722696348713L.
*/
@@ -80,14 +80,6 @@ public class InputPayManaExecuteCommands extends InputPayManaBase implements Inp
}
- /**
- *
- * resetManaCost.
- *
- */
- public final void resetManaCost() {
- this.manaCost = new ManaCostBeingPaid(this.originalManaCost);
- }
@Override
public void selectPlayer(final Player selectedPlayer) {
@@ -109,7 +101,6 @@ public class InputPayManaExecuteCommands extends InputPayManaBase implements Inp
if (this.phyLifeToLose > 0) {
Singletons.getControl().getPlayer().payLife(this.phyLifeToLose, null);
}
- this.resetManaCost();
Singletons.getControl().getPlayer().getManaPool().clearManaPaid(this.saPaidFor, false);
bPaid = true;
this.stop();
@@ -118,8 +109,6 @@ public class InputPayManaExecuteCommands extends InputPayManaBase implements Inp
/** {@inheritDoc} */
@Override
public final void selectButtonCancel() {
-
- this.resetManaCost();
Singletons.getControl().getPlayer().getManaPool().refundManaPaid(this.saPaidFor, true);
bPaid = false;
this.stop();