use of pcgen.core.Campaign in project pcgen by PCGen.
the class ExpandedCampaignFacetTest method getObject.
@Override
protected Campaign getObject() {
Campaign wp = new Campaign();
wp.setName("WP" + n++);
return wp;
}
use of pcgen.core.Campaign in project pcgen by PCGen.
the class ClassLevelCommandTest method setUp.
/**
* @throws Exception
* @see pcgen.AbstractCharacterTestCase#setUp()
*/
@Override
protected void setUp() throws Exception {
super.setUp();
Campaign customCampaign = new Campaign();
customCampaign.setName("Unit Test");
customCampaign.setName("KEY_Unit Test");
customCampaign.addToListFor(ListKey.DESCRIPTION, new Description("Unit Test data"));
// Create the monseter class type
GameMode gamemode = SettingsHandler.getGame();
gamemode.addClassType("Monster CRFORMULA:0 ISMONSTER:YES XPPENALTY:NO");
gamemode.setSkillMultiplierLevels("4");
gamemode.setMaxNonEpicLevel(20);
CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
// Create the Nymph race
nymphRace = new Race();
nymphRace.setName("Nymph");
nymphRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
nymphRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
Globals.getContext().getReferenceContext().importObject(nymphRace);
// Create the humanoid class
humanoidClass = new PCClass();
humanoidClass.setName("Humanoid");
humanoidClass.addToListFor(ListKey.TYPE, Type.getConstant("Monster"));
Globals.getContext().getReferenceContext().importObject(humanoidClass);
nymphClass = new PCClass();
nymphClass.setName("Nymph");
nymphClass.addToListFor(ListKey.TYPE, Type.getConstant("Monster"));
Globals.getContext().getReferenceContext().importObject(nymphClass);
megaCasterClass = new PCClass();
megaCasterClass.setName("MegaCaster");
BuildUtilities.setFact(megaCasterClass, "SpellType", "Arcane");
Globals.getContext().unconditionallyProcess(megaCasterClass, "SPELLSTAT", "CHA");
megaCasterClass.put(ObjectKey.SPELLBOOK, false);
megaCasterClass.put(ObjectKey.MEMORIZE_SPELLS, false);
Globals.getContext().getReferenceContext().importObject(megaCasterClass);
}
use of pcgen.core.Campaign in project pcgen by PCGen.
the class VariableReport method runReport.
/**
* Produce the variable report in the requested formats.
*
* @param reportNameMap A map of formats to be output and the names of
* the files to contain the report for the format.
* @throws IOException If the template cannot be accessed or the file cannot be written to.
* @throws TemplateException If there is an error in processing the template.
*/
public void runReport(Map<ReportFormat, String> reportNameMap) throws IOException, TemplateException {
List<GameMode> games = SystemCollections.getUnmodifiableGameModeList();
Map<String, List<VarDefine>> gameModeVarMap = new TreeMap<>();
Map<String, Integer> gameModeVarCountMap = new TreeMap<>();
for (GameMode gameMode : games) {
List<VarDefine> varList = new ArrayList<>();
Map<String, Integer> varCountMap = new HashMap<>();
Set<File> processedLstFiles = new HashSet<>();
List<Campaign> campaignsForGameMode = getCampaignsForGameMode(gameMode);
for (Campaign campaign : campaignsForGameMode) {
processCampaign(campaign, varList, varCountMap, processedLstFiles);
}
Collections.sort(varList);
gameModeVarMap.put(gameMode.getName(), varList);
gameModeVarCountMap.put(gameMode.getName(), varCountMap.size());
}
for (Entry<ReportFormat, String> reportRequest : reportNameMap.entrySet()) {
Writer file = new FileWriter(new File(reportRequest.getValue()));
try {
outputReport(gameModeVarMap, gameModeVarCountMap, reportRequest.getKey(), file);
} finally {
IOUtils.closeQuietly(file);
}
}
}
use of pcgen.core.Campaign in project pcgen by PCGen.
the class SpellLevelTest method testGetPCBasedBonusKnownSpells.
/**
* Test method for {@link pcgen.core.analysis.SpellLevel#getPCBasedBonusKnownSpells(pcgen.core.PlayerCharacter, pcgen.core.PCClass)}.
* @throws Exception
*/
public void testGetPCBasedBonusKnownSpells() throws Exception {
LoadContext context = Globals.getContext();
CampaignSourceEntry source;
try {
source = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
} catch (URISyntaxException e) {
throw new UnreachableError(e);
}
final String classLine = "CLASS:Sorcerer TYPE:Base.PC SPELLSTAT:CHA SPELLTYPE:Arcane MEMORIZE:NO BONUS:CASTERLEVEL|Sorcerer|CL";
PCClassLoader classLoader = new PCClassLoader();
PCClass pcc = classLoader.parseLine(context, null, classLine, source);
Spell spell = TestHelper.makeSpell("Bless");
String abilityLine = "Spell bonanza CATEGORY:FEAT SPELLKNOWN:CLASS|Sorcerer=3|KEY_Bless";
AbilityLoader abilityLoader = new AbilityLoader();
abilityLoader.parseLine(context, null, abilityLine, source);
Ability ab1 = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Ability.class, AbilityCategory.FEAT, "Spell bonanza");
// Do the post parsing cleanup
context.resolveDeferredTokens();
context.getReferenceContext().buildDeferredObjects();
context.getReferenceContext().buildDerivedObjects();
context.getReferenceContext().validate(null);
assertTrue(context.getReferenceContext().resolveReferences(null));
PlayerCharacter aPC = getCharacter();
Collection<Integer> levels = listManagerFacet.getScopes2(aPC.getCharID(), pcc.get(ObjectKey.CLASS_SPELLLIST));
assertEquals("Initial number of spell levels incorrect", 0, levels.size());
addAbility(AbilityCategory.FEAT, ab1);
// Now for the tests
levels = listManagerFacet.getScopes2(aPC.getCharID(), pcc.get(ObjectKey.CLASS_SPELLLIST));
assertEquals("Incorrect number of spell levels returned", 1, levels.size());
assertEquals("Incorrect spell level returned", Integer.valueOf(3), levels.iterator().next());
Collection<Spell> result = listManagerFacet.getSet(aPC.getCharID(), pcc.get(ObjectKey.CLASS_SPELLLIST), 3);
assertEquals("Incorrect number of spells returned", 1, result.size());
assertEquals("Incorrect spell returned", spell, result.iterator().next());
}
use of pcgen.core.Campaign in project pcgen by PCGen.
the class PreArmorProfTest method testWithFeatThatGrantsBonus.
/**
* Test Preweaponprof with a feat that has a bonus tag
* This test was written to help find the source of bug 1699779.
*
* @throws Exception the exception
*/
public void testWithFeatThatGrantsBonus() throws Exception {
final PlayerCharacter character = getCharacter();
final FeatLoader featLoader = new FeatLoader();
CampaignSourceEntry cse;
try {
cse = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
} catch (URISyntaxException e) {
throw new UnreachableError(e);
}
int baseHp = character.hitPoints();
Ability bar = new Ability();
final String barStr = "Bar TYPE:General DESC:See Text BONUS:HP|CURRENTMAX|50";
featLoader.parseLine(Globals.getContext(), bar, barStr, cse);
addAbility(AbilityCategory.FEAT, bar);
assertEquals("Character should have 50 bonus hp added.", baseHp + 50, character.hitPoints());
final Ability martialProf = TestHelper.makeAbility("Shield Proficiency (Single)", "FEAT", "General");
Globals.getContext().unconditionallyProcess(martialProf, "AUTO", "ARMORPROF|Full Plate");
assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
AbstractCharacterTestCase.applyAbility(character, AbilityCategory.FEAT, martialProf, null);
Ability foo = new Ability();
final String fooStr = "Foo TYPE:General DESC:See Text BONUS:HP|CURRENTMAX|50|PREPROFWITHARMOR:1,Full Plate";
featLoader.parseLine(Globals.getContext(), foo, fooStr, cse);
addAbility(AbilityCategory.FEAT, foo);
assertEquals("Character has the Full Plate proficiency so the bonus should be added", baseHp + 50 + 50, character.hitPoints());
}
Aggregations