mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
Show cost payment prompts during ability resolve using Prompt pane instead of a dialog
This commit is contained in:
@@ -46,19 +46,24 @@ public class Lang {
|
||||
public static <T> String joinHomogenous(Collection<T> objects, Function<T, String> accessor, String lastUnion) {
|
||||
int remaining = objects.size();
|
||||
StringBuilder sb = new StringBuilder();
|
||||
for(T obj : objects) {
|
||||
for (T obj : objects) {
|
||||
remaining--;
|
||||
if( accessor != null )
|
||||
if (accessor != null) {
|
||||
sb.append(accessor.apply(obj));
|
||||
else
|
||||
}
|
||||
else {
|
||||
sb.append(obj);
|
||||
if( remaining > 1 ) sb.append(", ");
|
||||
if( remaining == 1 ) sb.append(" ").append(lastUnion).append(" ");
|
||||
}
|
||||
if (remaining > 1) {
|
||||
sb.append(", ");
|
||||
}
|
||||
else if (remaining == 1) {
|
||||
sb.append(" ").append(lastUnion).append(" ");
|
||||
}
|
||||
}
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
|
||||
public static <T> String joinVerb(List<T> subjects, String verb) {
|
||||
return subjects.size() > 1 || !subjectIsSingle3rdPerson(Iterables.getFirst(subjects, "it").toString()) ? verb : verbs3rdPersonSingular(verb);
|
||||
}
|
||||
@@ -78,16 +83,18 @@ public class Lang {
|
||||
}
|
||||
|
||||
public static String getPlural(String noun) {
|
||||
return noun + ( noun.endsWith("s") || noun.endsWith("x") ? "es" : "s");
|
||||
return noun + (noun.endsWith("s") || noun.endsWith("x") ? "es" : "s");
|
||||
}
|
||||
|
||||
public static <T> String nounWithAmount(int cnt, String noun) {
|
||||
String countedForm = cnt <= 1 ? noun : getPlural(noun);
|
||||
String countedForm = cnt == 1 ? noun : getPlural(noun);
|
||||
final String strCount;
|
||||
if( cnt == 1 )
|
||||
if (cnt == 1) {
|
||||
strCount = startsWithVowel(noun) ? "an " : "a ";
|
||||
else
|
||||
}
|
||||
else {
|
||||
strCount = String.valueOf(cnt) + " ";
|
||||
}
|
||||
return strCount + countedForm;
|
||||
}
|
||||
|
||||
@@ -108,10 +115,10 @@ public class Lang {
|
||||
private static final char[] vowels = { 'a', 'i', 'e', 'o', 'u' };
|
||||
public static boolean isVowel(char letter) {
|
||||
char l = Character.toLowerCase(letter);
|
||||
for(char c : vowels)
|
||||
if ( c == l ) return true;
|
||||
for (char c : vowels) {
|
||||
if (c == l) return true;
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
public final static String[] numbers0 = new String[] {
|
||||
@@ -122,9 +129,9 @@ public class Lang {
|
||||
public static String getNumeral(int n) {
|
||||
String prefix = n < 0 ? "minus " : "";
|
||||
n = Math.abs(n);
|
||||
if ( n >= 0 && n < 20 )
|
||||
if (n >= 0 && n < 20)
|
||||
return prefix + numbers0[n];
|
||||
if ( n < 100 ) {
|
||||
if (n < 100) {
|
||||
int n1 = n % 10;
|
||||
String ones = n1 == 0 ? "" : numbers0[n1];
|
||||
return prefix + numbers20[(n / 10) - 2] + " " + ones;
|
||||
|
||||
@@ -54,12 +54,12 @@ import forge.game.spellability.SpellAbility;
|
||||
import forge.game.spellability.TargetRestrictions;
|
||||
import forge.game.zone.ZoneType;
|
||||
import forge.gui.GuiChoose;
|
||||
import forge.gui.GuiDialog;
|
||||
import forge.gui.input.InputPayMana;
|
||||
import forge.gui.input.InputPayManaExecuteCommands;
|
||||
import forge.gui.input.InputPayManaSimple;
|
||||
import forge.gui.input.InputSelectCards;
|
||||
import forge.gui.input.InputSelectCardsFromList;
|
||||
import forge.gui.input.InputYesOrNo;
|
||||
import forge.util.Lang;
|
||||
|
||||
/**
|
||||
@@ -300,15 +300,18 @@ public class HumanPlay {
|
||||
if (!parts.isEmpty()) {
|
||||
costPart = parts.get(0);
|
||||
}
|
||||
final String orString = prompt != null ? "" : " (or: " + sourceAbility.getStackDescription() + ")";
|
||||
String orString = prompt == null ? sourceAbility.getStackDescription().trim() : "";
|
||||
if (!orString.isEmpty()) {
|
||||
orString = " (or: " + orString + ")";
|
||||
}
|
||||
|
||||
if (parts.isEmpty() || (costPart.getAmount().equals("0") && parts.size() < 2)) {
|
||||
return GuiDialog.confirm(source, "Do you want to pay 0?" + orString);
|
||||
return InputYesOrNo.ask("Do you want to pay {0}?" + orString);
|
||||
}
|
||||
// 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 GuiDialog.confirm(source, "Do you want to pay 0?" + orString);
|
||||
return InputYesOrNo.ask("Do you want to pay {0}?" + orString);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -318,11 +321,13 @@ public class HumanPlay {
|
||||
|
||||
if (part instanceof CostPayLife) {
|
||||
final int amount = getAmountFromPart(part, source, sourceAbility);
|
||||
if (!p.canPayLife(amount))
|
||||
if (!p.canPayLife(amount)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false == GuiDialog.confirm(source, "Do you want to pay " + amount + " life?" + orString))
|
||||
if (!InputYesOrNo.ask("Do you want to pay " + amount + " life?" + orString)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
p.payLife(amount, null);
|
||||
}
|
||||
@@ -345,9 +350,13 @@ public class HumanPlay {
|
||||
sb.append("Do you want to ");
|
||||
sb.append(res.contains(p) ? "" : "let that player ");
|
||||
sb.append("draw " + amount);
|
||||
sb.append(" card(s)?" + orString);
|
||||
sb.append(" card");
|
||||
if (amount != 1) {
|
||||
sb.append("s");
|
||||
}
|
||||
sb.append("?" + orString);
|
||||
|
||||
if (!GuiDialog.confirm(source, sb.toString())) {
|
||||
if (!InputYesOrNo.ask(sb.toString())) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -361,7 +370,7 @@ public class HumanPlay {
|
||||
}
|
||||
}
|
||||
else if (part instanceof CostAddMana) {
|
||||
if (!GuiDialog.confirm(source, "Do you want to add "
|
||||
if (!InputYesOrNo.ask("Do you want to add "
|
||||
+ ((CostAddMana) part).toString()
|
||||
+ " to your mana pool?" + orString)) {
|
||||
return false;
|
||||
@@ -374,7 +383,8 @@ public class HumanPlay {
|
||||
final int amount = getAmountFromPart(part, source, sourceAbility);
|
||||
final List<Card> list = p.getCardsIn(ZoneType.Library);
|
||||
if (list.size() < amount) { return false; }
|
||||
if (!GuiDialog.confirm(source, "Do you want to mill " + amount + " card(s)?" + orString)) {
|
||||
if (!InputYesOrNo.ask("Do you want to mill " + amount +
|
||||
" card" + (amount == 1 ? "" : "s") + "?" + orString)) {
|
||||
return false;
|
||||
}
|
||||
List<Card> listmill = p.getCardsIn(ZoneType.Library, amount);
|
||||
@@ -382,7 +392,8 @@ public class HumanPlay {
|
||||
}
|
||||
else if (part instanceof CostFlipCoin) {
|
||||
final int amount = getAmountFromPart(part, source, sourceAbility);
|
||||
if (!GuiDialog.confirm(source, "Do you want to flip " + amount + " coin(s)?" + orString)) {
|
||||
if (!InputYesOrNo.ask("Do you want to flip " + amount +
|
||||
" coin" + (amount == 1 ? "" : "s") + "?" + orString)) {
|
||||
return false;
|
||||
}
|
||||
final int n = FlipCoinEffect.getFilpMultiplier(p);
|
||||
@@ -396,7 +407,7 @@ public class HumanPlay {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false == GuiDialog.confirm(source, "Do you want " + source + " to deal " + amount + " damage to you?")) {
|
||||
if (!InputYesOrNo.ask("Do you want " + source + " to deal " + amount + " damage to you?")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -412,7 +423,7 @@ public class HumanPlay {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!GuiDialog.confirm(source, "Do you want to put " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " on " + source + "?")) {
|
||||
if (!InputYesOrNo.ask("Do you want to put " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " on " + source + "?")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -422,12 +433,12 @@ public class HumanPlay {
|
||||
List<Card> list = p.getGame().getCardsIn(ZoneType.Battlefield);
|
||||
list = CardLists.getValidCards(list, part.getType().split(";"), p, source);
|
||||
if (list.isEmpty()) { return false; }
|
||||
if (!GuiDialog.confirm(source, "Do you want to put " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " on " + part.getTypeDescription() + "?")) {
|
||||
if (!InputYesOrNo.ask("Do you want to put " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " on " + part.getTypeDescription() + "?")) {
|
||||
return false;
|
||||
}
|
||||
while (amount > 0) {
|
||||
InputSelectCards inp = new InputSelectCardsFromList(1, 1, list);
|
||||
inp.setMessage("Select a card to add a counter");
|
||||
inp.setMessage("Select a card to add a counter to");
|
||||
inp.setCancelAllowed(true);
|
||||
Singletons.getControl().getInputQueue().setInputAndWait(inp);
|
||||
if (inp.hasCancelled()) {
|
||||
@@ -447,7 +458,7 @@ public class HumanPlay {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (false == GuiDialog.confirm(source, "Do you want to remove " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " from " + source + "?")) {
|
||||
if (!InputYesOrNo.ask("Do you want to remove " + Lang.nounWithAmount(amount, counterType.getName() + " counter") + " from " + source + "?")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -463,8 +474,8 @@ public class HumanPlay {
|
||||
allCounters += value;
|
||||
}
|
||||
}
|
||||
if (allCounters < amount) return false;
|
||||
if (!GuiDialog.confirm(source, "Do you want to remove counters from " + part.getDescriptiveType() + " ?")) {
|
||||
if (allCounters < amount) { return false; }
|
||||
if (!InputYesOrNo.ask("Do you want to remove counters from " + part.getDescriptiveType() + " ?")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -506,7 +517,7 @@ public class HumanPlay {
|
||||
}
|
||||
else if (part instanceof CostExile) {
|
||||
if ("All".equals(part.getType())) {
|
||||
if (false == GuiDialog.confirm(source, "Do you want to exile all cards in your graveyard?")) {
|
||||
if (!InputYesOrNo.ask("Do you want to exile all cards in your graveyard?")) {
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -524,7 +535,8 @@ public class HumanPlay {
|
||||
return false;
|
||||
}
|
||||
if (from == ZoneType.Library) {
|
||||
if (!GuiDialog.confirm(source, "Do you want to exile card(s) from you library?")) {
|
||||
if (!InputYesOrNo.ask("Do you want to exile " + nNeeded +
|
||||
" card" + (nNeeded == 1 ? "" : "s") + " from your library?")) {
|
||||
return false;
|
||||
}
|
||||
list = list.subList(0, nNeeded);
|
||||
|
||||
Reference in New Issue
Block a user