Search in sources :

Example 1 with UnitSet

use of pcgen.core.UnitSet in project pcgen by PCGen.

the class GameModeFileLoader method getDefaultUnitSet.

private static synchronized UnitSet getDefaultUnitSet() {
    if (DEFAULT_UNIT_SET == null) {
        // create default Unit Set in case none is specified in the game mode
        DEFAULT_UNIT_SET = new UnitSet();
        DEFAULT_UNIT_SET.setName(Constants.STANDARD_UNITSET_NAME);
        DEFAULT_UNIT_SET.setInternal(true);
        DEFAULT_UNIT_SET.setHeightUnit(Constants.STANDARD_UNITSET_HEIGHT_UNIT);
        DEFAULT_UNIT_SET.setHeightFactor(Constants.STANDARD_UNITSET_HEIGHT_FACTOR);
        DEFAULT_UNIT_SET.setHeightDisplayPattern(Constants.STANDARD_UNITSET_HEIGHT_DISPLAY_PATTERN);
        DEFAULT_UNIT_SET.setDistanceUnit(Constants.STANDARD_UNITSET_DISTANCE_UNIT);
        DEFAULT_UNIT_SET.setDistanceFactor(Constants.STANDARD_UNITSET_DISTANCE_FACTOR);
        DEFAULT_UNIT_SET.setDistanceDisplayPattern(Constants.STANDARD_UNITSET_DISTANCE_DISPLAY_PATTERN);
        DEFAULT_UNIT_SET.setWeightUnit(Constants.STANDARD_UNITSET_WEIGHT_UNIT);
        DEFAULT_UNIT_SET.setWeightFactor(Constants.STANDARD_UNITSET_WEIGHT_FACTOR);
        DEFAULT_UNIT_SET.setWeightDisplayPattern(Constants.STANDARD_UNITSET_WEIGHT_DISPLAY_PATTERN);
    }
    return DEFAULT_UNIT_SET;
}
Also used : UnitSet(pcgen.core.UnitSet)

Example 2 with UnitSet

use of pcgen.core.UnitSet in project pcgen by PCGen.

the class GameModeFileLoader method addDefaultUnitSet.

public static void addDefaultUnitSet(GameMode gameMode) {
    LoadContext context = gameMode.getModeContext();
    UnitSet us = context.getReferenceContext().silentlyGetConstructedCDOMObject(UnitSet.class, Constants.STANDARD_UNITSET_NAME);
    if (us == null) {
        gameMode.getModeContext().getReferenceContext().importObject(getDefaultUnitSet());
    }
}
Also used : LoadContext(pcgen.rules.context.LoadContext) UnitSet(pcgen.core.UnitSet)

Example 3 with UnitSet

use of pcgen.core.UnitSet 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)

Aggregations

UnitSet (pcgen.core.UnitSet)3 LoadContext (pcgen.rules.context.LoadContext)2 BigDecimal (java.math.BigDecimal)1 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 DecimalFormat (java.text.DecimalFormat)1 UnreachableError (pcgen.base.lang.UnreachableError)1 Campaign (pcgen.core.Campaign)1 PCTemplate (pcgen.core.PCTemplate)1 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)1 GenericLoader (pcgen.persistence.lst.GenericLoader)1