Fix formatting for Champion keyword

This commit is contained in:
drdev
2014-07-18 08:16:26 +00:00
parent d754c4efd0
commit fcc3818a00
3 changed files with 11 additions and 11 deletions

View File

@@ -3,10 +3,12 @@ package forge.util;
import com.google.common.base.Function;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import org.apache.commons.lang3.StringUtils;
import java.util.Collection;
import java.util.List;
import java.util.regex.Pattern;
/**
* TODO: Write javadoc for this type.
@@ -115,13 +117,9 @@ public class Lang {
return isVowel(word.trim().charAt(0));
}
private static final char[] vowels = { 'a', 'i', 'e', 'o', 'u' };
private static final Pattern VOWEL_PATTERN = Pattern.compile("[aeiou]", Pattern.CASE_INSENSITIVE);
public static boolean isVowel(char letter) {
char l = Character.toLowerCase(letter);
for (char c : vowels) {
if (c == l) return true;
}
return false;
return VOWEL_PATTERN.matcher(String.valueOf(letter)).find();
}
public final static String[] numbers0 = new String[] {

View File

@@ -2161,6 +2161,10 @@ public class CardFactoryUtil {
final String[] k = parse.split(":");
final String[] valid = k[1].split(",");
String desc = k.length > 2 ? k[2] : k[1];
String article = Lang.startsWithVowel(desc) ? "an" : "a";
if (desc.equals("Creature")) {
desc = "creature"; //use lowercase for "Champion a creature"
}
StringBuilder changeType = new StringBuilder();
for (String v : valid) {
@@ -2172,7 +2176,7 @@ public class CardFactoryUtil {
StringBuilder trig = new StringBuilder();
trig.append("Mode$ ChangesZone | Origin$ Any | Destination$ Battlefield | ValidCard$ Card.Self | ");
trig.append("Execute$ ChampionAbility | TriggerDescription$ Champion a(n) ");
trig.append("Execute$ ChampionAbility | TriggerDescription$ Champion ").append(article + " ");
trig.append(desc).append(" (When this enters the battlefield, sacrifice it unless you exile another ");
trig.append(desc).append(" you control. When this leaves the battlefield, that card returns to the battlefield.)");

View File

@@ -23,11 +23,11 @@ import forge.game.card.Card;
import forge.game.card.CounterType;
import forge.game.mana.ManaCostBeingPaid;
import forge.game.zone.ZoneType;
import forge.util.Lang;
import forge.util.TextUtil;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Pattern;
import com.google.common.collect.Lists;
@@ -643,8 +643,6 @@ public class Cost {
* <code>numNames="{zero, a, two, three, four, five, six, "{trunked}</code>
*/
private static final String[] NUM_NAMES = { "zero", "a", "two", "three", "four", "five", "six", "seven", "eight", "nine", "ten" };
/** Constant <code>vowelPattern</code>. */
private static final Pattern VOWEL_PATTERN = Pattern.compile("^[aeiou]", Pattern.CASE_INSENSITIVE);
/**
* Convert amount type to words.
@@ -686,7 +684,7 @@ public class Cost {
if (i >= Cost.NUM_NAMES.length) {
sb.append(i);
}
else if ((1 == i) && Cost.VOWEL_PATTERN.matcher(type).find()) {
else if (i == 1 && Lang.startsWithVowel(type)) {
sb.append("an");
}
else {