mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 11:18:01 +00:00
Renamed TargetChooser.java back into TargetSelection (for Sol)
CostSacrifice - removed input, using a common one other list-related costs use getDescriptiveType method from base class InputPayManaExecuteCommands won't reset manaCost because the class is not reusable anyway.
This commit is contained in:
2
.gitattributes
vendored
2
.gitattributes
vendored
@@ -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/SpellPermanent.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/spellability/Target.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/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/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/StaticAbility.java svneol=native#text/plain
|
||||||
src/main/java/forge/card/staticability/StaticAbilityCantAttackBlock.java -text
|
src/main/java/forge/card/staticability/StaticAbilityCantAttackBlock.java -text
|
||||||
|
|||||||
@@ -91,13 +91,9 @@ public abstract class CostPart {
|
|||||||
return this.typeDescription;
|
return this.typeDescription;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the descriptive type.
|
|
||||||
*
|
|
||||||
* @return the descriptive type
|
|
||||||
*/
|
|
||||||
public final String getDescriptiveType() {
|
public final String getDescriptiveType() {
|
||||||
return this.getTypeDescription() == null ? this.getType() : this.getTypeDescription();
|
String typeDesc = this.getTypeDescription();
|
||||||
|
return typeDesc == null ? this.getType() : typeDesc;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -24,85 +24,20 @@ import forge.CardLists;
|
|||||||
import forge.FThreads;
|
import forge.FThreads;
|
||||||
import forge.card.ability.AbilityUtils;
|
import forge.card.ability.AbilityUtils;
|
||||||
import forge.card.spellability.SpellAbility;
|
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.GameState;
|
||||||
import forge.game.ai.ComputerUtil;
|
import forge.game.ai.ComputerUtil;
|
||||||
import forge.game.player.AIPlayer;
|
import forge.game.player.AIPlayer;
|
||||||
import forge.game.player.Player;
|
import forge.game.player.Player;
|
||||||
import forge.game.zone.ZoneType;
|
import forge.game.zone.ZoneType;
|
||||||
import forge.gui.GuiDialog;
|
import forge.gui.GuiDialog;
|
||||||
import forge.gui.match.CMatchUI;
|
|
||||||
import forge.view.ButtonUtil;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Class CostSacrifice.
|
* The Class CostSacrifice.
|
||||||
*/
|
*/
|
||||||
public class CostSacrifice extends CostPartWithList {
|
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<Card> 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<Card> 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.
|
* Instantiates a new cost sacrifice.
|
||||||
*
|
*
|
||||||
@@ -226,9 +161,14 @@ public class CostSacrifice extends CostPartWithList {
|
|||||||
if (0 == c.intValue()) {
|
if (0 == c.intValue()) {
|
||||||
return true;
|
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);
|
FThreads.setInputAndWait(inp);
|
||||||
return inp.isPaid();
|
if ( inp.hasCancelled() )
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return executePayment(ability, inp.getSelected());
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -62,15 +62,6 @@ public class CostTapType extends CostPartWithList {
|
|||||||
public boolean isReusable() { return true; }
|
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)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
@@ -82,7 +73,7 @@ public class CostTapType extends CostPartWithList {
|
|||||||
sb.append("Tap ");
|
sb.append("Tap ");
|
||||||
|
|
||||||
final Integer i = this.convertAmount();
|
final Integer i = this.convertAmount();
|
||||||
final String desc = this.getDescription();
|
final String desc = this.getDescriptiveType();
|
||||||
final String type = this.getType();
|
final String type = this.getType();
|
||||||
|
|
||||||
if (type.contains("sharesCreatureTypeWith")) {
|
if (type.contains("sharesCreatureTypeWith")) {
|
||||||
@@ -206,7 +197,7 @@ public class CostTapType extends CostPartWithList {
|
|||||||
|
|
||||||
|
|
||||||
InputSelectCards inp = new InputSelectCardsFromList(c, c, typeList);
|
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);
|
FThreads.setInputAndWait(inp);
|
||||||
if ( inp.hasCancelled() )
|
if ( inp.hasCancelled() )
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -59,15 +59,6 @@ public class CostUntapType extends CostPartWithList {
|
|||||||
public boolean isReusable() { return true; }
|
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)
|
* (non-Javadoc)
|
||||||
*
|
*
|
||||||
@@ -79,7 +70,7 @@ public class CostUntapType extends CostPartWithList {
|
|||||||
sb.append("Untap ");
|
sb.append("Untap ");
|
||||||
|
|
||||||
final Integer i = this.convertAmount();
|
final Integer i = this.convertAmount();
|
||||||
final String desc = this.getDescription();
|
final String desc = this.getDescriptiveType();
|
||||||
|
|
||||||
sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), " tapped " + desc));
|
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);
|
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);
|
FThreads.setInputAndWait(inp);
|
||||||
if( inp.hasCancelled() || inp.getSelected().size() != c )
|
if( inp.hasCancelled() || inp.getSelected().size() != c )
|
||||||
return false;
|
return false;
|
||||||
|
|||||||
@@ -70,7 +70,7 @@ public class SpellAbilityRequirements {
|
|||||||
return;
|
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
|
// Skip to paying if parent ability doesn't target and has no
|
||||||
// subAbilities.
|
// subAbilities.
|
||||||
// (or trigger case where its already targeted)
|
// (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
|
// cancel ability during target choosing
|
||||||
final Card c = this.ability.getSourceCard();
|
final Card c = this.ability.getSourceCard();
|
||||||
|
|
||||||
|
|||||||
@@ -42,11 +42,11 @@ import forge.gui.GuiChoose;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class TargetChooser {
|
public class TargetSelection {
|
||||||
private final SpellAbility ability;
|
private final SpellAbility ability;
|
||||||
|
|
||||||
|
|
||||||
public TargetChooser(final SpellAbility sa) {
|
public TargetSelection(final SpellAbility sa) {
|
||||||
this.ability = sa;
|
this.ability = sa;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -58,7 +58,7 @@ public class TargetChooser {
|
|||||||
return this.ability.getSourceCard();
|
return this.ability.getSourceCard();
|
||||||
}
|
}
|
||||||
|
|
||||||
private TargetChooser subSelection = null;
|
private TargetSelection subSelection = null;
|
||||||
|
|
||||||
private boolean bCancel = false;
|
private boolean bCancel = false;
|
||||||
private boolean bTargetingDone = false;
|
private boolean bTargetingDone = false;
|
||||||
@@ -125,7 +125,7 @@ public class TargetChooser {
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
// Has Sub Ability
|
// Has Sub Ability
|
||||||
this.subSelection = new TargetChooser(abSub);
|
this.subSelection = new TargetSelection(abSub);
|
||||||
this.subSelection.clearTargets();
|
this.subSelection.clearTargets();
|
||||||
return this.subSelection.chooseTargets();
|
return this.subSelection.chooseTargets();
|
||||||
}
|
}
|
||||||
@@ -171,7 +171,7 @@ public class TargetChooser {
|
|||||||
* </p>
|
* </p>
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public final List<Card> chooseValidInput() {
|
private final List<Card> chooseValidInput() {
|
||||||
final Target tgt = this.getTgt();
|
final Target tgt = this.getTgt();
|
||||||
final GameState game = ability.getActivatingPlayer().getGame();
|
final GameState game = ability.getActivatingPlayer().getGame();
|
||||||
final List<ZoneType> zone = tgt.getZone();
|
final List<ZoneType> zone = tgt.getZone();
|
||||||
@@ -34,7 +34,7 @@ import forge.view.ButtonUtil;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class InputPayManaExecuteCommands extends InputPayManaBase implements InputPayment {
|
public class InputPayManaExecuteCommands extends InputPayManaBase {
|
||||||
/**
|
/**
|
||||||
* Constant <code>serialVersionUID=3836655722696348713L</code>.
|
* Constant <code>serialVersionUID=3836655722696348713L</code>.
|
||||||
*/
|
*/
|
||||||
@@ -80,14 +80,6 @@ public class InputPayManaExecuteCommands extends InputPayManaBase implements Inp
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* resetManaCost.
|
|
||||||
* </p>
|
|
||||||
*/
|
|
||||||
public final void resetManaCost() {
|
|
||||||
this.manaCost = new ManaCostBeingPaid(this.originalManaCost);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void selectPlayer(final Player selectedPlayer) {
|
public void selectPlayer(final Player selectedPlayer) {
|
||||||
@@ -109,7 +101,6 @@ public class InputPayManaExecuteCommands extends InputPayManaBase implements Inp
|
|||||||
if (this.phyLifeToLose > 0) {
|
if (this.phyLifeToLose > 0) {
|
||||||
Singletons.getControl().getPlayer().payLife(this.phyLifeToLose, null);
|
Singletons.getControl().getPlayer().payLife(this.phyLifeToLose, null);
|
||||||
}
|
}
|
||||||
this.resetManaCost();
|
|
||||||
Singletons.getControl().getPlayer().getManaPool().clearManaPaid(this.saPaidFor, false);
|
Singletons.getControl().getPlayer().getManaPool().clearManaPaid(this.saPaidFor, false);
|
||||||
bPaid = true;
|
bPaid = true;
|
||||||
this.stop();
|
this.stop();
|
||||||
@@ -118,8 +109,6 @@ public class InputPayManaExecuteCommands extends InputPayManaBase implements Inp
|
|||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final void selectButtonCancel() {
|
public final void selectButtonCancel() {
|
||||||
|
|
||||||
this.resetManaCost();
|
|
||||||
Singletons.getControl().getPlayer().getManaPool().refundManaPaid(this.saPaidFor, true);
|
Singletons.getControl().getPlayer().getManaPool().refundManaPaid(this.saPaidFor, true);
|
||||||
bPaid = false;
|
bPaid = false;
|
||||||
this.stop();
|
this.stop();
|
||||||
|
|||||||
Reference in New Issue
Block a user