Drag the current spellability closer to the GUI so that it can be (eventually) displayed

This commit is contained in:
pfps
2017-01-18 16:37:41 +00:00
parent 330dc48564
commit 43b99d130a
14 changed files with 122 additions and 85 deletions

View File

@@ -1292,7 +1292,7 @@ public class AiController {
throw new UnsupportedOperationException("AI is not supposed to reach this code at the moment");
}
public Map<GameEntity, CounterType> chooseProliferation() {
public Map<GameEntity, CounterType> chooseProliferation(final SpellAbility sa) {
final Map<GameEntity, CounterType> result = Maps.newHashMap();
final List<Player> allies = player.getAllies();

View File

@@ -626,7 +626,7 @@ public class PlayerControllerAi extends PlayerController {
}
@Override
public boolean confirmPayment(CostPart costPart, String prompt) {
public boolean confirmPayment(CostPart costPart, String prompt, SpellAbility sa) {
return brains.confirmPayment(costPart); // AI is expected to know what it is paying for at the moment (otherwise add another parameter to this method)
}
@@ -760,8 +760,8 @@ public class PlayerControllerAi extends PlayerController {
}
@Override
public Map<GameEntity, CounterType> chooseProliferation() {
return brains.chooseProliferation();
public Map<GameEntity, CounterType> chooseProliferation(SpellAbility sa) {
return brains.chooseProliferation(sa);
}
@Override

View File

@@ -24,7 +24,7 @@ public class CountersProliferateEffect extends SpellAbilityEffect {
@Override
public void resolve(SpellAbility sa) {
Player controller = sa.getHostCard().getController();
Map<GameEntity, CounterType> proliferateChoice = controller.getController().chooseProliferation();
Map<GameEntity, CounterType> proliferateChoice = controller.getController().chooseProliferation(sa);
if (proliferateChoice == null )
return;
for(Entry<GameEntity, CounterType> ge: proliferateChoice.entrySet()) {

View File

@@ -201,7 +201,7 @@ public abstract class PlayerController {
return chooseCounterType(options, sa, prompt);
}
public abstract boolean confirmPayment(CostPart costPart, String string);
public abstract boolean confirmPayment(CostPart costPart, String string, SpellAbility sa);
public abstract ReplacementEffect chooseSingleReplacementEffect(String prompt, List<ReplacementEffect> possibleReplacers, Map<String, Object> runParams);
public abstract String chooseProtectionType(String string, SpellAbility sa, List<String> choices);
public abstract CardShields chooseRegenerationShield(Card c);
@@ -212,7 +212,7 @@ public abstract class PlayerController {
public abstract void playTrigger(Card host, WrappedAbility wrapperAbility, boolean isMandatory);
public abstract boolean playSaFromPlayEffect(SpellAbility tgtSA);
public abstract Map<GameEntity, CounterType> chooseProliferation();
public abstract Map<GameEntity, CounterType> chooseProliferation(SpellAbility sa);
public abstract boolean chooseCardsPile(SpellAbility sa, CardCollectionView pile1, CardCollectionView pile2, String faceUp);
public abstract void revealAnte(String message, Multimap<Player, PaperCard> removedAnteCards);

View File

@@ -496,7 +496,7 @@ public class PlayerControllerForTests extends PlayerController {
}
@Override
public boolean confirmPayment(CostPart costPart, String string) {
public boolean confirmPayment(CostPart costPart, String string, SpellAbility ability) {
return true;
}
@@ -564,7 +564,7 @@ public class PlayerControllerForTests extends PlayerController {
}
@Override
public Map<GameEntity, CounterType> chooseProliferation() {
public Map<GameEntity, CounterType> chooseProliferation(final SpellAbility sa) {
// TODO Auto-generated method stub
return null;
}

View File

@@ -18,6 +18,7 @@
package forge.match.input;
import forge.game.card.Card;
import forge.game.spellability.SpellAbility;
import forge.player.PlayerControllerHuman;
/**
@@ -36,22 +37,24 @@ public class InputConfirm extends InputSyncronizedBase {
private final String noButtonText;
private final boolean defaultYes;
private boolean result;
private SpellAbility sa;
public InputConfirm(final PlayerControllerHuman controller, String message0) {
this(controller, message0, "Yes", "No", true);
public InputConfirm(final PlayerControllerHuman controller, String message0, SpellAbility sa) {
this(controller, message0, "Yes", "No", true, sa);
}
public InputConfirm(final PlayerControllerHuman controller, String message0, String yesButtonText0, String noButtonText0) {
this(controller, message0, yesButtonText0, noButtonText0, true);
public InputConfirm(final PlayerControllerHuman controller, String message0, String yesButtonText0, String noButtonText0, SpellAbility sa) {
this(controller, message0, yesButtonText0, noButtonText0, true, sa);
}
public InputConfirm(final PlayerControllerHuman controller, String message0, String yesButtonText0, String noButtonText0, boolean defaultYes0) {
public InputConfirm(final PlayerControllerHuman controller, String message0, String yesButtonText0, String noButtonText0, boolean defaultYes0, SpellAbility sa) {
super(controller);
message = message0;
yesButtonText = yesButtonText0;
noButtonText = noButtonText0;
defaultYes = defaultYes0;
result = defaultYes0;
this.sa = sa ;
}
/** {@inheritDoc} */

View File

@@ -11,15 +11,18 @@ import forge.game.GameEntity;
import forge.game.card.Card;
import forge.game.card.CounterType;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
import forge.player.PlayerControllerHuman;
import forge.util.ITriggerEvent;
public final class InputProliferate extends InputSelectManyBase<GameEntity> {
private static final long serialVersionUID = -1779224307654698954L;
private final Map<GameEntity, CounterType> chosenCounters = new HashMap<GameEntity, CounterType>();
private SpellAbility sa;
public InputProliferate(final PlayerControllerHuman controller) {
public InputProliferate(final PlayerControllerHuman controller, final SpellAbility sa) {
super(controller, 1, Integer.MAX_VALUE);
this.sa = sa;
}
@Override

View File

@@ -16,6 +16,7 @@ import forge.game.card.CardCollectionView;
import forge.game.card.CardUtil;
import forge.game.mana.ManaCostBeingPaid;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
import forge.player.PlayerControllerHuman;
import forge.util.ITriggerEvent;
@@ -29,8 +30,9 @@ public final class InputSelectCardsForConvokeOrImprovise extends InputSelectMany
private final boolean improvise;
private final String cardType;
private final String description;
private SpellAbility sa;
public InputSelectCardsForConvokeOrImprovise(final PlayerControllerHuman controller, final Player p, final ManaCost cost, final CardCollectionView untapped, boolean impr) {
public InputSelectCardsForConvokeOrImprovise(final PlayerControllerHuman controller, final Player p, final ManaCost cost, final CardCollectionView untapped, boolean impr, final SpellAbility sa) {
super(controller, 0, Math.min(cost.getCMC(), untapped.size()));
remainingCost = new ManaCostBeingPaid(cost);
player = p;
@@ -38,11 +40,15 @@ public final class InputSelectCardsForConvokeOrImprovise extends InputSelectMany
improvise = impr;
cardType = impr ? "artifact" : "creature";
description = impr ? "Improvise" : "Convoke";
this.sa = sa;
}
@Override
protected String getMessage() {
return String.format("Choose %s to tap for %s .\nRemaining mana cost is %s", cardType, description, remainingCost.toString());
StringBuilder sb = new StringBuilder();
if (sa != null) sb.append(sa.getStackDescription());
sb.append(String.format("Choose %s to tap for %s .\nRemaining mana cost is %s", cardType, description, remainingCost.toString()));
return sb.toString();
}
@Override

View File

@@ -1,6 +1,7 @@
package forge.match.input;
import forge.game.card.Card;
import forge.game.spellability.SpellAbility;
import forge.player.PlayerControllerHuman;
import forge.util.collect.FCollectionView;
@@ -11,8 +12,18 @@ public class InputSelectCardsFromList extends InputSelectEntitiesFromList<Card>
super(controller, cnt, cnt, validCards); // to avoid hangs
}
public InputSelectCardsFromList(final PlayerControllerHuman controller, final int cnt, final FCollectionView<Card> validCards, final SpellAbility sa) {
this(controller,cnt,validCards);
this.sa = sa;
}
public InputSelectCardsFromList(final PlayerControllerHuman controller, final int min, final int max, final FCollectionView<Card> validCards) {
super(controller, min, max, validCards); // to avoid hangs
}
public InputSelectCardsFromList(final PlayerControllerHuman controller, final int min, final int max, final FCollectionView<Card> validCards, final SpellAbility sa) {
this(controller,min,max,validCards);
this.sa = sa;
}
}

View File

@@ -6,6 +6,7 @@ import java.util.List;
import forge.game.GameEntity;
import forge.game.card.Card;
import forge.game.player.Player;
import forge.game.spellability.SpellAbility;
import forge.player.PlayerControllerHuman;
import forge.util.collect.FCollection;
import forge.util.collect.FCollectionView;
@@ -26,6 +27,11 @@ public class InputSelectEntitiesFromList<T extends GameEntity> extends InputSele
}
}
public InputSelectEntitiesFromList(final PlayerControllerHuman controller, final int min, final int max, final FCollectionView<T> validChoices0, final SpellAbility sa) {
this(controller,min,max,validChoices0);
this.sa = sa;
}
@Override
protected boolean onCardSelected(final Card c, final List<Card> otherCardsToSelect, final ITriggerEvent triggerEvent) {
if (!selectEntity(c)) {

View File

@@ -7,6 +7,7 @@ import com.google.common.collect.Iterables;
import forge.game.GameEntity;
import forge.game.card.Card;
import forge.game.card.CardView;
import forge.game.spellability.SpellAbility;
import forge.player.PlayerControllerHuman;
public abstract class InputSelectManyBase<T extends GameEntity> extends InputSyncronizedBase {
@@ -16,6 +17,7 @@ public abstract class InputSelectManyBase<T extends GameEntity> extends InputSyn
protected final int min;
protected final int max;
protected boolean allowCancel = false;
protected SpellAbility sa = null;
protected String message = "Source-Card-Name - Select %d more card(s)";
@@ -28,6 +30,11 @@ public abstract class InputSelectManyBase<T extends GameEntity> extends InputSyn
this.max = max;
}
protected InputSelectManyBase(final PlayerControllerHuman controller, final int min, final int max, final SpellAbility sa) {
this(controller,min,max);
this.sa = sa;
}
protected void refresh() {
if (hasAllTargets()) {
selectButtonOK();

View File

@@ -134,7 +134,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
final CardCollection discarded = new CardCollection();
while (c > 0) {
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, hand);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, hand, ability);
inp.setMessage("Select one of the cards with the same name to discard. Already chosen: " + discarded);
inp.setCancelAllowed(true);
inp.showAndWait();
@@ -166,7 +166,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
}
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, hand);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, hand, ability);
inp.setMessage("Select %d more " + cost.getDescriptiveType() + " to discard.");
inp.setCancelAllowed(true);
inp.showAndWait();
@@ -193,7 +193,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
}
if (player.canPayLife(c) && player.getController().confirmPayment(cost, "Pay " + c + " Life?")) {
if (player.canPayLife(c) && player.getController().confirmPayment(cost, "Pay " + c + " Life?", ability)) {
return PaymentDecision.number(c);
}
return null;
@@ -208,7 +208,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
c = AbilityUtils.calculateAmount(source, amount, ability);
}
if (!player.getController().confirmPayment(cost, "Draw " + c + " Card" + (c == 1 ? "" : "s"))) {
if (!player.getController().confirmPayment(cost, "Draw " + c + " Card" + (c == 1 ? "" : "s"), ability)) {
return null;
}
@@ -243,7 +243,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
if (cost.payCostFromSource()) {
return source.getZone() == player.getZone(cost.from) && player.getController().confirmPayment(cost, "Exile " + source.getName() + "?") ? PaymentDecision.card(source) : null;
return source.getZone() == player.getZone(cost.from) && player.getController().confirmPayment(cost, "Exile " + source.getName() + "?", ability) ? PaymentDecision.card(source) : null;
}
if (type.equals("All")) {
@@ -262,7 +262,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
if (cost.from == ZoneType.Battlefield || cost.from == ZoneType.Hand) {
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, list);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, list, ability);
inp.setMessage("Exile %d card(s) from your" + cost.from);
inp.setCancelAllowed(true);
inp.showAndWait();
@@ -382,7 +382,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
sb.append("Exile ").append(nNeeded).append(" cards from the top of your library?");
final CardCollectionView list = player.getCardsIn(ZoneType.Library, nNeeded);
if (list.size() > nNeeded || !player.getController().confirmPayment(cost, "Exile " + Lang.nounWithAmount(nNeeded, "card") + " from the top of your library?")) {
if (list.size() > nNeeded || !player.getController().confirmPayment(cost, "Exile " + Lang.nounWithAmount(nNeeded, "card") + " from the top of your library?",ability)) {
return null;
}
return PaymentDecision.card(list);
@@ -467,7 +467,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
final CardCollectionView list = player.getCardsIn(ZoneType.Battlefield);
final CardCollectionView validCards = CardLists.getValidCards(list, cost.getType().split(";"), player, source, ability);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, validCards);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, validCards, ability);
final String desc = cost.getTypeDescription() == null ? cost.getType() : cost.getTypeDescription();
inp.setMessage("Gain control of %d " + desc);
inp.showAndWait();
@@ -530,7 +530,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
}
if (!player.getController().confirmPayment(cost, String.format("Mill %d card%s from your library?", c, c == 1 ? "" : "s"))) {
if (!player.getController().confirmPayment(cost, String.format("Mill %d card%s from your library?", c, c == 1 ? "" : "s"),ability)) {
return null;
}
return PaymentDecision.card(player.getCardsIn(ZoneType.Library, c));
@@ -557,7 +557,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
}
if (player.canPayLife(c) && player.getController().confirmPayment(cost, "Pay " + c + " Life?")) {
if (player.canPayLife(c) && player.getController().confirmPayment(cost, "Pay " + c + " Life?",ability)) {
return PaymentDecision.number(c);
}
return null;
@@ -582,7 +582,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
if (player.canPayEnergy(c) &&
player.getController().confirmPayment(cost, cost.toString() + "?\n(You have " + player.getCounters(CounterType.ENERGY) + "{E})")) {
player.getController().confirmPayment(cost, cost.toString() + "?\n(You have " + player.getCounters(CounterType.ENERGY) + "{E})",ability)) {
return PaymentDecision.number(c);
}
return null;
@@ -613,7 +613,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
player.getCardsIn(cost.getFrom()), cost.getType().split(";"), player, source, ability);
if (cost.from == ZoneType.Hand) {
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, list);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, list, ability);
inp.setMessage("Put %d card(s) from your " + cost.from);
inp.setCancelAllowed(true);
inp.showAndWait();
@@ -694,7 +694,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
final CardCollectionView typeList = CardLists.getValidCards(player.getCardsIn(ZoneType.Battlefield),
cost.getType().split(";"), player, ability.getHostCard(), ability);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, typeList);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, typeList, ability);
inp.setMessage("Put " + Lang.nounWithAmount(c, cost.getCounter().getName() + " counter") + " on " + cost.getDescriptiveType());
inp.setCancelAllowed(true);
inp.showAndWait();
@@ -724,14 +724,14 @@ public class HumanCostDecision extends CostDecisionMakerBase {
final Card card = ability.getHostCard();
if (card.getController() == player && card.isInPlay()) {
final CardView view = CardView.get(card);
return player.getController().confirmPayment(cost, "Return " + view + " to hand?") ? PaymentDecision.card(card) : null;
return player.getController().confirmPayment(cost, "Return " + view + " to hand?",ability) ? PaymentDecision.card(card) : null;
}
}
else {
final CardCollectionView validCards = CardLists.getValidCards(ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield),
cost.getType().split(";"), player, source, ability);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, validCards);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, validCards, ability);
inp.setCancelAllowed(true);
inp.setMessage("Return %d " + cost.getDescriptiveType() + " card(s) to hand");
inp.showAndWait();
@@ -772,7 +772,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
if (num == 0) {
return PaymentDecision.number(0);
}
inp = new InputSelectCardsFromList(controller, num, hand) {
inp = new InputSelectCardsFromList(controller, num, hand, ability) {
private static final long serialVersionUID = 8338626212893374798L;
@Override
@@ -804,7 +804,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
return PaymentDecision.number(0);
};
inp = new InputSelectCardsFromList(controller, num, num, hand);
inp = new InputSelectCardsFromList(controller, num, num, hand, ability);
inp.setMessage("Select %d more " + cost.getDescriptiveType() + " card(s) to reveal.");
}
inp.setCancelAllowed(true);
@@ -834,7 +834,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
return card.hasCounters();
}
});
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, list);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, list, ability);
inp.setMessage("Select " + cost.getDescriptiveType() + " to remove a counter");
inp.setCancelAllowed(false);
inp.showAndWait();
@@ -860,11 +860,12 @@ public class HumanCostDecision extends CostDecisionMakerBase {
private final CounterType counterType;
private final CardCollectionView validChoices;
public InputSelectCardToRemoveCounter(final PlayerControllerHuman controller, final int cntCounters, final CounterType cType, final CardCollectionView validCards) {
public InputSelectCardToRemoveCounter(final PlayerControllerHuman controller, final int cntCounters, final CounterType cType, final CardCollectionView validCards, final SpellAbility sa) {
super(controller, cntCounters, cntCounters);
this.validChoices = validCards;
counterType = cType;
cardsChosen = cntCounters > 0 ? new HashMap<Card, Integer>() : null;
this.sa = sa;
}
@Override
@@ -959,13 +960,12 @@ public class HumanCostDecision extends CostDecisionMakerBase {
if (maxCounters < cntRemoved) {
return null;
}
final StringBuilder sb = new StringBuilder("Remove ");
final StringBuilder sb = new StringBuilder("Pay Cost: Remove ");
sb.append(Lang.nounWithNumeral(amount, cost.counter.getName() + " counter"));
sb.append(" from ");
sb.append(source.getName());
sb.append("?");
if (!player.getController().confirmPayment(cost, sb.toString())) {
if (!player.getController().confirmPayment(cost, sb.toString(),ability)) {
return null;
}
}
@@ -993,8 +993,8 @@ public class HumanCostDecision extends CostDecisionMakerBase {
return PaymentDecision.card(source, 0);
}
final InputSelectCardToRemoveCounter inp = new InputSelectCardToRemoveCounter(controller, cntRemoved, cost.counter, validCards);
inp.setMessage("Remove %d " + cost.counter.getName() + " counters from " + cost.getDescriptiveType());
final InputSelectCardToRemoveCounter inp = new InputSelectCardToRemoveCounter(controller, cntRemoved, cost.counter, validCards, ability);
inp.setMessage("Pay Cost: Remove %d " + cost.counter.getName() + " counters from " + cost.getDescriptiveType());
inp.setCancelAllowed(true);
inp.showAndWait();
if (inp.hasCancelled()) {
@@ -1039,7 +1039,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
if (cost.payCostFromSource()) {
if (source.getController() == ability.getActivatingPlayer() && source.isInPlay()) {
return player.getController().confirmPayment(cost, "Sacrifice " + source.getName() + "?") ? PaymentDecision.card(source) : null;
return player.getController().confirmPayment(cost, "Sacrifice " + source.getName() + "?",ability) ? PaymentDecision.card(source) : null;
}
else {
return null;
@@ -1065,7 +1065,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
if (list.size() < c) {
return null;
}
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, list);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, list, ability);
inp.setMessage("Select a " + cost.getDescriptiveType() + " to sacrifice (%d left)");
inp.setCancelAllowed(true);
inp.showAndWait();
@@ -1141,7 +1141,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
}
final CardCollection tapped = new CardCollection();
while (c > 0) {
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, typeList);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, typeList, ability);
inp.setMessage("Select one of the cards to tap. Already chosen: " + tapped);
inp.setCancelAllowed(true);
inp.showAndWait();
@@ -1164,7 +1164,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
if (totalPower) {
final int i = Integer.parseInt(totalP);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 0, typeList.size(), typeList);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 0, typeList.size(), typeList, ability);
inp.setMessage("Select a creature to tap.");
inp.setCancelAllowed(true);
inp.showAndWait();
@@ -1180,7 +1180,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
return null; // not enough targets anymore (e.g. Crackleburr + Smokebraider tapped to get mana)
}
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, typeList);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, typeList, ability);
inp.setCancelAllowed(true);
inp.setMessage("Select a " + cost.getDescriptiveType() + " to tap (%d left)");
inp.showAndWait();
@@ -1209,7 +1209,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
c = AbilityUtils.calculateAmount(source, amount, ability);
}
}
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, typeList);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, c, c, typeList, ability);
inp.setCancelAllowed(true);
inp.setMessage("Select a " + cost.getDescriptiveType() + " to untap (%d left)");
inp.showAndWait();
@@ -1229,7 +1229,7 @@ public class HumanCostDecision extends CostDecisionMakerBase {
final Card source = ability.getHostCard();
final Card cardToUnattach = cost.findCardToUnattach(source, player, ability);
if (cardToUnattach != null && player.getController().confirmPayment(cost, "Unattach " + cardToUnattach.getName() + "?")) {
if (cardToUnattach != null && player.getController().confirmPayment(cost, "Unattach " + cardToUnattach.getName() + "?",ability)) {
return PaymentDecision.card(cardToUnattach);
}
return null;

View File

@@ -282,12 +282,12 @@ public class HumanPlay {
}
if (parts.isEmpty() || (costPart.getAmount().equals("0") && parts.size() < 2)) {
return p.getController().confirmPayment(costPart, "Do you want to pay {0}?" + orString);
return p.getController().confirmPayment(costPart, "Do you want to pay {0}?" + orString, sourceAbility);
}
// 0 mana costs were slipping through because CostPart.getAmount returns 1
else if (costPart instanceof CostPartMana && parts.size() < 2) {
if (((CostPartMana) costPart).getManaToPay().isZero()) {
return p.getController().confirmPayment(costPart, "Do you want to pay {0}?" + orString);
return p.getController().confirmPayment(costPart, "Do you want to pay {0}?" + orString, sourceAbility);
}
}
@@ -304,7 +304,7 @@ public class HumanPlay {
return false;
}
if (!p.getController().confirmPayment(part, "Do you want to pay " + amount + " life?" + orString)) {
if (!p.getController().confirmPayment(part, "Do you want to pay " + amount + " life?" + orString, sourceAbility)) {
return false;
}
@@ -328,7 +328,7 @@ public class HumanPlay {
sb.append(res.contains(p) ? "" : "let that player ");
sb.append("draw " + Lang.nounWithAmount(amount, " card") + "?" + orString);
if (!p.getController().confirmPayment(part, sb.toString())) {
if (!p.getController().confirmPayment(part, sb.toString(), sourceAbility)) {
return false;
}
@@ -348,7 +348,7 @@ public class HumanPlay {
String desc = part.toString();
desc = desc.substring(0, 1).toLowerCase() + desc.substring(1);
if (!p.getController().confirmPayment(part, "Do you want to "+ desc + "?" + orString)) {
if (!p.getController().confirmPayment(part, "Do you want to "+ desc + "?" + orString, sourceAbility)) {
return false;
}
PaymentDecision pd = part.accept(hcd);
@@ -362,7 +362,7 @@ public class HumanPlay {
final int amount = getAmountFromPart(part, source, sourceAbility);
final CardCollectionView list = p.getCardsIn(ZoneType.Library);
if (list.size() < amount) { return false; }
if (!p.getController().confirmPayment(part, "Do you want to mill " + amount + " card" + (amount == 1 ? "" : "s") + "?" + orString)) {
if (!p.getController().confirmPayment(part, "Do you want to mill " + amount + " card" + (amount == 1 ? "" : "s") + "?" + orString, sourceAbility)) {
return false;
}
CardCollectionView listmill = p.getCardsIn(ZoneType.Library, amount);
@@ -370,7 +370,7 @@ public class HumanPlay {
}
else if (part instanceof CostFlipCoin) {
final int amount = getAmountFromPart(part, source, sourceAbility);
if (!p.getController().confirmPayment(part, "Do you want to flip " + amount + " coin" + (amount == 1 ? "" : "s") + "?" + orString)) {
if (!p.getController().confirmPayment(part, "Do you want to flip " + amount + " coin" + (amount == 1 ? "" : "s") + "?" + orString, sourceAbility)) {
return false;
}
final int n = FlipCoinEffect.getFilpMultiplier(p);
@@ -384,7 +384,7 @@ public class HumanPlay {
return false;
}
if (!p.getController().confirmPayment(part, "Do you want " + source + " to deal " + amount + " damage to you?")) {
if (!p.getController().confirmPayment(part, "Do you want " + source + " to deal " + amount + " damage to you?", sourceAbility)) {
return false;
}
CardDamageMap damageMap = new CardDamageMap();
@@ -403,7 +403,7 @@ public class HumanPlay {
return false;
}
if (!p.getController().confirmPayment(part, "Do you want to put " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " on " + source + "?")) {
if (!p.getController().confirmPayment(part, "Do you want to put " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " on " + source + "?", sourceAbility)) {
return false;
}
@@ -413,11 +413,11 @@ public class HumanPlay {
CardCollectionView list = p.getGame().getCardsIn(ZoneType.Battlefield);
list = CardLists.getValidCards(list, part.getType().split(";"), p, source, sourceAbility);
if (list.isEmpty()) { return false; }
if (!p.getController().confirmPayment(part, "Do you want to put " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " on " + part.getTypeDescription() + "?")) {
if (!p.getController().confirmPayment(part, "Do you want to put " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " on " + part.getTypeDescription() + "?", sourceAbility)) {
return false;
}
while (amount > 0) {
InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, list);
InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, list, sourceAbility);
inp.setMessage("Select a card to add a counter to");
inp.setCancelAllowed(true);
inp.showAndWait();
@@ -474,7 +474,7 @@ public class HumanPlay {
}
});
if (list.isEmpty()) { return false; }
InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, list);
InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, 1, 1, list, sourceAbility);
inp.setMessage("Select a card to remove a counter");
inp.setCancelAllowed(true);
inp.showAndWait();
@@ -504,7 +504,7 @@ public class HumanPlay {
final CardCollection exiledList = new CardCollection();
ZoneType from = ZoneType.Graveyard;
if ("All".equals(part.getType())) {
if (!p.getController().confirmPayment(part, "Do you want to exile all cards in your graveyard?")) {
if (!p.getController().confirmPayment(part, "Do you want to exile all cards in your graveyard?", sourceAbility)) {
return false;
}
@@ -523,7 +523,7 @@ public class HumanPlay {
}
if (from == ZoneType.Library) {
if (!p.getController().confirmPayment(part, "Do you want to exile " + nNeeded +
" card" + (nNeeded == 1 ? "" : "s") + " from your library?")) {
" card" + (nNeeded == 1 ? "" : "s") + " from your library?", sourceAbility)) {
return false;
}
list = list.subList(0, nNeeded);
@@ -628,7 +628,7 @@ public class HumanPlay {
}
else if (part instanceof CostDiscard) {
if ("Hand".equals(part.getType())) {
if (!p.getController().confirmPayment(part, "Do you want to discard your hand?")) {
if (!p.getController().confirmPayment(part, "Do you want to discard your hand?", sourceAbility)) {
return false;
}
@@ -715,7 +715,7 @@ public class HumanPlay {
private static boolean payCostPart(final PlayerControllerHuman controller, SpellAbility sourceAbility, CostPartWithList cpl, int amount, CardCollectionView list, String actionName) {
if (list.size() < amount) { return false; } // unable to pay (not enough cards)
InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, amount, amount, list);
InputSelectCardsFromList inp = new InputSelectCardsFromList(controller, amount, amount, list, sourceAbility);
inp.setMessage("Select %d " + cpl.getDescriptiveType() + " card(s) to " + actionName);
inp.setCancelAllowed(true);

View File

@@ -330,15 +330,15 @@ public class PlayerControllerHuman
@Override
public CardCollectionView choosePermanentsToSacrifice(final SpellAbility sa, final int min, final int max, final CardCollectionView valid, final String message) {
return choosePermanentsTo(min, max, valid, message, "sacrifice");
return choosePermanentsTo(min, max, valid, message, "sacrifice", sa);
}
@Override
public CardCollectionView choosePermanentsToDestroy(final SpellAbility sa, final int min, final int max, final CardCollectionView valid, final String message) {
return choosePermanentsTo(min, max, valid, message, "destroy");
return choosePermanentsTo(min, max, valid, message, "destroy", sa);
}
private CardCollectionView choosePermanentsTo(final int min, int max, final CardCollectionView valid, final String message, final String action) {
private CardCollectionView choosePermanentsTo(final int min, int max, final CardCollectionView valid, final String message, final String action, final SpellAbility sa) {
max = Math.min(max, valid.size());
if (max <= 0) {
return CardCollection.EMPTY;
@@ -350,7 +350,7 @@ public class PlayerControllerHuman
}
builder.append("%d " + message + "(s) to " + action + ".");
final InputSelectCardsFromList inp = new InputSelectCardsFromList(this, min, max, valid);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(this, min, max, valid, sa);
inp.setMessage(builder.toString());
inp.setCancelAllowed(min == 0);
inp.showAndWait();
@@ -381,7 +381,7 @@ public class PlayerControllerHuman
}
if (cardsAreInMyHandOrBattlefield) {
final InputSelectCardsFromList sc = new InputSelectCardsFromList(this, min, max, sourceList);
final InputSelectCardsFromList sc = new InputSelectCardsFromList(this, min, max, sourceList, sa);
sc.setMessage(title);
sc.setCancelAllowed(isOptional);
sc.showAndWait();
@@ -430,7 +430,7 @@ public class PlayerControllerHuman
if (delayedReveal != null) {
reveal(delayedReveal.getCards(), delayedReveal.getZone(), delayedReveal.getOwner(), delayedReveal.getMessagePrefix());
}
final InputSelectEntitiesFromList<T> input = new InputSelectEntitiesFromList<T>(this, isOptional ? 0 : 1, 1, optionList);
final InputSelectEntitiesFromList<T> input = new InputSelectEntitiesFromList<T>(this, isOptional ? 0 : 1, 1, optionList, sa);
input.setCancelAllowed(isOptional);
input.setMessage(MessageUtil.formatMessage(title, player, targetedPlayer));
input.showAndWait();
@@ -516,8 +516,8 @@ public class PlayerControllerHuman
return true;
}
final StringBuilder buildQuestion = new StringBuilder("Use triggered ability of ");
buildQuestion.append(regtrig.getHostCard().toString()).append("?");
final StringBuilder buildQuestion = new StringBuilder("<b>Use triggered ability of ");
buildQuestion.append(regtrig.getHostCard().toString()).append("?</b>");
if (!FModel.getPreferences().getPrefBoolean(FPref.UI_COMPACT_PROMPT)) {
//append trigger description unless prompt is compact
buildQuestion.append("\n(");
@@ -536,7 +536,8 @@ public class PlayerControllerHuman
}
}
final InputConfirm inp = new InputConfirm(this, buildQuestion.toString());
// pfps: trigger is on stack so do we really need to put it in the prompt area?
final InputConfirm inp = new InputConfirm(this, buildQuestion.toString(),sa);
inp.showAndWait();
return inp.getResult();
}
@@ -546,7 +547,7 @@ public class PlayerControllerHuman
if (game.getPlayers().size() == 2) {
final String prompt = String.format("%s, you %s\n\nWould you like to play or draw?",
player.getName(), isFirstGame ? " have won the coin toss." : " lost the last game.");
final InputConfirm inp = new InputConfirm(this, prompt, "Play", "Draw");
final InputConfirm inp = new InputConfirm(this, prompt, "Play", "Draw", null);
inp.showAndWait();
return inp.getResult() ? this.player : this.player.getOpponents().get(0);
}
@@ -688,7 +689,7 @@ public class PlayerControllerHuman
return choices;
}
final InputSelectCardsFromList inp = new InputSelectCardsFromList(this, min, max, valid);
final InputSelectCardsFromList inp = new InputSelectCardsFromList(this, min, max, valid, sa);
inp.setMessage(sa.hasParam("AnyNumber") ? "Discard up to %d card(s)" : "Discard %d card(s)");
inp.showAndWait();
return new CardCollection(inp.getSelected());
@@ -749,7 +750,7 @@ public class PlayerControllerHuman
*/
@Override
public CardCollectionView chooseCardsToDiscardUnlessType(final int num, final CardCollectionView hand, final String uType, final SpellAbility sa) {
final InputSelectEntitiesFromList<Card> target = new InputSelectEntitiesFromList<Card>(this, num, num, hand) {
final InputSelectEntitiesFromList<Card> target = new InputSelectEntitiesFromList<Card>(this, num, num, hand, sa) {
private static final long serialVersionUID = -5774108410928795591L;
@Override
@@ -1158,8 +1159,8 @@ public class PlayerControllerHuman
}
@Override
public boolean confirmPayment(final CostPart costPart, final String question) {
final InputConfirm inp = new InputConfirm(this, question);
public boolean confirmPayment(final CostPart costPart, final String question, SpellAbility sa) {
final InputConfirm inp = new InputConfirm(this, question, sa);
inp.showAndWait();
return inp.getResult();
}
@@ -1264,8 +1265,8 @@ public class PlayerControllerHuman
}
@Override
public Map<GameEntity, CounterType> chooseProliferation() {
final InputProliferate inp = new InputProliferate(this);
public Map<GameEntity, CounterType> chooseProliferation(final SpellAbility sa) {
final InputProliferate inp = new InputProliferate(this,sa);
inp.setCancelAllowed(true);
inp.showAndWait();
if (inp.hasCancelled()) {
@@ -1358,7 +1359,7 @@ public class PlayerControllerHuman
@Override
public Map<Card, ManaCostShard> chooseCardsForConvokeOrImprovise(final SpellAbility sa, final ManaCost manaCost, final CardCollectionView untappedCards, boolean improvise) {
final InputSelectCardsForConvokeOrImprovise inp = new InputSelectCardsForConvokeOrImprovise(this, player, manaCost, untappedCards, improvise);
final InputSelectCardsForConvokeOrImprovise inp = new InputSelectCardsForConvokeOrImprovise(this, player, manaCost, untappedCards, improvise, sa);
inp.showAndWait();
return inp.getConvokeMap();
}