Chnaged tooltip text generation of modal spells to use bullets.

This commit is contained in:
LevelX2 2014-10-17 14:57:38 +02:00
parent 4e5a3ebaee
commit 400e8bf0ae
5 changed files with 56 additions and 52 deletions

View file

@ -37,6 +37,7 @@ public class SystemUtil {
* 3b. Parse next line (go to 2.), If EOF go to 4.<br/>
* 4. Log message to all players that cards were added (to prevent unfair play).<br/>
* 5. Exit<br/>
* @param game
*/
public static void addCardsForTesting(Game game) {
try {

View file

@ -74,11 +74,16 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
continue;
}
if (!(ability instanceof SpellAbility || ability instanceof PlayLandAbility)) {
if (ability.getRuleAtTheTop()) {
rules.add(0, ability.getRule());
} else {
rules.add(ability.getRule());
String rule = ability.getRule();
if (rule.length() > 3) {
rule = Character.toUpperCase(rule.charAt(0)) + rule.substring(1);
if (ability.getRuleAtTheTop()) {
rules.add(0, rule);
} else {
rules.add(rule);
}
}
continue;
}
if (ability instanceof SpellAbility) {
if (ability.getAlternativeCosts().size() > 0) {
@ -86,11 +91,11 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
for (AlternativeCost cost: ability.getAlternativeCosts()) {
if (cost.getClass().getName().equals("mage.abilities.costs.AlternativeCostImpl"))
{ // if the template class is used, the rule is in the getName() instead in the getText()
sbRule.append(cost.getName()).append(".\n");
sbRule.append(cost.getName()).append(".<br>");
}
else
{
sbRule.append(cost.getText()).append(".\n");
sbRule.append(cost.getText()).append(".<br>");
}
}
rules.add(sbRule.toString());
@ -102,17 +107,16 @@ public class AbilitiesImpl<T extends Ability> extends ArrayList<T> implements Ab
if (!cost.getText().startsWith("As an additional cost")) {
sbRule.append("As an additional cost to cast {this}, ");
}
sbRule.append(cost.getText()).append(".\n");
sbRule.append(cost.getText()).append(".<br>");
}
}
rules.add(sbRule.toString());
}
String rule = ability.getRule();
if (rule.length() > 1) {
rule = rule.substring(0, 1).toUpperCase() + rule.substring(1);
}
rules.add(rule);
}
if (rule.length() > 0) {
rules.add(Character.toUpperCase(rule.charAt(0)) + rule.substring(1));
}
}
}
return rules;

View file

@ -612,7 +612,6 @@ public abstract class AbilityImpl implements Ability {
sbRule.append(text);
}
}
return sbRule.toString();
}

View file

@ -177,36 +177,25 @@ public class Modes extends LinkedHashMap<UUID, Mode> {
}
public String getText() {
String andOr = "";
if (this.size() <= 1) {
return this.getMode().getEffects().getText(this.getMode());
}
StringBuilder sb = new StringBuilder();
if (this.size() > 1) {
if (this.getMinModes() == 1 && this.getMaxModes() == 3) {
sb.append("Choose one or more - ");
andOr = "; and/or ";
}else if (this.getMinModes() == 1 && this.getMaxModes() == 2) {
sb.append("Choose one or both - ");
andOr = "; and/or ";
} else if (this.getMinModes() == 2 && this.getMaxModes() == 2) {
sb.append("Choose two - ");
andOr = "; or ";
} else {
sb.append("Choose one - ");
andOr = "; or ";
}
if (this.getMinModes() == 1 && this.getMaxModes() == 3) {
sb.append("choose one or more - ");
}else if (this.getMinModes() == 1 && this.getMaxModes() == 2) {
sb.append("choose one or both - ");
} else if (this.getMinModes() == 2 && this.getMaxModes() == 2) {
sb.append("choose two - ");
} else {
sb.append("choose one - ");
}
sb.append("<br>");
for (Mode mode: this.values()) {
sb.append(mode.getEffects().getText(mode));
if (this.size() > 1) {
if (sb.length() > 2 && sb.substring(sb.length()-1, sb.length()).equals(".")) {
sb.delete(sb.length()-1, sb.length());
}
sb.append(andOr);
}
}
if (this.size() > 1) {
sb.delete(sb.length() - andOr.length(), sb.length());
sb.append(".");
}
sb.append("&bull ");
sb.append(mode.getEffects().getTextStartingUpperCase(mode));
sb.append("<br>");
}
return sb.toString();
}

View file

@ -53,25 +53,36 @@ public class Effects extends ArrayList<Effect> {
return new Effects(this);
}
public String getTextStartingUpperCase(Mode mode) {
String text = getText(mode);
if (text.length() > 3) {
return Character.toUpperCase(text.charAt(0)) + text.substring(1);
}
return text;
}
public String getText(Mode mode) {
StringBuilder sbText = new StringBuilder();
String rule = null;
String lastRule = null;
for (Effect effect: this) {
String endString = "";
if (rule != null && rule.length()> 3 && !rule.endsWith(".")) {
endString = ". ";
}
rule = effect.getText(mode);
if (rule != null) {
if (rule.startsWith("and ") || rule.startsWith("with ")) {
String endString = "";
String nextRule = effect.getText(mode);
if (nextRule != null) {
if (nextRule.startsWith("and ") || nextRule.startsWith("with ")) {
endString = " ";
} else if (rule.startsWith(",")) {
} else if (nextRule.startsWith(",")) {
endString = "";
} else if (lastRule != null && lastRule.length()> 3 && !lastRule.endsWith(".")) {
endString = ". ";
if (nextRule.length() > 3) {
nextRule = Character.toUpperCase(nextRule.charAt(0)) + nextRule.substring(1);
}
}
sbText.append(endString).append(rule);
sbText.append(endString).append(nextRule);
}
lastRule = nextRule;
}
if (rule != null && rule.length()> 3 && !rule.endsWith(".") && !rule.endsWith("\"") && !rule.startsWith("<b>Level ")) {
if (lastRule != null && lastRule.length()> 3 && !lastRule.endsWith(".") && !lastRule.endsWith("\"") && !lastRule.startsWith("<b>Level ")) {
sbText.append(".");
}
return sbText.toString();
@ -91,7 +102,7 @@ public class Effects extends ArrayList<Effect> {
for (Effect effect: this) {
outcomes.add(effect.getOutcome());
}
return new ArrayList(outcomes);
return new ArrayList<>(outcomes);
}
public int getOutcomeTotal() {