use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreLangTest method testLang.
/**
* Test the PRELANG code
* @throws Exception
*/
public void testLang() throws Exception {
final PlayerCharacter character = getCharacter();
character.addFreeLanguage(elven, elven);
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PRELANG:1,KEY_Elven");
assertTrue("Character should have elven", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRELANG:1,KEY_Elven,KEY_Dwarven");
assertTrue("Character should have elven", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRELANG:2,KEY_Elven,KEY_Dwarven");
assertFalse("Character doesn't have Dwarven", PrereqHandler.passes(prereq, character, null));
character.addFreeLanguage(dwarven, dwarven);
assertTrue("Character has Elven and Dwarven", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRELANG:3,ANY");
assertFalse("Character doesn't have 3 langs", PrereqHandler.passes(prereq, character, null));
character.addFreeLanguage(halfling, halfling);
assertTrue("Character has Elven, Dwarven, and Halfling", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRELANG:3,Elven");
assertFalse("PRE test should look at keys", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreReqHandlerTest method testToHtml.
/**
* Print out as HTML
* @throws Exception
*/
public void testToHtml() throws Exception {
final PreParserFactory factory = PreParserFactory.getInstance();
final List<Prerequisite> list = new ArrayList<>();
list.add(factory.parse("PRESKILL:1,Spellcraft=15"));
list.add(factory.parse("PRESPELLTYPE:1,Arcane=8"));
list.add(factory.parse("PREFEAT:2,TYPE=Metamagic"));
list.add(factory.parse("PREFEAT:2,TYPE=ItemCreation"));
list.add(factory.parse("PRESKILLTOT:TYPE.Knowledge=20"));
LocaleDependentTestCase.before(Locale.US);
final String htmlString = PrereqHandler.toHtmlString(list);
System.out.println(htmlString);
assertEquals("at least 15 ranks in Spellcraft and at least 1 Arcane spell of level 8 and at least 2 FEAT(s) of type Metamagic and at least 2 FEAT(s) of type ItemCreation and at least 20 of ( at least 1 ranks in TYPE.Knowledge )", htmlString);
EnUsLocaleDependentTestCase.after();
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreSkillTest method testServesAsTotalsMatch.
public void testServesAsTotalsMatch() throws Exception {
final PlayerCharacter character = getCharacter();
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite prereq = factory.parse("PRESKILLTOT:Tumble,Target=18");
assertEquals(false, PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRESKILLTOT:Tumble,Target2=14");
assertEquals(true, PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRESKILLTOT:Foo,Target=40");
assertEquals(false, PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreBaseSizeTest method testBaseSizePlusMod.
/**
* Tests to make sure the base size does not includ SIZEMOD adjustments
* @throws Exception
*/
public void testBaseSizePlusMod() throws Exception {
final PlayerCharacter character = getCharacter();
LoadContext context = Globals.getContext();
character.setRace(race);
final BonusObj sizeBonus = Bonus.newBonus(context, "SIZEMOD|NUMBER|1");
race.addToListFor(ListKey.BONUS, sizeBonus);
character.calcActiveBonuses();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREBASESIZEEQ:Medium");
assertTrue("Character's base size should be equal to Medium", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBASESIZELTEQ:Medium");
assertTrue("Character's base size should be <= to Medium", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBASESIZEGTEQ:Medium");
assertTrue("Character's base size should be >= to Medium", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBASESIZEGT:Small");
assertTrue("Character's base size should be > to Small", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBASESIZELT:Large");
assertTrue("Character's base size should be < to Large", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBASESIZELT:Medium");
assertFalse("Character's base size should not be < to Medium", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBASESIZEGT:Medium");
assertFalse("Character's base size should not be > to Medium", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreCSkillTest method testCSkill.
/**
* Test that CSkill works
* @throws Exception
*/
public void testCSkill() throws Exception {
final PlayerCharacter character = getCharacter();
character.incrementClassLevel(1, myClass, true);
myClass = character.getClassKeyed("My Class");
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PRECSKILL:1,Spot,Listen");
assertFalse("Character has no class skills", PrereqHandler.passes(prereq, character, null));
character.addLocalCost(myClass, spot, SkillCost.CLASS, myClass);
//Need to throw out the cache
character.setDirty(true);
assertTrue("Character has spot class skills", PrereqHandler.passes(prereq, character, null));
character.addLocalCost(myClass, spy1, SkillCost.CLASS, myClass);
//Need to throw out the cache
character.setDirty(true);
assertTrue("Character has spot class skills", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECSKILL:2,TYPE.Spy");
assertFalse("Character has only one Spy Skill", PrereqHandler.passes(prereq, character, null));
character.addLocalCost(myClass, spy2, SkillCost.CLASS, myClass);
//Need to throw out the cache
character.setDirty(true);
assertTrue("Character has 2 Spy class skills", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECSKILL:3,Spot,TYPE.Spy");
assertTrue("Character has 2 Spy and Spot class skills", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECSKILL:3,Listen,TYPE.Spy");
assertFalse("Character has only 2 Spy Skills", PrereqHandler.passes(prereq, character, null));
character.addLocalCost(myClass, spy3, SkillCost.CLASS, myClass);
//Need to throw out the cache
character.setDirty(true);
prereq = factory.parse("PRECSKILL:3,Listen,TYPE.Spy");
assertTrue("Character has 3 Spy Skills", PrereqHandler.passes(prereq, character, null));
}
Aggregations