magarena/src/magic/model/MagicRarity.java

51 lines
1.1 KiB
Java
Raw Normal View History

2011-06-23 21:08:53 -07:00
package magic.model;
import java.util.EnumSet;
2020-01-15 12:02:42 -08:00
2016-10-26 01:46:59 -07:00
import magic.translate.MText;
2011-06-23 21:08:53 -07:00
public enum MagicRarity {
2016-06-17 19:12:34 -07:00
Basic(MagicRarityStr._SBasic, 'B'),
Common(MagicRarityStr._SCommon, 'C'),
Uncommon(MagicRarityStr._SUncommon, 'U'),
Rare(MagicRarityStr._SRare, 'R'),
Mythic_Rare(MagicRarityStr._SMythicRare, 'M');
2011-06-23 21:08:53 -07:00
public static final int length = values().length;
2013-06-23 18:33:35 -07:00
private final char c;
private final String displayName;
2011-06-23 21:08:53 -07:00
private MagicRarity(final String aName, final char c) {
2016-10-26 01:46:59 -07:00
this.displayName = MText.get(aName);
2011-06-23 21:08:53 -07:00
this.c = c;
}
public char getChar() {
return c;
}
public String getName() {
return displayName;
2011-06-23 21:08:53 -07:00
}
2013-06-23 18:33:35 -07:00
2012-06-16 07:55:26 -07:00
public static MagicRarity getRarity(final char c) {
for (final MagicRarity type : values()) {
if (type.c == c) {
return type;
}
}
2014-07-28 07:26:01 -07:00
throw new RuntimeException("unknown rarity \"" + c + "\"");
2012-06-16 07:55:26 -07:00
}
public static String[] getDisplayNames() {
return EnumSet.allOf(MagicRarity.class)
.stream()
.map(MagicRarity::getName)
.toArray(String[]::new);
}
2016-06-17 19:12:34 -07:00
2011-06-23 21:08:53 -07:00
}