use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreLevelTest 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("PRELEVEL: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("PRELEVEL:MAX=6");
assertTrue("Character has only 4 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PRELEVEL:MAX=6");
assertFalse("Character is less than 6 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PRELEVEL:MIN=5");
assertTrue("Character has only 4 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRELEVEL:MIN=4,MAX=6");
assertTrue("Character has 4-6 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRELEVEL:MIN=6,MAX=8");
assertFalse("Character does not have 6-8 levels", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PRELEVEL: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 PreLevelTest 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("PRELEVEL: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("PRELEVEL: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("!PRELEVEL:MIN=2,MAX=3");
assertTrue("Character is 2nd or 3rd level", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PRELEVEL:MIN=4");
assertFalse("Character is 4 or higher level", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("!PRELEVEL: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 PreFactSetTest method testFact.
/**
* Test the PREFACT code
* @throws Exception
*/
public void testFact() throws Exception {
final PlayerCharacter character = getCharacter();
Deity deity = new Deity();
BuildUtilities.addToFactSet(deity, "PANTHEON", "Greek");
BuildUtilities.addToFactSet(deity, "PANTHEON", "War");
deity.setName("Ares");
character.setDeity(deity);
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREFACTSET:1,DEITY,PANTHEON=Roman");
assertFalse("Character's deity should not match requirement", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREFACTSET:1,DEITY,PANTHEON=War");
assertTrue("Character's deity should match pantheon", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREFACTSET:1,DEITY,PANTHEON=Greek");
assertTrue("Character's deity should match pantheon", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreFactTest method testFact.
/**
* Test the PREFACT code
* @throws Exception
*/
public void testFact() throws Exception {
final PlayerCharacter character = getCharacter();
Race race = new Race();
BuildUtilities.setFact(race, "ABB", "Hgln");
race.setName("Hobgoblin");
character.setRace(race);
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREFACT:1,RACE,ABB=Hum");
assertFalse("Character should not be a matching race", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREFACT:1,RACE,ABB=Hgln");
assertTrue("Character should be a matching race", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreHPTest method testHP.
/**
* Test the PREHP code
* @throws Exception
*/
public void testHP() throws Exception {
final PlayerCharacter character = getCharacter();
LoadContext context = Globals.getContext();
character.incrementClassLevel(1, myClass, true);
myClass = character.getClassList().get(0);
PCClassLevel pcl = character.getActiveClassLevel(myClass, 1);
character.setHP(pcl, 4);
character.calcActiveBonuses();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREHP:4");
assertTrue("Character should have 4 hp", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREHP:5");
assertFalse("Character should have less than 5 hp", PrereqHandler.passes(prereq, character, null));
final BonusObj hpBonus = Bonus.newBonus(context, "HP|CURRENTMAX|1");
myClass.addToListFor(ListKey.BONUS, hpBonus);
character.calcActiveBonuses();
assertTrue("Character should have 5 hp", PrereqHandler.passes(prereq, character, null));
}
Aggregations