Search in sources :

Example 36 with UnreachableError

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);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) DecimalFormat(java.text.DecimalFormat) GenericLoader(pcgen.persistence.lst.GenericLoader) LoadContext(pcgen.rules.context.LoadContext) UnitSet(pcgen.core.UnitSet) URISyntaxException(java.net.URISyntaxException) UnreachableError(pcgen.base.lang.UnreachableError) PCTemplate(pcgen.core.PCTemplate) URI(java.net.URI) BigDecimal(java.math.BigDecimal)

Example 37 with UnreachableError

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());
}
Also used : Ability(pcgen.core.Ability) Campaign(pcgen.core.Campaign) URISyntaxException(java.net.URISyntaxException) UnreachableError(pcgen.base.lang.UnreachableError) URI(java.net.URI)

Example 38 with UnreachableError

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);
            }
        }
    }
}
Also used : Field(java.lang.reflect.Field) UnreachableError(pcgen.base.lang.UnreachableError)

Example 39 with UnreachableError

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);
            }
        }
    }
}
Also used : Field(java.lang.reflect.Field) QualifiedObject(pcgen.core.QualifiedObject) UnreachableError(pcgen.base.lang.UnreachableError)

Aggregations

UnreachableError (pcgen.base.lang.UnreachableError)39 URI (java.net.URI)23 URISyntaxException (java.net.URISyntaxException)23 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)19 LoadContext (pcgen.rules.context.LoadContext)14 Field (java.lang.reflect.Field)9 Ability (pcgen.core.Ability)9 Campaign (pcgen.core.Campaign)9 CDOMReference (pcgen.cdom.base.CDOMReference)7 AbilityList (pcgen.cdom.list.AbilityList)6 CNAbility (pcgen.cdom.content.CNAbility)5 PlayerCharacter (pcgen.core.PlayerCharacter)4 FeatLoader (pcgen.persistence.lst.FeatLoader)4 ArrayList (java.util.ArrayList)3 PCClass (pcgen.core.PCClass)3 PCTemplate (pcgen.core.PCTemplate)3 QualifiedObject (pcgen.core.QualifiedObject)3 AbilityLoader (pcgen.persistence.lst.AbilityLoader)3 GenericLoader (pcgen.persistence.lst.GenericLoader)3 PCClassLoader (pcgen.persistence.lst.PCClassLoader)3