Search in sources :

Example 6 with FixedSizeFormula

use of pcgen.cdom.formula.FixedSizeFormula 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 7 with FixedSizeFormula

use of pcgen.cdom.formula.FixedSizeFormula in project pcgen by PCGen.

the class SizeTokenTest method testUnparseLegal.

@Test
public void testUnparseLegal() throws PersistenceLayerException {
    FixedSizeFormula fsf = new FixedSizeFormula(CDOMDirectSingleRef.getRef(ps));
    primaryProf.put(FormulaKey.SIZE, fsf);
    expectSingle(getToken().unparse(primaryContext, primaryProf), ps.getKeyName());
}
Also used : FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula) Test(org.junit.Test)

Example 8 with FixedSizeFormula

use of pcgen.cdom.formula.FixedSizeFormula in project pcgen by PCGen.

the class SizeToken method parseNonEmptyToken.

@Override
public ParseResult parseNonEmptyToken(LoadContext context, Race race, String value) {
    CDOMSingleRef<SizeAdjustment> size = context.getReferenceContext().getCDOMReference(SizeAdjustment.class, value);
    Formula sizeFormula = new FixedSizeFormula(size);
    context.getObjectContext().put(race, FormulaKey.SIZE, sizeFormula);
    return ParseResult.SUCCESS;
}
Also used : FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula) Formula(pcgen.base.formula.Formula) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

Example 9 with FixedSizeFormula

use of pcgen.cdom.formula.FixedSizeFormula in project pcgen by PCGen.

the class PCClassTest method setUp.

/**
	 * @see pcgen.AbstractCharacterTestCase#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;
    try {
        source = new CampaignSourceEntry(customCampaign, new URI("file:/" + getClass().getName() + ".java"));
    } catch (URISyntaxException e) {
        throw new UnreachableError(e);
    }
    // Create the monseter class type
    GameMode gamemode = SettingsHandler.getGame();
    gamemode.addClassType("Monster		CRFORMULA:0			ISMONSTER:YES	XPPENALTY:NO");
    gamemode.setSkillMultiplierLevels("4");
    // 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);
    classDef = "CLASS:Nymph		KEY:KEY_Nymph	CLASSTYPE:Monster	HD:6	STARTSKILLPTS:6	MODTOSKILLS:YES	";
    classLoader = new PCClassLoader();
    nymphClass = classLoader.parseLine(context, null, classDef, source);
    Globals.getContext().getReferenceContext().importObject(nymphClass);
    CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
    CDOMDirectSingleRef<SizeAdjustment> largeRef = CDOMDirectSingleRef.getRef(large);
    // Create the large size mod
    // Create the BugBear race
    bugbearRace = new 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(IntegerKey.INITIAL_SKILL_MULT, 1);
    Globals.getContext().getReferenceContext().importObject(bugbearRace);
    bigBugbearRace = new Race();
    bigBugbearRace.setName("BigBugbear");
    bigBugbearRace.put(StringKey.KEY_NAME, "KEY_BigBugbear");
    bigBugbearRace.put(FormulaKey.SIZE, new FixedSizeFormula(largeRef));
    bigBugbearRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
    bigBugbearRace.put(IntegerKey.INITIAL_SKILL_MULT, 1);
    Globals.getContext().getReferenceContext().importObject(bigBugbearRace);
    // Create the Nymph race
    nymphRace = new Race();
    nymphRace.setName("Nymph");
    nymphRace.put(StringKey.KEY_NAME, "KEY_Nymph");
    nymphRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
    nymphRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
    nymphRace.put(ObjectKey.MONSTER_CLASS, new LevelCommandFactory(CDOMDirectSingleRef.getRef(nymphClass), FormulaFactory.getFormulaFor(0)));
    Globals.getContext().getReferenceContext().importObject(nymphRace);
    // Setup class with prereqs and var based abilities with prereqs.
    PreVariableParser parser = new PreVariableParser();
    prereq = parser.parse("VARGTEQ", "Foo,1", false, false);
    classPreRule = new RuleCheck();
    classPreRule.setName("CLASSPRE");
    classPreRule.setDefault(false);
    gamemode.getModeContext().getReferenceContext().importObject(classPreRule);
    prClass = new PCClass();
    prClass.setName("PreReqClass");
    prClass.put(StringKey.KEY_NAME, "KEY_PreReqClass");
    final BonusObj aBonus = Bonus.newBonus(context, "MISC|SR|10|PREVARGTEQ:Foo,2");
    if (aBonus != null) {
        prClass.addToListFor(ListKey.BONUS, aBonus);
    }
    prClass.addPrerequisite(prereq);
    qClass = new PCClass();
    qClass.setName("QualClass");
    qClass.put(StringKey.KEY_NAME, "KEY_QualClass");
    CDOMDirectSingleRef<PCClass> ref = CDOMDirectSingleRef.getRef(prClass);
    qClass.addToListFor(ListKey.QUALIFY, new Qualifier(PCClass.class, ref));
    nqClass = new PCClass();
    nqClass.setName("NonQualClass");
    nqClass.put(StringKey.KEY_NAME, "KEY_NonQualClass");
    nqClass.put(VariableKey.getConstant("Foo"), FormulaFactory.ONE);
    nqClass.getOriginalClassLevel(2).put(VariableKey.getConstant("Foo"), FormulaFactory.getFormulaFor(2));
}
Also used : LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) BonusObj(pcgen.core.bonus.BonusObj) PreVariableParser(plugin.pretokens.parser.PreVariableParser) URISyntaxException(java.net.URISyntaxException) UnreachableError(pcgen.base.lang.UnreachableError) URI(java.net.URI) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula) CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) LoadContext(pcgen.rules.context.LoadContext) PCClassLoader(pcgen.persistence.lst.PCClassLoader) Qualifier(pcgen.cdom.reference.Qualifier)

Example 10 with FixedSizeFormula

use of pcgen.cdom.formula.FixedSizeFormula in project pcgen by PCGen.

the class ClassLevelCommandTest method setUp.

/**
	 * @throws Exception
	 * @see pcgen.AbstractCharacterTestCase#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"));
    // Create the monseter class type
    GameMode gamemode = SettingsHandler.getGame();
    gamemode.addClassType("Monster		CRFORMULA:0			ISMONSTER:YES	XPPENALTY:NO");
    gamemode.setSkillMultiplierLevels("4");
    gamemode.setMaxNonEpicLevel(20);
    CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
    // Create the Nymph race
    nymphRace = new Race();
    nymphRace.setName("Nymph");
    nymphRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
    nymphRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
    Globals.getContext().getReferenceContext().importObject(nymphRace);
    // Create the humanoid class
    humanoidClass = new PCClass();
    humanoidClass.setName("Humanoid");
    humanoidClass.addToListFor(ListKey.TYPE, Type.getConstant("Monster"));
    Globals.getContext().getReferenceContext().importObject(humanoidClass);
    nymphClass = new PCClass();
    nymphClass.setName("Nymph");
    nymphClass.addToListFor(ListKey.TYPE, Type.getConstant("Monster"));
    Globals.getContext().getReferenceContext().importObject(nymphClass);
    megaCasterClass = new PCClass();
    megaCasterClass.setName("MegaCaster");
    BuildUtilities.setFact(megaCasterClass, "SpellType", "Arcane");
    Globals.getContext().unconditionallyProcess(megaCasterClass, "SPELLSTAT", "CHA");
    megaCasterClass.put(ObjectKey.SPELLBOOK, false);
    megaCasterClass.put(ObjectKey.MEMORIZE_SPELLS, false);
    Globals.getContext().getReferenceContext().importObject(megaCasterClass);
}
Also used : GameMode(pcgen.core.GameMode) Campaign(pcgen.core.Campaign) Description(pcgen.core.Description) Race(pcgen.core.Race) PCClass(pcgen.core.PCClass) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

Aggregations

FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)16 SizeAdjustment (pcgen.core.SizeAdjustment)14 LoadContext (pcgen.rules.context.LoadContext)9 PlayerCharacter (pcgen.core.PlayerCharacter)8 Race (pcgen.core.Race)8 Equipment (pcgen.core.Equipment)6 WieldCategory (pcgen.core.character.WieldCategory)6 LevelCommandFactory (pcgen.cdom.content.LevelCommandFactory)4 URI (java.net.URI)3 Campaign (pcgen.core.Campaign)3 Description (pcgen.core.Description)3 PCClass (pcgen.core.PCClass)3 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)3 PCClassLoader (pcgen.persistence.lst.PCClassLoader)3 Formula (pcgen.base.formula.Formula)2 GameMode (pcgen.core.GameMode)2 BonusObj (pcgen.core.bonus.BonusObj)2 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)2 URISyntaxException (java.net.URISyntaxException)1 Test (org.junit.Test)1