This restores mana payment prompts (lost yesterday)

This commit is contained in:
Maxmtg
2014-02-18 20:28:03 +00:00
parent 164490ffc9
commit b299711be7
8 changed files with 23 additions and 13 deletions

View File

@@ -717,7 +717,7 @@ public class PlayerControllerAi extends PlayerController {
} }
@Override @Override
public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa) { public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa, String prompt /* ai needs hints as well */ ) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return ComputerUtilMana.payManaCost(new ManaCostBeingPaid(toPay), sa, player); return ComputerUtilMana.payManaCost(new ManaCostBeingPaid(toPay), sa, player);
} }

View File

@@ -128,7 +128,7 @@ public class CostPartMana extends CostPart {
sa.clearManaPaid(); sa.clearManaPaid();
// decision not used here, the whole payment is interactive! // decision not used here, the whole payment is interactive!
return payer.getController().payManaCost(this, sa); return payer.getController().payManaCost(this, sa, null);
} }
} }

View File

@@ -222,10 +222,10 @@ public abstract class PlayerController {
public List<Card> cheatShuffle(List<Card> list) { return list; } public List<Card> cheatShuffle(List<Card> list) { return list; }
public Collection<? extends PaperCard> complainCardsCantPlayWell(Deck myDeck) { return null; } public Collection<? extends PaperCard> complainCardsCantPlayWell(Deck myDeck) { return null; }
public final boolean payManaCost(CostPartMana costPartMana, SpellAbility sa) { public final boolean payManaCost(CostPartMana costPartMana, SpellAbility sa, String prompt) {
return payManaCost(costPartMana.getManaCostFor(sa), costPartMana, sa); return payManaCost(costPartMana.getManaCostFor(sa), costPartMana, sa, prompt);
} }
public abstract boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa); public abstract boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa, String prompt);
public abstract Map<Card, ManaCostShard> chooseCardsForConvoke(SpellAbility sa, ManaCost manaCost, List<Card> untappedCreats); public abstract Map<Card, ManaCostShard> chooseCardsForConvoke(SpellAbility sa, ManaCost manaCost, List<Card> untappedCreats);

View File

@@ -372,4 +372,10 @@ public abstract class InputPayMana extends InputSyncronizedBase {
} }
public boolean isPaid() { return bPaid; } public boolean isPaid() { return bPaid; }
protected String messagePrefix;
public void setMessagePrefix(String prompt) {
// TODO Auto-generated method stub
messagePrefix = prompt;
}
} }

View File

@@ -44,7 +44,10 @@ public class InputPayManaOfCostPayment extends InputPayMana {
protected String getMessage() { protected String getMessage() {
final String displayMana = manaCost.toString(false); final String displayMana = manaCost.toString(false);
final StringBuilder msg = new StringBuilder("Pay Mana Cost: " + displayMana); final StringBuilder msg = new StringBuilder();
if( messagePrefix != null )
msg.append(messagePrefix).append("\n");
msg.append("Pay Mana Cost: ").append(displayMana);
if (this.phyLifeToLose > 0) { if (this.phyLifeToLose > 0) {
msg.append(" ("); msg.append(" (");
msg.append(this.phyLifeToLose); msg.append(this.phyLifeToLose);

View File

@@ -628,7 +628,7 @@ public class HumanPlay {
} }
sourceAbility.clearManaPaid(); sourceAbility.clearManaPaid();
boolean paid = p.getController().payManaCost(cost.getCostMana(), sourceAbility); boolean paid = p.getController().payManaCost(cost.getCostMana(), sourceAbility, prompt);
if (!paid) { if (!paid) {
p.getManaPool().refundManaPaid(sourceAbility); p.getManaPool().refundManaPaid(sourceAbility);
} }
@@ -679,7 +679,7 @@ public class HumanPlay {
return done; return done;
} }
public static boolean payManaCost(final ManaCost realCost, final CostPartMana mc, final SpellAbility ability, final Player activator) { public static boolean payManaCost(final ManaCost realCost, final CostPartMana mc, final SpellAbility ability, final Player activator, String prompt) {
final Card source = ability.getHostCard(); final Card source = ability.getHostCard();
ManaCostBeingPaid toPay = new ManaCostBeingPaid(realCost, mc.getRestiction()); ManaCostBeingPaid toPay = new ManaCostBeingPaid(realCost, mc.getRestiction());
@@ -699,16 +699,17 @@ public class HumanPlay {
toPay.addManaCost(mkCost); toPay.addManaCost(mkCost);
} }
InputPayMana inpPayment;
toPay.applySpellCostChange(ability, false); toPay.applySpellCostChange(ability, false);
InputPayMana inpPayment;
if (ability.isOffering() && ability.getSacrificedAsOffering() == null) { if (ability.isOffering() && ability.getSacrificedAsOffering() == null) {
System.out.println("Sacrifice input for Offering cancelled"); System.out.println("Sacrifice input for Offering cancelled");
return false; return false;
} }
if (!toPay.isPaid()) { if (!toPay.isPaid()) {
inpPayment = new InputPayManaOfCostPayment(toPay, ability, activator); inpPayment = new InputPayManaOfCostPayment(toPay, ability, activator);
inpPayment.setMessagePrefix(prompt);
inpPayment.showAndWait(); inpPayment.showAndWait();
if (!inpPayment.isPaid()) { if (!inpPayment.isPaid()) {
return handleOfferingAndConvoke(ability, true, false); return handleOfferingAndConvoke(ability, true, false);

View File

@@ -1062,8 +1062,8 @@ public class PlayerControllerHuman extends PlayerController {
} }
@Override @Override
public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa) { public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa, String prompt /* ai needs hints as well */ ) {
return HumanPlay.payManaCost(toPay, costPartMana, sa, player); return HumanPlay.payManaCost(toPay, costPartMana, sa, player, prompt);
} }
@Override @Override

View File

@@ -566,7 +566,7 @@ public class PlayerControllerForTests extends PlayerController {
} }
@Override @Override
public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa) { public boolean payManaCost(ManaCost toPay, CostPartMana costPartMana, SpellAbility sa, String prompt /* ai needs hints as well */ ) {
// TODO Auto-generated method stub // TODO Auto-generated method stub
return ComputerUtilMana.payManaCost(new ManaCostBeingPaid(toPay), sa, player); return ComputerUtilMana.payManaCost(new ManaCostBeingPaid(toPay), sa, player);
} }