forked from External/mage
TargetAmount refactors (#13128)
* Add minimum and maximum target counts as parameters for TargetAmount and its subclasses; update/add several rules comments (and one actual text) for clarity; remove unused imports * Get amount+description from target instead of parameters for DistributeCountersEffect and DamageMultiEffect; additions to TargetImpl.getDescription to accommodate * Create separate method to check if "any number" phrasing should be used, override it in TargetAmount * Check instanceof TargetAmount before casting * Add new constructors to chain off of for TargetCreaturePermanentAmount & TargetCreatureOrPlaneswalkerAmount * Fix text for Storm the Seedcore * Use Integer.MAX_VALUE instead of 0 to represent no maximum targets * Add comment about getUseAnyNumber() * Use amount-only constructors in some TargetAmount subclasses, add clarifying documentation * Fix a few calls * Require more specific filters
This commit is contained in:
parent
960c26a291
commit
73b63d14ad
123 changed files with 444 additions and 365 deletions
|
|
@ -109,17 +109,22 @@ public abstract class TargetImpl implements Target {
|
|||
sb.append(" or more ");
|
||||
} else if (!targetName.startsWith("X ") && (min != 1 || max != 1)) {
|
||||
targetName = targetName.replace("another", "other"); //If non-singular, use "other" instead of "another"
|
||||
if (min < max && max != Integer.MAX_VALUE) {
|
||||
if (min == 1 && max == 2) {
|
||||
sb.append("one or ");
|
||||
} else if (min == 1 && max == 3) {
|
||||
sb.append("one, two, or ");
|
||||
} else {
|
||||
sb.append("up to ");
|
||||
|
||||
if (getUseAnyNumber()) {
|
||||
sb.append(("any number of "));
|
||||
} else {
|
||||
if (min < max && max != Integer.MAX_VALUE) {
|
||||
if (min == 1 && max == 2) {
|
||||
sb.append("one or ");
|
||||
} else if (min == 1 && max == 3) {
|
||||
sb.append("one, two, or ");
|
||||
} else {
|
||||
sb.append("up to ");
|
||||
}
|
||||
}
|
||||
sb.append(CardUtil.numberToText(max));
|
||||
sb.append(' ');
|
||||
}
|
||||
sb.append(CardUtil.numberToText(max));
|
||||
sb.append(' ');
|
||||
}
|
||||
boolean addTargetWord = false;
|
||||
if (!isNotTarget()) {
|
||||
|
|
@ -127,7 +132,8 @@ public abstract class TargetImpl implements Target {
|
|||
if (targetName.contains("target ")) {
|
||||
addTargetWord = false;
|
||||
} else if (targetName.endsWith("any target")
|
||||
|| targetName.endsWith("any other target")) {
|
||||
|| targetName.endsWith("any other target")
|
||||
|| targetName.endsWith("targets")) {
|
||||
addTargetWord = false;
|
||||
}
|
||||
// endsWith needs to be specific.
|
||||
|
|
@ -144,6 +150,15 @@ public abstract class TargetImpl implements Target {
|
|||
return sb.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for generating text description. Needed so that subclasses may override.
|
||||
*/
|
||||
protected boolean getUseAnyNumber() {
|
||||
int min = getMinNumberOfTargets();
|
||||
int max = getMaxNumberOfTargets();
|
||||
return min == 0 && max == Integer.MAX_VALUE;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getMessage(Game game) {
|
||||
// UI choose message
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue