Search in sources :

Example 51 with Campaign

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;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) PCGFile(pcgen.io.PCGFile) File(java.io.File)

Example 52 with Campaign

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.");
    }
}
Also used : Campaign(pcgen.core.Campaign) DataSet(pcgen.core.DataSet) ArrayList(java.util.ArrayList) LoadContext(pcgen.rules.context.LoadContext) URI(java.net.URI) CampaignFacade(pcgen.facade.core.CampaignFacade) DefaultListFacade(pcgen.facade.util.DefaultListFacade)

Example 53 with Campaign

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;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) URI(java.net.URI) BeforeClass(org.junit.BeforeClass)

Example 54 with Campaign

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;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) URI(java.net.URI) BeforeClass(org.junit.BeforeClass)

Example 55 with Campaign

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);
}
Also used : GameMode(pcgen.core.GameMode) Campaign(pcgen.core.Campaign) Description(pcgen.core.Description) Race(pcgen.core.Race) PCClass(pcgen.core.PCClass) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

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