use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreSizeTest method testEquipmentPreSize.
public void testEquipmentPreSize() throws Exception {
final PlayerCharacter character = getCharacter();
Globals.getContext().getReferenceContext().resolveReferences(null);
is(eq1.sizeInt(), eq(3), "Item one is expected size");
is(eq2.sizeInt(), eq(4), "Item two is expected size");
is(eq3.sizeInt(), eq(5), "Item three is expected size");
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PRESIZEEQ:L");
is(PrereqHandler.passes(prereq, eq1, character), eq(false), "Item one is not Large");
is(PrereqHandler.passes(prereq, eq2, character), eq(false), "Item two is not Large");
is(PrereqHandler.passes(prereq, eq3, character), eq(true), "Item three Large");
prereq = factory.parse("PRESIZEGT:S");
is(PrereqHandler.passes(prereq, eq1, character), eq(false), "Item one is not larger than Small");
is(PrereqHandler.passes(prereq, eq2, character), eq(true), "Item two is larger than Small");
is(PrereqHandler.passes(prereq, eq3, character), eq(true), "Item three larger than Small");
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreSkillTest method testServesAsTypeMatch.
public void testServesAsTypeMatch() throws Exception {
final PlayerCharacter character = getCharacter();
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite prereq = factory.parse("PRESKILL:1,TYPE.INT=4");
assertEquals(true, PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRESKILL:1,TYPE.STR=6");
assertEquals(true, PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRESKILL:1,TYPE.ST%=6");
assertEquals(true, PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRESKILL:1,TYPE.STR=7");
assertEquals(false, PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRESKILL:1,TYPE.ST%=7");
assertEquals(false, PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRESKILL:1,TYPE.CHA=1");
assertEquals(false, PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRESKILL:1,TYPE.CH%=7");
assertEquals(false, PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PrePCLevelTest method testPCLevel.
/**
* Make sure BONUS:PCLEVEL is not counted
* @throws Exception
*/
public void testPCLevel() throws Exception {
final PlayerCharacter character = getCharacter();
LoadContext context = Globals.getContext();
character.incrementClassLevel(2, myClass, true);
myClass = character.getClassKeyed("MY_CLASS");
character.setRace(race);
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREPCLEVEL:MIN=6");
final BonusObj levelBonus = Bonus.newBonus(context, "PCLEVEL|MY_CLASS|2");
myClass.addToListFor(ListKey.BONUS, levelBonus);
character.calcActiveBonuses();
assertFalse("Character has only 4 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPCLEVEL:MAX=6");
assertTrue("Character has more than 6 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MAX=6");
assertFalse("Character is less than 6 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MIN=5");
assertTrue("Character has only 4 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPCLEVEL:MIN=4,MAX=6");
assertFalse("Character does not have 4-6 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPCLEVEL:MIN=6,MAX=8");
assertFalse("Character does not have 6-8 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MIN=6,MAX=8");
assertTrue("Character is not 6-8 levels", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreShieldProfTest method testMultiple.
/**
* Tests to see if a character has a certain number of shieldprofs from a list.
*
* @throws Exception the exception
*/
public void testMultiple() throws Exception {
final PlayerCharacter character = getCharacter();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREPROFWITHSHIELD:1,Heavy Wooden Shield,Full Plate");
assertFalse("Character has no proficiencies", PrereqHandler.passes(prereq, character, null));
final Ability martialProf = TestHelper.makeAbility("Shield Proficiency (Single)", "FEAT", "General");
Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|Heavy Wooden Shield");
Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "SHIELDPROF|Full Plate");
assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
assertTrue("Character has one of Heavy Wooden Shield or Full Plate proficiency", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPROFWITHSHIELD:2,Heavy Wooden Shield,Full Plate");
assertTrue("Character has both Heavy Wooden Shield and Full Plate proficiency", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPROFWITHSHIELD:3,Heavy Wooden Shield,Full Plate,Light Wooden Shield");
assertFalse("Character has both Heavy Wooden Shield and Full Plate proficiency but not Light Wooden Shield", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreGenderTest method testGender.
/**
* Test the PREGENDER code
* @throws Exception
*/
public void testGender() throws Exception {
final PlayerCharacter character = getCharacter();
character.setGender(Gender.Male);
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREGENDER:M");
assertTrue("Character is Male", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREGENDER:m");
assertFalse("Case is significant", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREGENDER:Moose");
assertFalse("Requires a full match", PrereqHandler.passes(prereq, character, null));
}
Aggregations