Search in sources :

Example 26 with Campaign

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

the class VisibleTokenTest 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 27 with Campaign

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

the class FunctionTokenTest 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 28 with Campaign

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

the class PreCampaignTester method countCampaignByBookType.

/**
	 * Count the number of campaign currently loaded or selected that 
	 * are of the book type.
	 * 
	 * @param bookType the book type
	 * @param includeSubCampaigns Should we count included sub campaigns that match
	 * 
	 * @return the number of matching campaigns
	 */
private int countCampaignByBookType(String bookType, boolean includeSubCampaigns) {
    Set<Campaign> matchingCampaigns = new HashSet<>();
    PersistenceManager pMan = PersistenceManager.getInstance();
    List<URI> selCampaigns = pMan.getChosenCampaignSourcefiles();
    for (URI element : selCampaigns) {
        final Campaign aCampaign = Globals.getCampaignByURI(element, false);
        List<Campaign> fullCampList;
        if (includeSubCampaigns) {
            fullCampList = getFullCampaignList(aCampaign);
        } else {
            fullCampList = new ArrayList<>();
            fullCampList.add(aCampaign);
        }
        for (Campaign camp : fullCampList) {
            for (String listType : camp.getBookTypeList()) {
                if (bookType.equalsIgnoreCase(listType)) {
                    matchingCampaigns.add(camp);
                    break;
                }
            }
        }
    }
    return matchingCampaigns.size();
}
Also used : Campaign(pcgen.core.Campaign) PersistenceManager(pcgen.persistence.PersistenceManager) URI(java.net.URI) HashSet(java.util.HashSet)

Example 29 with Campaign

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

the class AbstractPCClassLevelTokenTestCase 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 30 with Campaign

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

the class DataLoadTest method getBasicSources.

private static List<SourceSelectionFacade> getBasicSources() {
    List<SourceSelectionFacade> basicSources = new ArrayList<>();
    for (Campaign campaign : Globals.getCampaignList()) {
        if (campaign.showInMenu()) {
            SourceSelectionFacade sourceSelection = FacadeFactory.createSourceSelection(campaign.getGameModes().getElementAt(0), Collections.singletonList(campaign), campaign.getName());
            basicSources.add(sourceSelection);
        }
    }
    for (GameMode mode : SystemCollections.getUnmodifiableGameModeList()) {
        String title = mode.getDefaultSourceTitle();
        if (title == null && !mode.getDefaultDataSetList().isEmpty()) {
            title = mode.getName();
        }
        if (!mode.getDefaultDataSetList().isEmpty()) {
            List<CampaignFacade> qcamps = new ArrayList<>();
            List<String> sources = mode.getDefaultDataSetList();
            for (String string : sources) {
                Campaign camp = Globals.getCampaignKeyed(string);
                assertNotNull("Cannot find source " + string + " for game mode " + mode, camp);
                qcamps.add(camp);
            }
            basicSources.add(FacadeFactory.createSourceSelection(mode, qcamps, mode.getDefaultSourceTitle()));
        }
    }
    return basicSources;
}
Also used : GameMode(pcgen.core.GameMode) SourceSelectionFacade(pcgen.facade.core.SourceSelectionFacade) Campaign(pcgen.core.Campaign) ArrayList(java.util.ArrayList) CampaignFacade(pcgen.facade.core.CampaignFacade)

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