use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreCheckBaseTest method testBonus.
public void testBonus() throws Exception {
final PlayerCharacter character = getCharacter();
LoadContext context = Globals.getContext();
final BonusObj fortBonus = Bonus.newBonus(context, "SAVE|Fortitude|1");
myClass.getOriginalClassLevel(1).addToListFor(ListKey.BONUS, fortBonus);
character.incrementClassLevel(1, myClass, true);
character.calcActiveBonuses();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PRECHECKBASE:1,Fortitude=1");
assertFalse("Character's base Fort save should be 0", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECHECKBASE:1,Will=2");
assertTrue("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECHECKBASE:1,Fortitude=1,Will=3");
assertFalse("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECHECKBASE:2,Fortitude=1,Will=2");
assertFalse("Character's base Fort save not 1", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreCheckBaseTest method testBase.
/**
* Test that Base Checks work
* @throws Exception
*/
public void testBase() throws Exception {
final PlayerCharacter character = getCharacter();
character.incrementClassLevel(1, myClass, true);
character.calcActiveBonuses();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PRECHECKBASE:1,Fortitude=0");
assertTrue("Character's Fort save should be 0", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECHECKBASE:1,Will=2");
assertTrue("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECHECKBASE:1,Fortitude=1,Will=2");
assertTrue("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECHECKBASE:2,Fortitude=1,Will=2");
assertFalse("Character's Fort save not 1", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreCheckTest method testBase.
/**
* Test that Base Checks work
* @throws Exception
*/
public void testBase() throws Exception {
final PlayerCharacter character = getCharacter();
character.incrementClassLevel(1, myClass, true);
character.calcActiveBonuses();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PRECHECK:1,Fortitude=0");
assertTrue("Character's Fort save should be 0", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECHECK:1,Will=2");
assertTrue("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECHECK:1,Fortitude=1,Will=2");
assertTrue("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECHECK:2,Fortitude=1,Will=2");
assertFalse("Character's Fort save not 1", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreDeityTest method testName.
/**
* Test naming specific deities works as expected
* @throws Exception
*/
public void testName() throws Exception {
final PlayerCharacter character = getCharacter();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREDEITY:1,Test Deity");
assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
character.setAlignment(ng);
character.setDeity(deity);
assertTrue("Character has Test Deity selected", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDEITY:1,Test Deity,Zeus,Odin");
assertTrue("Character has Test Deity selected", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreDeityTest method testNewFormat.
/**
* Test that the new standardised format works correctly.
* @throws PersistenceLayerException
*/
public void testNewFormat() throws PersistenceLayerException {
final PlayerCharacter character = getCharacter();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREDEITY:1,YES");
assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDEITY:1,NO");
assertTrue("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
character.setAlignment(ng);
character.setDeity(deity);
assertFalse("Character has deity selected", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDEITY:1,YES");
assertTrue("Character has deity selected", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDEITY:1,yes");
assertTrue("Character has deity selected", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDEITY:1,Yesmeth");
assertFalse("Character does not have Yesmeth as deity", PrereqHandler.passes(prereq, character, null));
}
Aggregations