Search in sources :

Example 16 with Campaign

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

the class WriteDirectoryPanel method showWarning.

private void showWarning() {
    List<Campaign> existingCampaigns = getExistingPccs();
    StringBuilder warning = new StringBuilder("<html>");
    if (!existingCampaigns.isEmpty()) {
        warning.append("<b>Warning</b>: Some converted campaigns already exist in this ");
        warning.append("destination folder and will be skipped:\n<UL>");
        final int maxCampaigns = 15;
        int i = 1;
        for (Campaign camp : existingCampaigns) {
            if ((i >= maxCampaigns) && (existingCampaigns.size() > maxCampaigns)) {
                warning.append("<li>" + (existingCampaigns.size() - maxCampaigns + 1) + " more campaigns.</li>");
                break;
            }
            warning.append("<li>");
            warning.append(camp.getName());
            warning.append("</li>");
            i++;
        }
        warning.append("</ul>");
    }
    warning.append("</html>");
    warningLabel.setText(warning.toString());
}
Also used : Campaign(pcgen.core.Campaign)

Example 17 with Campaign

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

the class PCGVer2Parser method parcePCGSourceOnly.

/**
	 * Check the game mode and then build a list of campaigns the character 
	 * requires to be loaded.
	 *   
	 * @param lines The PCG lines to be parsed.
	 * @return The list of campaigns.
	 * @throws PCGParseException If the lines are invalid 
	 */
@Override
public SourceSelectionFacade parcePCGSourceOnly(String[] lines) throws PCGParseException {
    buildPcgLineCache(lines);
    /*
		 * VERSION:x.x.x
		 */
    if (cache.containsKey(IOConstants.TAG_VERSION)) {
        parseVersionLine(cache.get(IOConstants.TAG_VERSION).get(0));
    }
    if (!cache.containsKey(IOConstants.TAG_GAMEMODE)) {
        Logging.errorPrint("Character does not have game mode information.");
        return null;
    }
    String line = cache.get(IOConstants.TAG_GAMEMODE).get(0);
    String requestedMode = line.substring(IOConstants.TAG_GAMEMODE.length() + 1);
    GameMode mode = SystemCollections.getGameModeNamed(requestedMode);
    if (mode == null) {
        for (GameMode gameMode : SystemCollections.getUnmodifiableGameModeList()) {
            if (gameMode.getAllowedModes().contains(requestedMode)) {
                mode = gameMode;
                break;
            }
        }
    }
    //if mode == null still then a game mode was not found
    if (mode == null) {
        Logging.errorPrint("Character's game mode entry was not valid: " + line);
        return null;
    }
    if (!cache.containsKey(IOConstants.TAG_CAMPAIGN)) {
        Logging.errorPrint("Character does not have campaign information.");
        return FacadeFactory.createSourceSelection(mode, new ArrayList<>());
    }
    /*
		 * #System Information
		 * CAMPAIGN:CMP - Monkey Book I - Book For Monkeys
		 * CAMPAIGN:CMP - Monkey Book II - Book By Monkeys
		 * ...
		 *
		 * first thing to do is checking campaigns - no matter what!
		 */
    List<Campaign> campaigns = getCampaignList(cache.get(IOConstants.TAG_CAMPAIGN), mode.getName());
    if (campaigns.isEmpty()) {
        Logging.errorPrint("Character's campaign entry was empty.");
    }
    return FacadeFactory.createSourceSelection(mode, campaigns);
}
Also used : GameMode(pcgen.core.GameMode) Campaign(pcgen.core.Campaign)

Example 18 with Campaign

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

the class AbstractContentTokenTest method testFromCampaign.

//BioSet not *supposed* to do things like this
@Test
public void testFromCampaign() throws PersistenceLayerException {
    Campaign source = create(Campaign.class, "Source");
    processToken(source);
    assertEquals(baseCount(), targetFacetCount());
    expandedCampaignFacet.add(id, source, this);
    assertTrue(containsExpected());
    assertEquals(baseCount() + 1, targetFacetCount());
    expandedCampaignFacet.remove(id, source, this);
    assertEquals(baseCount(), targetFacetCount());
}
Also used : Campaign(pcgen.core.Campaign) Test(org.junit.Test) AbstractTokenModelTest(tokenmodel.testsupport.AbstractTokenModelTest)

Example 19 with Campaign

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

the class CampaignFileLoader method initCampaigns.

/**
     * Goes through the campaigns in {@link #campaignFiles campaignFiles} and loads
     * data associated with dependent campaigns.
     */
private static void initCampaigns() {
    // This may modify the globals list; need a local copy so
    // the iteration doesn't fail.
    Iterable<Campaign> initialCampaigns = new ArrayList<>(Globals.getCampaignList());
    CampaignLoader campaignLoader = new CampaignLoader();
    for (final Campaign c : initialCampaigns) {
        campaignLoader.initRecursivePccFiles(c);
    }
}
Also used : Campaign(pcgen.core.Campaign) ArrayList(java.util.ArrayList) CampaignLoader(pcgen.persistence.lst.CampaignLoader)

Example 20 with Campaign

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

the class AbstractGrantedListTokenTest method testFromCampaign.

//BioSet not *supposed* to do things like this
@Test
public void testFromCampaign() throws PersistenceLayerException {
    Campaign source = create(Campaign.class, "Source");
    T granted = createGrantedObject();
    processToken(source);
    assertEquals(0, getCount());
    expandedCampaignFacet.add(id, source, this);
    assertTrue(containsExpected(granted));
    assertEquals((expandedCampaignFacet == getTargetFacet()) ? 2 : 1, getCount());
    expandedCampaignFacet.remove(id, source, this);
    assertEquals(0, getCount());
    assertTrue(cleanedSideEffects());
}
Also used : Campaign(pcgen.core.Campaign) Test(org.junit.Test)

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