use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreSpellSchoolTest method testTwoClassSchool.
public void testTwoClassSchool() throws Exception {
final PlayerCharacter character = getCharacter();
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite prereq = factory.parse("PRESPELLSCHOOL:3,Fire=2,Useful=2");
assertFalse(PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, wiz);
boolean passes = PrereqHandler.passes(prereq, character, null);
assertFalse(passes);
character.incrementClassLevel(1, wiz);
passes = PrereqHandler.passes(prereq, character, null);
assertFalse(passes);
character.incrementClassLevel(1, cle);
passes = PrereqHandler.passes(prereq, character, null);
assertFalse(passes);
character.incrementClassLevel(1, cle);
passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreSpellDescriptorTest method testNotTwoClassDescriptor.
public void testNotTwoClassDescriptor() throws Exception {
final PlayerCharacter character = getCharacter();
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite prereq = factory.parse("!PRESPELLDESCRIPTOR:3,Fire=2,Useful=2");
assertTrue(PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, wiz);
boolean passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
character.incrementClassLevel(1, wiz);
passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
character.incrementClassLevel(1, cle);
passes = PrereqHandler.passes(prereq, character, null);
assertTrue(passes);
character.incrementClassLevel(1, cle);
passes = PrereqHandler.passes(prereq, character, null);
assertFalse(passes);
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class DomainTokenTest method testUnparseSinglePre.
@Test
public void testUnparseSinglePre() throws PersistenceLayerException {
Domain wp1 = construct(primaryContext, "TestWP1");
CDOMDirectSingleRef<Domain> ref = CDOMDirectSingleRef.getRef(wp1);
PreParserFactory prereqParser = PreParserFactory.getInstance();
Prerequisite prereq = prereqParser.parse("PRERACE:1,Dwarf");
assertNotNull(prereq);
QualifiedObject<CDOMSingleRef<Domain>> qo = new QualifiedObject<>(ref, prereq);
primaryProf.addToListFor(ListKey.DOMAIN, qo);
String[] unparsed = getToken().unparse(primaryContext, primaryProf);
expectSingle(unparsed, getLegalValue() + "|PRERACE:1,Dwarf");
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class MonNonSkillTHDTokenTest method testUnparseOnePrereq.
@Test
public void testUnparseOnePrereq() throws PersistenceLayerException {
BonusObj bonus = getBonus(1);
PreParserFactory prereqParser = PreParserFactory.getInstance();
Prerequisite prereq = prereqParser.parse("PRERACE:1,Dwarf");
assertNotNull(prereq);
bonus.addPrerequisite(prereq);
primaryProf.addToListFor(ListKey.BONUS, bonus);
String[] sap = getToken().unparse(primaryContext, primaryProf);
expectSingle(sap, "1|PRERACE:1,Dwarf");
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class StartFeatsTokenTest method getBonus.
private BonusObj getBonus(int bonusValue) throws PersistenceLayerException {
BonusObj bon = Bonus.newBonus(primaryContext, "FEAT|POOL|" + bonusValue);
assertNotNull(bon);
PreParserFactory prereqParser = PreParserFactory.getInstance();
Prerequisite prereq = prereqParser.parse("PREMULT:1,[PREHD:MIN=1],[PRELEVEL:MIN=1]");
assertNotNull(prereq);
bon.addPrerequisite(prereq);
bon.setTokenSource(token.getTokenName());
return bon;
}
Aggregations