Search in sources :

Example 16 with SizeAdjustment

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

the class TestHelper method makeSizeAdjustments.

/**
	 * Make some size adjustments
	 */
public static void makeSizeAdjustments() {
    final String sizes = "Fine|Diminutive|Tiny|Small|Medium|Large|Huge|Gargantuan|Colossal";
    final StringTokenizer aTok = new StringTokenizer(sizes, "|");
    GameMode gamemode = SystemCollections.getGameModeNamed("3.5");
    if (gamemode == null) {
        gamemode = new GameMode("3.5");
        SystemCollections.addToGameModeList(gamemode);
        GameModeFileLoader.addDefaultTabInfo(gamemode);
    }
    SettingsHandler.setGame("3.5");
    int count = 0;
    while (aTok.hasMoreTokens()) {
        SizeAdjustment sa = BuildUtilities.createSize(aTok.nextToken(), count++);
        Globals.getContext().getReferenceContext().importObject(sa);
    }
    Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(SizeAdjustment.class, "M").put(ObjectKey.IS_DEFAULT_SIZE, true);
}
Also used : GameMode(pcgen.core.GameMode) StringTokenizer(java.util.StringTokenizer) SizeAdjustment(pcgen.core.SizeAdjustment)

Example 17 with SizeAdjustment

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

the class PreBaseSizeParser method parse.

/**
	 * Parse the pre req list
	 *
	 * @param kind The kind of the prerequisite (less the "PRE" prefix)
	 * @param formula The body of the prerequisite.
	 * @param invertResult Whether the prerequisite should invert the result.
	 * @param overrideQualify
	 *           if set true, this prerequisite will be enforced in spite
	 *           of any "QUALIFY" tag that may be present.
	 * @return PreReq
	 * @throws PersistenceLayerException
	 */
@Override
public Prerequisite parse(String kind, String formula, boolean invertResult, boolean overrideQualify) throws PersistenceLayerException {
    Prerequisite prereq = super.parse(kind, formula, invertResult, overrideQualify);
    try {
        prereq.setKind("basesize");
        // Get the comparator type BASESIZEGTEQ, BASESIZE, BASESIZENEQ etc.
        String compType = kind.substring(8);
        if (compType.isEmpty()) {
            compType = "gteq";
        }
        prereq.setOperator(compType);
        String abb = formula.substring(0, 1);
        LoadContext context = Globals.getContext();
        CDOMSingleRef<SizeAdjustment> ref = context.getReferenceContext().getCDOMReference(SizeAdjustment.class, abb);
        context.forgetMeNot(ref);
        prereq.setOperand(abb);
        if (invertResult) {
            prereq.setOperator(prereq.getOperator().invert());
        }
    } catch (PrerequisiteException pe) {
        throw new PersistenceLayerException("Unable to parse the prerequisite :'" + kind + ':' + formula + "'. " + pe.getLocalizedMessage());
    }
    return prereq;
}
Also used : PrerequisiteException(pcgen.core.prereq.PrerequisiteException) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) LoadContext(pcgen.rules.context.LoadContext) SizeAdjustment(pcgen.core.SizeAdjustment) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 18 with SizeAdjustment

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

the class PCTLTermEvaluatorTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    Campaign customCampaign = new Campaign();
    customCampaign.setName("Unit Test");
    customCampaign.setName("KEY_Unit Test");
    customCampaign.addToListFor(ListKey.DESCRIPTION, new Description("Unit Test data"));
    CampaignSourceEntry source = new CampaignSourceEntry(customCampaign, new URI("file:/" + getClass().getName() + ".java"));
    // Create the humanoid class
    String classDef = "CLASS:Humanoid	KEY:KEY_Humanoid	HD:8		CLASSTYPE:Monster	STARTSKILLPTS:1	" + "MODTOSKILLS:NO	MONSKILL:6+INT	MONNONSKILLHD:1|PRESIZELTEQ:M	" + "MONNONSKILLHD:2|PRESIZEEQ:L";
    PCClassLoader classLoader = new PCClassLoader();
    LoadContext context = Globals.getContext();
    humanoidClass = classLoader.parseLine(context, null, classDef, source);
    Globals.getContext().getReferenceContext().importObject(humanoidClass);
    // Create the BugBear race
    bugbearRace = new Race();
    bugbearRace.setName("Bugbear");
    bugbearRace.put(StringKey.KEY_NAME, "KEY_Bugbear");
    CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
    bugbearRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
    bugbearRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
    bugbearRace.put(IntegerKey.INITIAL_SKILL_MULT, 1);
    Globals.getContext().getReferenceContext().importObject(bugbearRace);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) Description(pcgen.core.Description) Race(pcgen.core.Race) LoadContext(pcgen.rules.context.LoadContext) PCClassLoader(pcgen.persistence.lst.PCClassLoader) URI(java.net.URI) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

Example 19 with SizeAdjustment

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

the class PCRacialHDSizeTermEvaluatorTest method setUp.

@Override
protected void setUp() throws Exception {
    super.setUp();
    Campaign customCampaign = new Campaign();
    customCampaign.setName("Unit Test");
    customCampaign.setName("KEY_Unit Test");
    customCampaign.addToListFor(ListKey.DESCRIPTION, new Description("Unit Test data"));
    CampaignSourceEntry source = new CampaignSourceEntry(customCampaign, new URI("file:/" + getClass().getName() + ".java"));
    LoadContext context = Globals.getContext();
    PCClassLoader classLoader = new PCClassLoader();
    // Create the humanoid monster class
    final String humanoidClassLine = "CLASS:Humanoid	KEY:KEY_Humanoid	HD:8	TYPE:Monster	CLASSTYPE:Monster	" + "STARTSKILLPTS:2	MODTOSKILLS:YES";
    humanoidClass = classLoader.parseLine(context, null, humanoidClassLine, source);
    context.getReferenceContext().importObject(humanoidClass);
    // Create the pc class
    final String pcClassLine = "CLASS:TestPCClass	TYPE:PC		HD:10";
    pcClass = classLoader.parseLine(context, null, pcClassLine, source);
    context.getReferenceContext().importObject(pcClass);
    CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
    // Create the BugBear race
    bugbearRace.setName("Bugbear");
    bugbearRace.put(StringKey.KEY_NAME, "KEY_Bugbear");
    bugbearRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
    bugbearRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
    bugbearRace.put(ObjectKey.MONSTER_CLASS, new LevelCommandFactory(CDOMDirectSingleRef.getRef(humanoidClass), FormulaFactory.getFormulaFor(3)));
    context.getReferenceContext().importObject(bugbearRace);
    // Create the human race
    humanRace.setName("Human");
    humanRace.put(StringKey.KEY_NAME, "KEY_Human");
    humanRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
    context.getReferenceContext().importObject(humanRace);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) Description(pcgen.core.Description) LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) LoadContext(pcgen.rules.context.LoadContext) PCClassLoader(pcgen.persistence.lst.PCClassLoader) URI(java.net.URI) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

Example 20 with SizeAdjustment

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

the class SizeTokenTest method setUp.

@Override
@Before
public void setUp() throws PersistenceLayerException, URISyntaxException {
    super.setUp();
    SizeAdjustment ps = BuildUtilities.createSize("Small", 0);
    primaryContext.getReferenceContext().importObject(ps);
    SizeAdjustment pm = BuildUtilities.createSize("Medium", 1);
    primaryContext.getReferenceContext().importObject(pm);
    SizeAdjustment ss = BuildUtilities.createSize("Small", 0);
    secondaryContext.getReferenceContext().importObject(ss);
    SizeAdjustment sm = BuildUtilities.createSize("Medium", 1);
    secondaryContext.getReferenceContext().importObject(sm);
}
Also used : SizeAdjustment(pcgen.core.SizeAdjustment) Before(org.junit.Before)

Aggregations

SizeAdjustment (pcgen.core.SizeAdjustment)43 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)14 Equipment (pcgen.core.Equipment)11 Race (pcgen.core.Race)10 LoadContext (pcgen.rules.context.LoadContext)10 PlayerCharacter (pcgen.core.PlayerCharacter)8 Before (org.junit.Before)7 WieldCategory (pcgen.core.character.WieldCategory)7 Formula (pcgen.base.formula.Formula)3 LevelCommandFactory (pcgen.cdom.content.LevelCommandFactory)3 Campaign (pcgen.core.Campaign)3 Description (pcgen.core.Description)3 GameMode (pcgen.core.GameMode)3 PCClass (pcgen.core.PCClass)3 Prerequisite (pcgen.core.prereq.Prerequisite)3 AbstractReferenceContext (pcgen.rules.context.AbstractReferenceContext)3 BigDecimal (java.math.BigDecimal)2 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 StringTokenizer (java.util.StringTokenizer)2