use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreDeityAlignTest method testAbbrev.
/**
* Test that alignment abbreviation values work correctly in Deity Align tests.
* @throws Exception
*/
public void testAbbrev() throws Exception {
final PlayerCharacter character = getCharacter();
character.setAlignment(ng);
character.setDeity(deity);
assertEquals("Deity should have been set for character.", deity, character.getDeity());
Prerequisite prereq = new Prerequisite();
prereq.setKind("deityAlign");
prereq.setOperand("NG");
prereq.setOperator(PrerequisiteOperator.EQ);
assertTrue("Abbrev NG should match deity's alignment of NG", PrereqHandler.passes(prereq, character, null));
prereq = new Prerequisite();
prereq.setKind("deityAlign");
prereq.setOperand("LG");
prereq.setOperator(PrerequisiteOperator.EQ);
assertFalse("Abbrev LG should not match deity's alignment of NG", PrereqHandler.passes(prereq, character, null));
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREDEITYALIGN:NG");
assertTrue("Abbrev NG should match deity's alignment of NG", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDEITYALIGN:LG");
assertFalse("Abbrev LG should not match deity's alignment of NG", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreDeityDomainTest method testMultiple.
public void testMultiple() throws Exception {
final PlayerCharacter character = getCharacter();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREDEITYDOMAIN:1,Good,Law");
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:2,Good,Law");
assertFalse("Character's deity doesn't have Law domain", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREDEITYDOMAIN:2,Good,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 PreCityTest method testCity.
/**
* Test the PRECITY code
* @throws Exception
*/
public void testCity() throws Exception {
final PlayerCharacter character = getCharacter();
character.setPCAttribute(PCAttribute.RESIDENCE, "Klamath");
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PRECITY:Klamath");
assertTrue("Character is from Klamath", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECITY:KLAMATH");
assertTrue("Case is not significant", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PRECITY:Klam");
assertFalse("Requires a full match", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreClassTest method testSpellcasterLevelsTwoClasses.
public void testSpellcasterLevelsTwoClasses() throws Exception {
final PCClass pcClass = new PCClass();
LoadContext context = Globals.getContext();
pcClass.setName("MyClass");
BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
BonusObj aBonus = Bonus.newBonus(context, "CASTERLEVEL|MyClass|CL");
if (aBonus != null) {
pcClass.addToListFor(ListKey.BONUS, aBonus);
}
final PCClass pcClass2 = new PCClass();
pcClass2.setName("MyClass2");
BuildUtilities.setFact(pcClass2, "SpellType", "Divine");
aBonus = Bonus.newBonus(context, "CASTERLEVEL|MyClass2|CL");
if (aBonus != null) {
pcClass.addToListFor(ListKey.BONUS, aBonus);
}
final PlayerCharacter character = getCharacter();
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite prereq = factory.parse("PRECLASS:2,SPELLCASTER=1");
character.incrementClassLevel(1, pcClass);
assertEquals(false, PrereqHandler.passes(prereq, character, null));
character.incrementClassLevel(1, pcClass2);
assertEquals(true, PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreAttTest method testAtt.
/**
* Test the PREATT code
* @throws Exception
*/
public void testAtt() throws Exception {
final PlayerCharacter character = getCharacter();
LoadContext context = Globals.getContext();
character.incrementClassLevel(1, myClass, true);
character.calcActiveBonuses();
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREATT:6");
assertTrue("Character's BAB should be 6", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREATT:7");
assertFalse("Character's BAB should be less than 7", PrereqHandler.passes(prereq, character, null));
final BonusObj toHitBonus = Bonus.newBonus(context, "COMBAT|TOHIT|1");
myClass.getOriginalClassLevel(1).addToListFor(ListKey.BONUS, toHitBonus);
character.calcActiveBonuses();
assertFalse("Character's BAB should be less than 7", PrereqHandler.passes(prereq, character, null));
}
Aggregations