use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreDeityTest method testFormat.
/**
* Test different formats for the option
* @throws Exception
*/
public void testFormat() throws Exception {
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));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreDomainTest method testMultiple.
/**
* Test with multiple options
* @throws Exception
*/
public void testMultiple() throws Exception {
final PlayerCharacter character = getCharacter();
PCClass cl = new PCClass();
character.setDefaultDomainSource(new ClassSource(cl, 1));
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREDOMAIN:1,Good,Law");
assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
character.setAlignment(ng);
character.setDeity(deity);
assertFalse("Character's deity has Good domain", PrereqHandler.passes(prereq, character, null));
character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Good"));
assertTrue("Character has Good domain", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDOMAIN:2,Good,Law");
assertFalse("Character doesn't have Law domain", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDOMAIN:2,Good,Animal");
character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Animal"));
assertTrue("Character's deity has Good and animal domains", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreCheckTest 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("PRECHECK:1,Fortitude=1");
assertTrue("Character's Fort save should be 1", 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=3");
assertTrue("Character's Will save should be 2", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECHECK:2,Fortitude=2,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 PreDeityDomainTest method testSingle.
/**
* Test for a single domain
* @throws Exception
*/
public void testSingle() throws Exception {
final PlayerCharacter character = getCharacter();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREDEITYDOMAIN:1,Good");
assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
character.setAlignment(ng);
character.setDeity(deity);
assertTrue("Character's deity has Good domain", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDEITYDOMAIN:1,Law");
assertFalse("Character's deity doesn't have Law domain", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreDomainTest method testDeity.
/**
* Test to make sure it is not looking at deity domains
* @throws Exception
*/
public void testDeity() throws Exception {
final PlayerCharacter character = getCharacter();
PCClass cl = new PCClass();
character.setDefaultDomainSource(new ClassSource(cl, 1));
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREDOMAIN:1,Good");
assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
character.setAlignment(ng);
character.setDeity(deity);
assertFalse("Character's deity has Good domain", PrereqHandler.passes(prereq, character, null));
character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Good"));
assertTrue("Character has Good domain", PrereqHandler.passes(prereq, character, null));
}
Aggregations