Improve message for Devour

This commit is contained in:
drdev
2014-09-12 23:45:55 +00:00
parent 014c02b4d0
commit b7c8a57730
4 changed files with 20 additions and 19 deletions

View File

@@ -100,7 +100,7 @@ public class Lang {
} }
public static <T> String nounWithNumeral(int cnt, String noun) { public static <T> String nounWithNumeral(int cnt, String noun) {
String countedForm = cnt <= 1 ? noun : getPlural(noun); String countedForm = cnt == 1 ? noun : getPlural(noun);
return getNumeral(cnt) + " " + countedForm; return getNumeral(cnt) + " " + countedForm;
} }
@@ -130,8 +130,9 @@ public class Lang {
public static String getNumeral(int n) { public static String getNumeral(int n) {
String prefix = n < 0 ? "minus " : ""; String prefix = n < 0 ? "minus " : "";
n = Math.abs(n); n = Math.abs(n);
if (n >= 0 && n < 20) if (n >= 0 && n < 20) {
return prefix + numbers0[n]; return prefix + numbers0[n];
}
if (n < 100) { if (n < 100) {
int n1 = n % 10; int n1 = n % 10;
String ones = n1 == 0 ? "" : numbers0[n1]; String ones = n1 == 0 ? "" : numbers0[n1];

View File

@@ -3164,8 +3164,8 @@ public class CardFactoryUtil {
String abStr = "DB$ ChangeZone | Hidden$ True | Origin$ All | Destination$ Battlefield" String abStr = "DB$ ChangeZone | Hidden$ True | Origin$ All | Destination$ Battlefield"
+ " | Defined$ ReplacedCard | SubAbility$ DevourCleanup"; + " | Defined$ ReplacedCard | SubAbility$ DevourCleanup";
String dbStr = "DB$ Sacrifice | Defined$ You | Amount$ DevourSacX | " String dbStr = "DB$ Sacrifice | Defined$ You | Amount$ DevourSacX | "
+ "References$ DevourSacX | SacValid$ Creature.Other | SacMessage$ creature (Devour " + "References$ DevourSacX | SacValid$ Creature.Other | SacMessage$ creature | "
+ magnitude + ") | RememberSacrificed$ True | Optional$ True | " + "RememberSacrificed$ True | Optional$ True | "
+ "Devour$ True | SubAbility$ DevourCounters"; + "Devour$ True | SubAbility$ DevourCounters";
String counterStr = "DB$ PutCounter | Defined$ Self | CounterType$ P1P1 | CounterNum$ DevourX" String counterStr = "DB$ PutCounter | Defined$ Self | CounterType$ P1P1 | CounterNum$ DevourX"
+ " | References$ DevourX,DevourSize | SubAbility$ DevourETB"; + " | References$ DevourX,DevourSize | SubAbility$ DevourETB";

View File

@@ -19,9 +19,9 @@ public class InputSelectEntitiesFromList<T extends GameEntity> extends InputSele
super(Math.min(min, validChoices.size()), Math.min(max, validChoices.size())); super(Math.min(min, validChoices.size()), Math.min(max, validChoices.size()));
this.validChoices = validChoices; this.validChoices = validChoices;
if ( min > validChoices.size() ) if (min > validChoices.size()) {
System.out.println(String.format("Trying to choose at least %d cards from a list with only %d cards!", min, validChoices.size())); System.out.println(String.format("Trying to choose at least %d cards from a list with only %d cards!", min, validChoices.size()));
}
} }
@Override @Override
@@ -69,10 +69,6 @@ public class InputSelectEntitiesFromList<T extends GameEntity> extends InputSele
protected boolean hasEnoughTargets() { return selected.size() >= min; } protected boolean hasEnoughTargets() { return selected.size() >= min; }
protected boolean hasAllTargets() { return selected.size() >= max; } protected boolean hasAllTargets() { return selected.size() >= max; }
/**
* TODO: Write javadoc for this method.
* @return
*/
protected String getMessage() { protected String getMessage() {
return max == Integer.MAX_VALUE return max == Integer.MAX_VALUE
? String.format(message, selected.size()) ? String.format(message, selected.size())

View File

@@ -200,24 +200,28 @@ public class PlayerControllerHuman extends PlayerController {
@Override @Override
public List<Card> choosePermanentsToSacrifice(SpellAbility sa, int min, int max, List<Card> valid, String message) { public List<Card> choosePermanentsToSacrifice(SpellAbility sa, int min, int max, List<Card> valid, String message) {
String outerMessage = "Select %d " + message + "(s) to sacrifice"; return choosePermanentsTo(min, max, valid, message, "sacrifice");
return choosePermanentsTo(min, max, valid, outerMessage);
} }
@Override @Override
public List<Card> choosePermanentsToDestroy(SpellAbility sa, int min, int max, List<Card> valid, String message) { public List<Card> choosePermanentsToDestroy(SpellAbility sa, int min, int max, List<Card> valid, String message) {
String outerMessage = "Select %d " + message + "(s) to be destroyed"; return choosePermanentsTo(min, max, valid, message, "destroy");
return choosePermanentsTo(min, max, valid, outerMessage);
} }
private List<Card> choosePermanentsTo(int min, int max, List<Card> valid, String outerMessage) { private List<Card> choosePermanentsTo(int min, int max, List<Card> valid, String message, String action) {
max = Math.min(max, valid.size()); max = Math.min(max, valid.size());
if (max <= 0) { if (max <= 0) {
return new ArrayList<Card>(); return new ArrayList<Card>();
} }
InputSelectCardsFromList inp = new InputSelectCardsFromList(min == 0 ? 1 : min, max, valid); StringBuilder builder = new StringBuilder("Select ");
inp.setMessage(outerMessage); if (min == 0) {
builder.append("up to ");
}
builder.append("%d " + message + "(s) to " + action + ".");
InputSelectCardsFromList inp = new InputSelectCardsFromList(min, max, valid);
inp.setMessage(builder.toString());
inp.setCancelAllowed(min == 0); inp.setCancelAllowed(min == 0);
inp.showAndWait(); inp.showAndWait();
return Lists.newArrayList(inp.getSelected()); return Lists.newArrayList(inp.getSelected());