Search in sources :

Example 16 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class MonsterclassToken method process.

@Override
public boolean process(LoadContext context, Race r) {
    LevelCommandFactory lcf = r.get(ObjectKey.MONSTER_CLASS);
    if (lcf != null) {
        String className = lcf.getLSTformat();
        PCClass pcc = context.getReferenceContext().silentlyGetConstructedCDOMObject(PCCLASS_CLASS, className);
        if (pcc != null && !pcc.isMonster()) {
            Logging.log(Logging.LST_WARNING, "Class " + className + " was used in RACE MONSTERCLASS, " + "but it is not a Monster class");
        }
    }
    return true;
}
Also used : LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) PCClass(pcgen.core.PCClass)

Example 17 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory 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 18 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class MonsterClassTokenTest method testUnparseSingle.

@Test
public void testUnparseSingle() throws PersistenceLayerException {
    primaryContext.getReferenceContext().constructCDOMObject(PCClass.class, "Fighter");
    CDOMSingleRef<PCClass> cl = primaryContext.getReferenceContext().getCDOMReference(PCClass.class, "Fighter");
    primaryProf.put(ObjectKey.MONSTER_CLASS, new LevelCommandFactory(cl, FormulaFactory.getFormulaFor(4)));
    String[] unparsed = getToken().unparse(primaryContext, primaryProf);
    expectSingle(unparsed, "Fighter:4");
}
Also used : LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) PCClass(pcgen.core.PCClass) Test(org.junit.Test)

Example 19 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class PreHDTest method testClassLevels.

/**
	 * Tests using monster class levels
	 * @throws Exception
	 */
public void testClassLevels() throws Exception {
    monClass.setName("Humanoid");
    monClass.put(ObjectKey.IS_MONSTER, true);
    Globals.getContext().getReferenceContext().importObject(monClass);
    race1.setName("Bugbear");
    CDOMDirectSingleRef<SizeAdjustment> largeRef = CDOMDirectSingleRef.getRef(large);
    race1.put(FormulaKey.SIZE, new FixedSizeFormula(largeRef));
    race1.put(ObjectKey.MONSTER_CLASS, new LevelCommandFactory(CDOMDirectSingleRef.getRef(monClass), FormulaFactory.getFormulaFor(3)));
    Globals.getContext().getReferenceContext().importObject(race1);
    final PlayerCharacter character = new PlayerCharacter();
    character.setRace(race1);
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREHD:MIN=4");
    assertFalse("Character doesn't have 4 HD", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREHD:MIN=3");
    assertTrue("Character has 3 HD", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREHD:MIN=1,MAX=3");
    assertTrue("Character has 3 HD", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREHD:MIN=3,MAX=6");
    assertTrue("Character has 3 HD", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREHD:MIN=4,MAX=7");
    assertFalse("Character doesn't have 4 HD", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREHD:MIN=1,MAX=2");
    assertFalse("Character doesn't have 2 or less HD", PrereqHandler.passes(prereq, character, null));
}
Also used : LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

Example 20 with LevelCommandFactory

use of pcgen.cdom.content.LevelCommandFactory in project pcgen by PCGen.

the class PreHDTest method testHD.

/**
	 * Test the PREHD code
	 * @throws Exception
	 */
public void testHD() throws Exception {
    race.setName("Human");
    CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
    race.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
    Globals.getContext().getReferenceContext().importObject(race);
    PCClass raceClass = new PCClass();
    raceClass.setName("Race Class");
    raceClass.put(StringKey.KEY_NAME, "RaceClass");
    raceClass.put(ObjectKey.IS_MONSTER, true);
    Globals.getContext().getReferenceContext().importObject(raceClass);
    race.put(ObjectKey.MONSTER_CLASS, new LevelCommandFactory(CDOMDirectSingleRef.getRef(raceClass), FormulaFactory.getFormulaFor(3)));
    final PlayerCharacter character = getCharacter();
    character.setRace(race);
    Prerequisite prereq;
    final PreParserFactory factory = PreParserFactory.getInstance();
    prereq = factory.parse("PREHD:MIN=4");
    assertFalse("Character doesn't have 4 HD", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREHD:MIN=3");
    assertTrue("Character has 3 HD", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREHD:MIN=1,MAX=3");
    assertTrue("Character has 3 HD", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREHD:MIN=3,MAX=6");
    assertTrue("Character has 3 HD", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREHD:MIN=4,MAX=7");
    assertFalse("Character doesn't have 4 HD", PrereqHandler.passes(prereq, character, null));
    prereq = factory.parse("PREHD:MIN=1,MAX=2");
    assertFalse("Character doesn't have 2 or less HD", PrereqHandler.passes(prereq, character, null));
}
Also used : LevelCommandFactory(pcgen.cdom.content.LevelCommandFactory) PlayerCharacter(pcgen.core.PlayerCharacter) PreParserFactory(pcgen.persistence.lst.prereq.PreParserFactory) PCClass(pcgen.core.PCClass) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

Aggregations

LevelCommandFactory (pcgen.cdom.content.LevelCommandFactory)25 PCClass (pcgen.core.PCClass)10 PlayerCharacter (pcgen.core.PlayerCharacter)7 CharID (pcgen.cdom.enumeration.CharID)4 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)4 ArrayList (java.util.ArrayList)3 Test (org.junit.Test)3 Race (pcgen.core.Race)3 SizeAdjustment (pcgen.core.SizeAdjustment)3 LoadContext (pcgen.rules.context.LoadContext)3 URI (java.net.URI)2 ParsingSeparator (pcgen.base.text.ParsingSeparator)2 CDOMObject (pcgen.cdom.base.CDOMObject)2 PCTemplate (pcgen.core.PCTemplate)2 BonusObj (pcgen.core.bonus.BonusObj)2 PCLevelInfo (pcgen.core.pclevelinfo.PCLevelInfo)2 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)2 PCClassLoader (pcgen.persistence.lst.PCClassLoader)2 PreParserFactory (pcgen.persistence.lst.prereq.PreParserFactory)2 PcgCombatant (gmgen.plugin.PcgCombatant)1