use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PrePCLevelTest method testLevel.
/**
* Test that Level works
* @throws Exception
*/
public void testLevel() 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("PREPCLEVEL:MIN=2");
assertFalse("Character is not 2nd level", PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, myClass, true);
assertTrue("Character has 2 levels", PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, myClass, true);
prereq = factory.parse("PREPCLEVEL:MIN=2,MAX=3");
assertTrue("Character is 2nd or 3rd level", PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, myClass, true);
assertFalse("Character is not 2nd or 3rd level", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MIN=2,MAX=3");
assertTrue("Character is 2nd or 3rd level", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MIN=4");
assertFalse("Character is 4 or higher level", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MAX=3");
assertTrue("Character is 3rd or higher level", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PrePCLevelTest method testHD.
/**
* Test that HD are counted
* @throws Exception
*/
public void testHD() throws Exception {
final PlayerCharacter character = getCharacter();
character.incrementClassLevel(2, myClass, true);
myClass = character.getClassKeyed("MY_CLASS");
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREPCLEVEL:MIN=4");
assertFalse("Character doesn't have 4 levels", PrereqHandler.passes(prereq, character, null));
character.setRace(race);
assertFalse("Character has 4 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MIN=5");
assertTrue("Character doesn't have 5 or more levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MIN=3");
assertTrue("Character doesn't have 5 or more levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MAX=3");
assertFalse("Character doesn't have 3 or more levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PREPCLEVEL:MIN=6,MAX=7");
assertTrue("Character doesn't have between 6 and 7 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPCLEVEL:MIN=4,MAX=6");
assertFalse("Character doesn't have 4-6 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPCLEVEL:MIN=6,MAX=7");
assertFalse("Character doesn't have 6-7 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREPCLEVEL:MAX=7");
assertTrue("Character has no more than 5 levels", PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(4, myClass, true);
prereq = factory.parse("PREPCLEVEL:MAX=6");
assertTrue("Character has no more than 6 levels", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreLevelMaxTest method testHD.
/**
* Test that HD are counted
* @throws Exception
*/
public void testHD() throws Exception {
final PlayerCharacter character = getCharacter();
character.incrementClassLevel(2, myClass, true);
myClass = character.getClassKeyed("MY_CLASS");
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PRELEVELMAX:3");
assertTrue("Character doesn't have 4 levels", PrereqHandler.passes(prereq, character, null));
character.setRace(race);
assertTrue("Character has 4 levels", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreLevelMaxTest method testLevel.
/**
* Test that Level works
* @throws Exception
*/
public void testLevel() 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("PRELEVELMAX:1");
assertTrue("Character is not 2nd level", PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, myClass, true);
assertFalse("Character has 2 levels", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreLevelMaxTest 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("PRELEVELMAX:5");
final BonusObj levelBonus = Bonus.newBonus(context, "PCLEVEL|MY_CLASS|2");
myClass.addToListFor(ListKey.BONUS, levelBonus);
character.calcActiveBonuses();
assertTrue("Character has only 4 levels", PrereqHandler.passes(prereq, character, null));
}
Aggregations