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;
}
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));
}
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");
}
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));
}
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));
}
Aggregations