use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreDeityTest method testPantheon.
/**
* Test the pantheon fucntioanlity of the PREDEITY tag.
* @throws PersistenceLayerException
*/
public void testPantheon() throws PersistenceLayerException {
final PlayerCharacter character = getCharacter();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREDEITY:1,PANTHEON.Celtic");
assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
character.setAlignment(ng);
character.setDeity(deity);
assertTrue("Character has Celtic deity selected", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDEITY:1,Zeus,PANTHEON.Celtic,Odin");
assertTrue("Character has Celtic deity selected", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreDeityTest method testBoolean.
/**
* Test that the boolean version (Y/N) works
* @throws Exception
*/
public void testBoolean() throws Exception {
final PlayerCharacter character = getCharacter();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREDEITY:1,Y");
assertFalse("Character has no deity selected", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDEITY:1,N");
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,Y");
assertTrue("Character has deity selected", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreDomainTest method testAny.
/**
* Test for any domain.
*
* @throws Exception
*/
public void testAny() 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,ANY");
assertFalse("Character has no domains", PrereqHandler.passes(prereq, character, null));
character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Good"));
assertTrue("Character has one domain", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDOMAIN:2,ANY");
assertFalse("Character has only one domain", PrereqHandler.passes(prereq, character, null));
character.addDomain(Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Domain.class, "Animal"));
assertTrue("Character has two domains", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreDRTest method testMultiAnd.
public void testMultiAnd() throws Exception {
final PlayerCharacter character = getCharacter();
character.setRace(race);
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREDR:2,+1=10,+2=5");
assertFalse("Character has no DR", PrereqHandler.passes(prereq, character, null));
race.addToListFor(ListKey.DAMAGE_REDUCTION, drPlus1);
character.setRace(race);
assertFalse("Character DR not 10", PrereqHandler.passes(prereq, character, null));
DamageReduction drPlus2_5 = new DamageReduction(FormulaFactory.getFormulaFor(5), "+2");
race.addToListFor(ListKey.DAMAGE_REDUCTION, drPlus2_5);
//This weirdness is because we are altering the race after application (no-no at runtime)
character.setRace(null);
character.setRace(race);
assertFalse("Character has DR 5/+2", PrereqHandler.passes(prereq, character, null));
DamageReduction drPlus1_10 = new DamageReduction(FormulaFactory.getFormulaFor(10), "+1");
race.addToListFor(ListKey.DAMAGE_REDUCTION, drPlus1_10);
//This weirdness is because we are altering the race after application (no-no at runtime)
character.setRace(null);
character.setRace(race);
assertTrue("Character has DR 10/+1 and 5/+2", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreDRTest method testDR.
/**
* Test basic functionality
* @throws Exception
*/
public void testDR() throws Exception {
final PlayerCharacter character = getCharacter();
character.setRace(race);
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREDR:1,+1=10");
assertFalse("Character has no DR", PrereqHandler.passes(prereq, character, null));
race.addToListFor(ListKey.DAMAGE_REDUCTION, drPlus1);
//This weirdness is because we are altering the race after application (no-no at runtime)
character.setRace(null);
character.setRace(race);
assertFalse("Character DR not 10", PrereqHandler.passes(prereq, character, null));
DamageReduction drPlus1_10 = new DamageReduction(FormulaFactory.getFormulaFor(10), "+1");
race.addToListFor(ListKey.DAMAGE_REDUCTION, drPlus1_10);
//This weirdness is because we are altering the race after application (no-no at runtime)
character.setRace(null);
character.setRace(race);
assertTrue("Character has DR 10/+1", PrereqHandler.passes(prereq, character, null));
}
Aggregations