Search in sources :

Example 1 with Campaign

use of pcgen.core.Campaign in project pcgen by PCGen.

the class Gui2CampaignInfoFactory method getHTMLInfo.

public String getHTMLInfo(SourceSelectionFacade selection) {
    if (selection.getCampaigns().getSize() == 1) {
        return getHTMLInfo(selection.getCampaigns().getElementAt(0));
    }
    final HtmlInfoBuilder infoText = new HtmlInfoBuilder(selection.toString());
    for (CampaignFacade campaign : selection.getCampaigns()) {
        if (campaign == null || !(campaign instanceof Campaign)) {
            continue;
        }
        Campaign aCamp = (Campaign) campaign;
        infoText.appendLineBreak();
        infoText.appendLineBreak();
        infoText.appendTitleElement(aCamp.getDisplayName());
        appendCampaignInfo(aCamp, infoText);
    }
    return infoText.toString();
}
Also used : Campaign(pcgen.core.Campaign) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder) CampaignFacade(pcgen.facade.core.CampaignFacade)

Example 2 with Campaign

use of pcgen.core.Campaign in project pcgen by PCGen.

the class Gui2CampaignInfoFactory method getHTMLInfo.

/**
	 * @see pcgen.core.facade.CampaignInfoFactory#getHTMLInfo(pcgen.core.facade.CampaignFacade)
	 */
@Override
public String getHTMLInfo(CampaignFacade campaign) {
    if (campaign == null || !(campaign instanceof Campaign)) {
        return "";
    }
    Campaign aCamp = (Campaign) campaign;
    final HtmlInfoBuilder infoText = new HtmlInfoBuilder(aCamp.getDisplayName());
    appendCampaignInfo(aCamp, infoText);
    return infoText.toString();
}
Also used : Campaign(pcgen.core.Campaign) HtmlInfoBuilder(pcgen.gui2.util.HtmlInfoBuilder)

Example 3 with Campaign

use of pcgen.core.Campaign in project pcgen by PCGen.

the class Gui2CampaignInfoFactory method getRequirementsHTMLString.

@Override
public String getRequirementsHTMLString(CampaignFacade campaign, List<CampaignFacade> testList) {
    if (campaign == null || !(campaign instanceof Campaign)) {
        return "";
    }
    Campaign aCamp = (Campaign) campaign;
    PersistenceManager pman = PersistenceManager.getInstance();
    List<URI> oldList = setSourcesForPrereqTesting(testList, pman);
    String preReqHtml = PrerequisiteUtilities.preReqHTMLStringsForList(null, null, aCamp.getPrerequisiteList(), false);
    pman.setChosenCampaignSourcefiles(oldList);
    return preReqHtml;
}
Also used : Campaign(pcgen.core.Campaign) PersistenceManager(pcgen.persistence.PersistenceManager) URI(java.net.URI)

Example 4 with Campaign

use of pcgen.core.Campaign in project pcgen by PCGen.

the class SourceFileLoader method readPccFiles.

/**
	 * This method reads the PCC (Campaign) files and, if options are allowed to
	 * be set in the sources, sets the SettingsHandler settings to reflect the
	 * changes from the campaign files.
	 *
	 * @param aSelectedCampaignsList
	 *            List of Campaigns to load
	 */
private Collection<Campaign> readPccFiles(Iterable<Campaign> aSelectedCampaignsList) {
    Collection<Campaign> loadedSet = new HashSet<>();
    // along with any options required by the campaigns...
    for (Campaign campaign : aSelectedCampaignsList) {
        if (Logging.isDebugMode()) {
            Logging.debugPrint("Loading campaign " + campaign);
        }
        loadedCampaigns.add(campaign);
        List<String> copyright = campaign.getListFor(ListKey.SECTION_15);
        if (copyright != null) {
            sec15.append("<br><b>Source Material:</b>");
            sec15.append(SourceFormat.getFormattedString(campaign, SourceFormat.LONG, true));
            sec15.append("<br>");
            sec15.append("<b>Section 15 Entry in Source Material:</b><br>");
            for (String license : copyright) {
                sec15.append(license).append("<br>");
            }
        }
        // Update whether licenses need shown
        showOGL |= campaign.getSafe(ObjectKey.IS_OGL);
        showD20 |= campaign.getSafe(ObjectKey.IS_D20);
        showLicensed |= campaign.getSafe(ObjectKey.IS_LICENSED);
        if (campaign.getSafe(ObjectKey.IS_LICENSED)) {
            List<String> licenseList = campaign.getSafeListFor(ListKey.LICENSE);
            if (licenseList != null && !licenseList.isEmpty()) {
                licensesToDisplayString.append(licenseList);
            }
            List<CampaignSourceEntry> licenseURIs = campaign.getSafeListFor(ListKey.LICENSE_FILE);
            if (licenseURIs != null) {
                licenseFiles.addAll(licenseURIs);
            }
        }
        // check if maturity warning needs to be shown
        showMature |= campaign.getSafe(ObjectKey.IS_MATURE);
        if (campaign.getSafe(ObjectKey.IS_MATURE)) {
            matureCampaigns.append(SourceFormat.LONG.getField(campaign) + " (" + campaign.getSafe(StringKey.PUB_NAME_LONG) + ")<br>");
        }
        // Load the LST files to be loaded for the campaign
        addQualifiedSources(campaign, ListKey.FILE_LST_EXCLUDE);
        for (ListKey<CampaignSourceEntry> lk : CampaignLoader.OBJECT_FILE_LISTKEY) {
            addQualifiedSources(campaign, lk);
        }
        loadedSet.add(campaign);
        if (PCGenSettings.OPTIONS_CONTEXT.initBoolean(PCGenSettings.OPTION_ALLOWED_IN_SOURCES, true)) {
            setCampaignOptions(campaign);
        }
        // Add all sub-files to the main campaign, regardless of exclusions
        for (CampaignSourceEntry fName : campaign.getSafeListFor(ListKey.FILE_PCC)) {
            URI uri = fName.getURI();
            if (PCGFile.isPCGenCampaignFile(uri)) {
                loadedSet.add(Globals.getCampaignByURI(uri, false));
            } else {
                Logging.errorPrint("The referenced source " + uri + " is not valid.");
            }
        }
    }
    // ...but make sure to remove those files specified by LSTEXCLUDE;
    // LSTEXCLUDE should be treated as a global exclusion.
    // sage_sam 29 Dec 2003, Bug #834834
    stripLstExcludes();
    return loadedSet;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) URI(java.net.URI) HashSet(java.util.HashSet)

Example 5 with Campaign

use of pcgen.core.Campaign in project pcgen by PCGen.

the class SourceFileLoader method loadCampaigns.

private void loadCampaigns(GameMode gamemode, final List<Campaign> aSelectedCampaignsList, LoadContext context) throws PersistenceLayerException {
    Logging.log(Logging.INFO, "Loading game " + gamemode + " and sources " + aSelectedCampaignsList + ".");
    //		// The first thing we need to do is load the
    //		// correct statsandchecks.lst file for this gameMode
    //		GameMode gamemode = SettingsHandler.getGame();
    //		if (gamemode == null)
    //		{
    //			// Autoload campaigns is set but there
    //			// is no current gameMode, so just return
    //			return;
    //		}
    File gameModeDir = new File(ConfigurationSettings.getSystemsDir(), "gameModes");
    File specificGameModeDir = new File(gameModeDir, gamemode.getFolderName());
    // Sort the campaigns
    sortCampaignsByRank(aSelectedCampaignsList);
    // Read the campaigns
    Collection<Campaign> loaded = readPccFiles(aSelectedCampaignsList);
    // Add custom campaign files at the start of the lists
    addCustomFilesToStartOfList();
    // Notify our observers of how many files we intend
    // to load in total so that they can set up any
    // progress meters that they want to.
    setMaximum(countTotalFilesToLoad());
    // Load using the new LstFileLoaders
    List<CampaignSourceEntry> dataDefFileList = fileLists.getListFor(ListKey.FILE_DATACTRL);
    dataDefFileList = addDefaultDataControlIfNeeded(dataDefFileList);
    dataControlLoader.loadLstFiles(context, dataDefFileList);
    processFactDefinitions(context);
    tableLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_DATATABLE));
    dynamicLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_DYNAMIC));
    //Load Variables (foundation for other items)
    variableLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_VARIABLE));
    defineBuiltinVariables(context);
    List<CampaignSourceEntry> globalModFileList = fileLists.getListFor(ListKey.FILE_GLOBALMOD);
    if (globalModFileList.isEmpty()) {
        File defaultGameModeDir = new File(gameModeDir, "default");
        File df = new File(defaultGameModeDir, "compatibilityGlobalModifier.lst");
        Campaign c = new Campaign();
        c.setName("Default Global Modifier File");
        CampaignSourceEntry cse = new CampaignSourceEntry(c, df.toURI());
        globalModFileList.add(cse);
    }
    globalModifierLoader.loadLstFiles(context, globalModFileList);
    // load ability categories first as they used to only be at the game mode
    abilityCategoryLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_ABILITY_CATEGORY));
    for (Campaign c : loaded) {
        c.applyTo(context.getReferenceContext());
    }
    sizeLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_SIZE));
    //Now load PCC stat, check, alignment
    statLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_STAT));
    savesLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_SAVE));
    alignmentLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_ALIGNMENT));
    // load weapon profs first
    wProfLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_WEAPON_PROF));
    WeaponProf wp = context.getReferenceContext().silentlyGetConstructedCDOMObject(WeaponProf.class, "Unarmed Strike");
    if (wp == null) {
        wp = new WeaponProf();
        wp.setName(LanguageBundle.getString("Equipment.UnarmedStrike"));
        wp.put(StringKey.KEY_NAME, "Unarmed Strike");
        wp.addToListFor(ListKey.TYPE, Type.SIMPLE);
        context.getReferenceContext().importObject(wp);
    }
    aProfLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_ARMOR_PROF));
    sProfLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_SHIELD_PROF));
    // load skills before classes to handle class skills
    skillLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_SKILL));
    // load before races to handle auto known languages
    languageLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_LANGUAGE));
    // load before race or class to handle feats
    featLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_FEAT));
    // load before race or class to handle abilities
    abilityLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_ABILITY));
    raceLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_RACE));
    //Domain must load before CLASS - thpr 10/29/06
    domainLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_DOMAIN));
    spellLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_SPELL));
    deityLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_DEITY));
    classLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_CLASS));
    templateLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_TEMPLATE));
    // loaded before equipment (required)
    eqModLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_EQUIP_MOD));
    equipmentLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_EQUIP));
    companionModLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_COMPANION_MOD));
    kitLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_KIT));
    // Load the bio settings files
    bioLoader.setGameMode(gamemode.getName());
    bioLoader.loadLstFiles(context, fileLists.getListFor(ListKey.FILE_BIO_SET));
    // Check for the default deities
    checkRequiredDeities(specificGameModeDir, context);
    // Add default EQ mods
    addDefaultEquipmentMods(context);
    classLoader.loadSubLines(context);
    /*
		 * This is technically bad behavior, but we at least want to provide the
		 * hint here since we are using WeakReferences as a container for
		 * references to ensure those that are not used are not resolved.
		 */
    System.gc();
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) WeaponProf(pcgen.core.WeaponProf) PCGFile(pcgen.io.PCGFile) File(java.io.File)

Aggregations

Campaign (pcgen.core.Campaign)84 URI (java.net.URI)49 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)44 URISyntaxException (java.net.URISyntaxException)17 BeforeClass (org.junit.BeforeClass)16 LoadContext (pcgen.rules.context.LoadContext)16 ArrayList (java.util.ArrayList)14 PlayerCharacter (pcgen.core.PlayerCharacter)11 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)11 File (java.io.File)10 PCClass (pcgen.core.PCClass)10 PCClassLoader (pcgen.persistence.lst.PCClassLoader)10 UnreachableError (pcgen.base.lang.UnreachableError)9 Ability (pcgen.core.Ability)9 GameMode (pcgen.core.GameMode)7 SourceEntry (pcgen.persistence.lst.SourceEntry)7 Test (org.junit.Test)6 HashSet (java.util.HashSet)5 CampaignFacade (pcgen.facade.core.CampaignFacade)5 PCGFile (pcgen.io.PCGFile)5