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());
}
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);
}
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());
}
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);
}
}
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());
}
Aggregations