use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class PCClassTest method testGetPCCText.
/**
* Test the processing of getPCCText to ensure that it correctly produces
* an LST representation of an object and that the LST can then be reloaded
* to recrete the object.
*
* @throws PersistenceLayerException
*/
public void testGetPCCText() throws PersistenceLayerException {
FactKey.getConstant("Abb", new StringManager());
// Test a basic class
String classPCCText = humanoidClass.getPCCText();
assertNotNull("PCC Text for race should not be null", classPCCText);
CampaignSourceEntry source;
try {
source = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
} catch (URISyntaxException e) {
throw new UnreachableError(e);
}
PCClass reconstClass = null;
System.out.println("Got text:" + classPCCText);
reconstClass = parsePCClassText(classPCCText, source);
assertEquals("getPCCText should be the same after being encoded and reloaded", classPCCText, reconstClass.getPCCText());
assertEquals("Class abbrev was not restored after saving and reloading.", humanoidClass.getAbbrev(), reconstClass.getAbbrev());
// Test a class with some innate spells
String b = "1" + "\t" + "SPELLS:" + "Humanoid|TIMES=1|CASTERLEVEL=var(\"TCL\")|Create undead,11+WIS";
PCClassLoader classLoader = new PCClassLoader();
classLoader.parseLine(Globals.getContext(), humanoidClass, b, source);
classPCCText = humanoidClass.getPCCText();
assertNotNull("PCC Text for race should not be null", classPCCText);
reconstClass = null;
System.out.println("Got text:" + classPCCText);
reconstClass = parsePCClassText(classPCCText, source);
assertEquals("getPCCText should be the same after being encoded and reloaded", classPCCText, reconstClass.getPCCText());
assertEquals("Class abbrev was not restored after saving and reloading.", humanoidClass.getAbbrev(), reconstClass.getAbbrev());
Collection<CDOMReference<Spell>> startSpells = humanoidClass.getOriginalClassLevel(1).getListMods(Spell.SPELLS);
Collection<CDOMReference<Spell>> reconstSpells = reconstClass.getOriginalClassLevel(1).getListMods(Spell.SPELLS);
assertEquals("All spell should have been reconstituted.", startSpells.size(), reconstSpells.size());
assertEquals("Spell names should been preserved.", startSpells, reconstSpells);
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class ChallengeRatingPathfinderTest method additionalSetUp.
@Override
protected void additionalSetUp() throws Exception {
SettingsHandler.getGame().setCRSteps("1/2|1/3|1/4|1/6|1/8");
SettingsHandler.getGame().setCRThreshold("BASECR");
SettingsHandler.getGame().setMonsterRoleList(new ArrayList<>(Arrays.asList("Combat", "Skill", "Druid")));
SettingsHandler.getGame().addClassType("PC CRFORMULA:CL ISMONSTER:NO CRMOD:-1 CRMODPRIORITY:1");
SettingsHandler.getGame().addClassType("NPC CRFORMULA:CL ISMONSTER:NO CRMOD:-2 CRMODPRIORITY:2");
SettingsHandler.getGame().addClassType("Monster CRFORMULA:0 ISMONSTER:YES");
SettingsHandler.getGame().addClassType("Companion CRFORMULA:NONE ISMONSTER:YES");
LoadContext context = Globals.getContext();
BuildUtilities.createFact(context, "ClassType", PCClass.class);
SourceFileLoader.processFactDefinitions(context);
CampaignSourceEntry source = TestHelper.createSource(getClass());
GenericLoader<Race> raceLoader = new GenericLoader<>(Race.class);
PCClassLoader classLoader = new PCClassLoader();
final String standardRaceLine = "Standard Race";
raceLoader.parseLine(context, null, standardRaceLine, source);
standardRace = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "Standard Race");
final String koboldRaceLine = "Kobold CRMOD:NPC|-3";
raceLoader.parseLine(context, null, koboldRaceLine, source);
koboldRace = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "Kobold");
final String drowNobleLine = "Drow Noble CRMOD:PC.NPC|0";
raceLoader.parseLine(context, null, drowNobleLine, source);
drowNobleRace = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "Drow Noble");
final String babauLine = "Babau MONSTERCLASS:TestMonsterClass:7 CR:6 ROLE:Combat.Skill";
raceLoader.parseLine(context, null, babauLine, source);
babauRace = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "Babau");
final String dryadLine = "Dryad MONSTERCLASS:TestMonsterClass:8 CR:7 ROLE:Druid";
raceLoader.parseLine(context, null, dryadLine, source);
dryadRace = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "Dryad");
final String companionLine = "TestCompanion MONSTERCLASS:TestCompanionClass:4";
raceLoader.parseLine(context, null, companionLine, source);
companionRace = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "TestCompanion");
final String zombieLine = "Zombie MONSTERCLASS:TestMonsterClass:1 CR:1/2 ROLE:Combat";
raceLoader.parseLine(context, null, zombieLine, source);
zombieRace = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "Zombie");
final String direRatLine = "Dire Rat MONSTERCLASS:TestMonsterClass:1 CR:1/3 ROLE:Combat";
raceLoader.parseLine(context, null, direRatLine, source);
direRatRace = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "Dire rat");
final String miteLine = "Mite MONSTERCLASS:TestMonsterClass:1 CR:1/4 ROLE:Combat";
raceLoader.parseLine(context, null, miteLine, source);
miteRace = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "Mite");
final String beetleLine = "Beetle MONSTERCLASS:TestMonsterClass:1 CR:1/6 ROLE:Combat";
raceLoader.parseLine(context, null, beetleLine, source);
beetleRace = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "Beetle");
final String centipedeLine = "Centipede MONSTERCLASS:TestMonsterClass:1 CR:1/8 Centipede";
raceLoader.parseLine(context, null, centipedeLine, source);
centipedeRace = context.getReferenceContext().silentlyGetConstructedCDOMObject(Race.class, "Centipede");
final String pcClassLine = "CLASS:TestPCClass TYPE:PC ROLE:Combat";
pcClass = classLoader.parseLine(context, null, pcClassLine, source);
context.getReferenceContext().importObject(pcClass);
final String pcClassLine2 = "CLASS:TestPCClass2 TYPE:PC ROLE:Druid";
pcClass2 = classLoader.parseLine(context, null, pcClassLine2, source);
context.getReferenceContext().importObject(pcClass2);
final String npcClassLine = "CLASS:TestNPCClass2 TYPE:NPC";
npcClass = classLoader.parseLine(context, null, npcClassLine, source);
context.getReferenceContext().importObject(npcClass);
final String npcClassLine2 = "CLASS:TestNPCClass2 TYPE:NPC";
npcClass2 = classLoader.parseLine(context, null, npcClassLine2, source);
context.getReferenceContext().importObject(npcClass2);
final String monsterClassLine = "CLASS:TestMonsterClass HD:8 CLASSTYPE:Monster";
monsterClass = classLoader.parseLine(context, null, monsterClassLine, source);
context.getReferenceContext().importObject(monsterClass);
final String companionClassLine = "CLASS:TestCompanionClass HD:8 CLASSTYPE:Companion";
companionClass = classLoader.parseLine(context, null, companionClassLine, source);
context.getReferenceContext().importObject(companionClass);
context.commit();
BuildUtilities.createFact(context, "ClassType", PCClass.class);
FactDefinition<?, String> fd = BuildUtilities.createFact(context, "SpellType", PCClass.class);
fd.setSelectable(true);
SourceFileLoader.processFactDefinitions(context);
context.getReferenceContext().buildDerivedObjects();
context.resolveDeferredTokens();
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class RequiredTokenTest method classSetUp.
@BeforeClass
public static void classSetUp() throws URISyntaxException {
testCampaign = new CampaignSourceEntry(new Campaign(), new URI("file:/Test%20Case"));
classSetUpFired = true;
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class ValueTokenTest method classSetUp.
@BeforeClass
public static void classSetUp() throws URISyntaxException {
testCampaign = new CampaignSourceEntry(new Campaign(), new URI("file:/Test%20Case"));
classSetUpFired = true;
}
use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.
the class VisibleTokenTest method classSetUp.
@BeforeClass
public static void classSetUp() throws URISyntaxException {
testCampaign = new CampaignSourceEntry(new Campaign(), new URI("file:/Test%20Case"));
classSetUpFired = true;
}
Aggregations