use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreBaseSizeTest method testBaseSize.
/**
* Test the PREBASESIZE code
* @throws Exception
*/
public void testBaseSize() throws Exception {
final PlayerCharacter character = getCharacter();
character.setRace(race);
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREBASESIZEEQ:Medium");
assertTrue("Character's base size should be equal to Medium", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBASESIZELTEQ:Medium");
assertTrue("Character's base size should be <= to Medium", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBASESIZEGTEQ:Medium");
assertTrue("Character's base size should be >= to Medium", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBASESIZEGT:Small");
assertTrue("Character's base size should be > to Small", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBASESIZELT:Large");
assertTrue("Character's base size should be < to Large", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBASESIZELT:Medium");
assertFalse("Character's base size should not be < to Medium", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBASESIZEGT:Medium");
assertFalse("Character's base size should not be > to Medium", PrereqHandler.passes(prereq, character, null));
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreClassTest method testSpellcasterTypeLevelsTwoClasses.
public void testSpellcasterTypeLevelsTwoClasses() 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", "Arcane");
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.ARCANE=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 PreClassTest method testFromParserAny.
/**
* Test to ensure that a character will fail a test
* if it does not have the correct number of levels
* in the class.
* @throws Exception
*/
public void testFromParserAny() throws Exception {
LoadContext context = Globals.getContext();
final PCClass pcClass = new PCClass();
pcClass.setName("MyClass");
context.unconditionallyProcess(pcClass, "SPELLSTAT", "CHA");
BuildUtilities.setFact(pcClass, "SpellType", "Arcane");
context.unconditionallyProcess(pcClass.getOriginalClassLevel(1), "CAST", "5,4");
final PCClass pcClass2 = new PCClass();
pcClass2.setName("Other Class");
context.unconditionallyProcess(pcClass2, "SPELLSTAT", "INT");
BuildUtilities.setFact(pcClass2, "SpellType", "Arcane");
context.unconditionallyProcess(pcClass2.getOriginalClassLevel(1), "CAST", "5,4");
final PlayerCharacter character = getCharacter();
character.incrementClassLevel(1, pcClass);
character.incrementClassLevel(2, pcClass2);
final PreParserFactory factory = PreParserFactory.getInstance();
final Prerequisite prereq = factory.parse("PRECLASS:1,ANY=3");
final PreClassTester test = new PreClassTester();
int passes = test.passes(prereq, character, null);
// Doens't pass - levels not summed...
assertEquals(0, passes);
character.incrementClassLevel(1, pcClass2);
passes = test.passes(prereq, character, null);
assertEquals(1, passes);
}
use of pcgen.persistence.lst.prereq.PreParserFactory in project pcgen by PCGen.
the class PreBirthplaceTest method testAtt.
/**
* Test the PREBIRTHPLACE code
* @throws Exception
*/
public void testAtt() throws Exception {
final PlayerCharacter character = getCharacter();
character.setPCAttribute(PCAttribute.BIRTHPLACE, "Klamath");
Prerequisite prereq;
final PreParserFactory factory = PreParserFactory.getInstance();
prereq = factory.parse("PREBIRTHPLACE:Klamath");
assertTrue("Character is from Klamath", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBIRTHPLACE:KLAMATH");
assertTrue("Case is not significant", PrereqHandler.passes(prereq, character, null));
prereq = factory.parse("PREBIRTHPLACE: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 PreCampaignTest method testNestedKeyMatch.
/**
* Test matching by key.
*
* @throws Exception the exception
*/
@Test
public void testNestedKeyMatch() throws Exception {
// Setup campaigns
PersistenceManager pmgr = PersistenceManager.getInstance();
List<URI> uris = new ArrayList<>();
uris.add(camp1.getSourceURI());
pmgr.setChosenCampaignSourcefiles(uris);
final PreParserFactory factory = PreParserFactory.getInstance();
Prerequisite preCampaign = factory.parse("PRECAMPAIGN:1,INCLUDES=Camp3");
assertFalse("Nonpresent campaign should not be found", PrereqHandler.passes(preCampaign, null, sourceCamp));
uris.add(camp2KeyParent.getSourceURI());
pmgr.setChosenCampaignSourcefiles(uris);
assertTrue("Present but nested campaign should be found", PrereqHandler.passes(preCampaign, null, sourceCamp));
}
Aggregations