use of pcgen.core.Campaign in project pcgen by PCGen.
the class SourceFileLoader method addDefaultDataControlIfNeeded.
/**
* Add default data control files to the supplied list, but only if it is empty.
*
* @param dataDefFileList The list of data control files.
*/
public static List<CampaignSourceEntry> addDefaultDataControlIfNeeded(List<CampaignSourceEntry> dataDefFileList) {
if (dataDefFileList == null) {
dataDefFileList = new ArrayList<>();
}
if (dataDefFileList.isEmpty()) {
File gameModeDir = new File(ConfigurationSettings.getSystemsDir(), "gameModes");
File defaultGameModeDir = new File(gameModeDir, "default");
File df = new File(defaultGameModeDir, "compatibilityDataControl.lst");
Campaign c = new Campaign();
c.setName("Default Data Control File");
CampaignSourceEntry cse = new CampaignSourceEntry(c, df.toURI());
dataDefFileList.add(cse);
}
return dataDefFileList;
}
use of pcgen.core.Campaign in project pcgen by PCGen.
the class SourceFileLoader method loadCampaigns.
private void loadCampaigns() throws PersistenceLayerException {
// Unload the existing campaigns and load our selected campaign
Globals.emptyLists();
PersistenceManager pManager = PersistenceManager.getInstance();
List<URI> uris = new ArrayList<>();
for (CampaignFacade campaignFacade : selectedCampaigns) {
uris.add(((Campaign) campaignFacade).getSourceURI());
}
pManager.setChosenCampaignSourcefiles(uris);
sourcesSet.clear();
licenseFiles.clear();
if (selectedCampaigns.isEmpty()) {
throw new PersistenceLayerException("You must select at least one campaign to load.");
}
// -- sage_sam
try {
LoadContext context = Globals.getContext();
loadCampaigns(selectedGame, selectedCampaigns, context);
// Load custom items
loadCustomItems(context);
finishLoad(selectedCampaigns, context);
// Check for valid race types
// checkRaceTypes();
// Verify weapons are melee or ranged
verifyWeaponsMeleeOrRanged(context);
// Auto-gen additional equipment
if (PCGenSettings.OPTIONS_CONTEXT.initBoolean(PCGenSettings.OPTION_AUTOCREATE_MW_MAGIC_EQUIP, false)) {
EquipmentList.autoGenerateEquipment();
}
for (Campaign campaign : selectedCampaigns) {
sourcesSet.add(SourceFormat.getFormattedString(campaign, SourceFormat.MEDIUM, true));
}
context.setLoaded(selectedCampaigns);
/*
* This needs to happen after auto equipment generation and after
* context.setLoaded, not in finishLoad
*/
context.loadCampaignFacets();
dataset = new DataSet(context, selectedGame, new DefaultListFacade<>(selectedCampaigns));
// // Show the licenses
// showLicensesIfNeeded();
// showSponsorsIfNeeded();
} catch (Throwable thr) {
Logging.errorPrint("Exception loading files.", thr);
uiDelegate.showErrorMessage(Constants.APPLICATION_NAME, "Failed to load campaigns, see log for details.");
}
}
use of pcgen.core.Campaign in project pcgen by PCGen.
the class AbstractGlobalTokenTestCase method classSetUp.
@BeforeClass
public static void classSetUp() throws URISyntaxException {
Locale.setDefault(Locale.US);
testCampaign = new CampaignSourceEntry(new Campaign(), new URI("file:/Test%20Case"));
classSetUpFired = true;
}
use of pcgen.core.Campaign in project pcgen by PCGen.
the class AbstractTokenTestCase method classSetUp.
@BeforeClass
public static void classSetUp() throws URISyntaxException {
testCampaign = new CampaignSourceEntry(new Campaign(), new URI("file:/Test%20Case"));
classSetUpFired = true;
}
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);
}
Aggregations