use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.
the class VisionTokenTest method setUp.
/*
* @see TestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
final GenericLoader<PCTemplate> loader = new GenericLoader<>(PCTemplate.class);
final LoadContext context = Globals.getContext();
CampaignSourceEntry source;
try {
source = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
} catch (URISyntaxException e) {
throw new UnreachableError(e);
}
loader.parseLine(context, null, "Darkvision VISION:Darkvision (60')", source);
darkvisionT = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCTemplate.class, "Darkvision");
loader.parseLine(context, null, "Low-light VISION:Low-light", source);
lowlightT = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCTemplate.class, "Low-light");
loader.parseLine(context, null, "Astral VISION:Astral (130')", source);
astralT = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCTemplate.class, "Astral");
assertTrue(context.getReferenceContext().resolveReferences(null));
metricUS = new UnitSet();
metricUS.setName("Metric");
metricUS.setDistanceUnit("m");
metricUS.setDistanceFactor(new BigDecimal(0.3));
metricUS.setDistanceDisplayPattern(new DecimalFormat("#.##"));
SettingsHandler.getGame().getModeContext().getReferenceContext().importObject(metricUS);
}
use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.
the class FeatTest method testAlertness.
/**
* Test Alertness Feat
* @throws Exception
*/
public void testAlertness() throws Exception {
Ability alertnessFeat;
FeatLoader featLoader = new FeatLoader();
CampaignSourceEntry source;
try {
source = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
} catch (URISyntaxException e) {
throw new UnreachableError(e);
}
alertnessFeat = new Ability();
featLoader.parseLine(Globals.getContext(), alertnessFeat, "Alertness TYPE:General DESC:+2 on Listen and Spot checks BONUS:SKILL|Listen,Spot|2", source);
assertEquals("Alertness", alertnessFeat.getKeyName());
}
use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.
the class AssociationListKey method buildMap.
private static void buildMap() {
map = new CaseInsensitiveMap<>();
Field[] fields = AssociationListKey.class.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
int mod = fields[i].getModifiers();
if (Modifier.isStatic(mod) && Modifier.isFinal(mod) && Modifier.isPublic(mod)) {
try {
Object obj = fields[i].get(null);
if (obj instanceof AssociationListKey) {
map.put(fields[i].getName(), (AssociationListKey<?>) obj);
}
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new UnreachableError(e);
}
}
}
}
use of pcgen.base.lang.UnreachableError in project pcgen by PCGen.
the class ListKey method buildMap.
private static void buildMap() {
map = new CaseInsensitiveMap<>();
Field[] fields = ListKey.class.getDeclaredFields();
for (int i = 0; i < fields.length; i++) {
int mod = fields[i].getModifiers();
if (java.lang.reflect.Modifier.isStatic(mod) && java.lang.reflect.Modifier.isFinal(mod) && java.lang.reflect.Modifier.isPublic(mod)) {
try {
Object obj = fields[i].get(null);
if (obj instanceof ListKey) {
map.put(fields[i].getName(), (ListKey<?>) obj);
}
} catch (IllegalArgumentException | IllegalAccessException e) {
throw new UnreachableError(e);
}
}
}
}
Aggregations