updated counter adding text to handle articles correctly

This commit is contained in:
Evan Kranzler 2021-01-31 11:46:32 -05:00
parent f9dfb56d4e
commit f76107702f
6 changed files with 49 additions and 35 deletions

View file

@ -74,8 +74,8 @@ public enum CounterType {
HEXPROOF("hexproof"),
HIT("hit"),
HOOFPRINT("hoofprint"),
HOUR("hour"),
HOURGLASS("hourglass"),
HOUR("hour", "an"),
HOURGLASS("hourglass", "an"),
HUNGER("hunger"),
ICE("ice"),
INCARNATION("incarnation"),
@ -158,7 +158,7 @@ public enum CounterType {
TRAMPLE("trample"),
TRAP("trap"),
TREASURE("treasure"),
UNITY("unity"),
UNITY("unity", "a"),
VELOCITY("velocity"),
VERSE("verse"),
VIGILANCE("vigilance"),
@ -171,10 +171,16 @@ public enum CounterType {
WISH("wish");
private final String name;
private final String article;
private final CounterPredicate predicate;
CounterType(String name) {
this(name, "aeiou".contains("" + name.charAt(0)) ? "an" : "a");
}
CounterType(String name, String article) {
this.name = name;
this.article = article;
this.predicate = new CounterPredicate(this);
}
@ -187,6 +193,10 @@ public enum CounterType {
return this.name;
}
public String getArticle() {
return article;
}
/**
* Create instance of counter type with amount equal to 1.
*
@ -268,6 +278,11 @@ public enum CounterType {
return null;
}
public static String findArticle(String name) {
CounterType counterType = findByName(name);
return counterType == null ? "a" : counterType.article;
}
public CounterPredicate getPredicate() {
return predicate;
}