Search in sources :

Example 26 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class GlobalModifierToken method unparse.

@Override
public String[] unparse(LoadContext context, Campaign campaign) {
    Changes<CampaignSourceEntry> cseChanges = context.getObjectContext().getListChanges(campaign, ListKey.FILE_GLOBALMOD);
    Collection<CampaignSourceEntry> added = cseChanges.getAdded();
    if (added == null) {
        //empty indicates no token
        return null;
    }
    Set<String> set = new TreeSet<>();
    for (CampaignSourceEntry cse : added) {
        set.add(cse.getLSTformat());
    }
    return set.toArray(new String[set.size()]);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) TreeSet(java.util.TreeSet)

Example 27 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class LicenseToken method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, Campaign campaign, String value) {
    if (value.startsWith("FILE=")) {
        String fileURI = value.substring(5);
        if (fileURI.isEmpty()) {
            return new ParseResult.Fail("Cannot have empty FILE in " + getTokenName(), context);
        }
        CampaignSourceEntry cse = context.getCampaignSourceEntry(campaign, fileURI);
        if (cse == null) {
            return ParseResult.INTERNAL_ERROR;
        }
        context.getObjectContext().addToList(campaign, ListKey.LICENSE_FILE, cse);
    } else {
        context.getObjectContext().addToList(campaign, ListKey.LICENSE, value);
    }
    return ParseResult.SUCCESS;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry)

Example 28 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class TestHelper method makeEquipment.

/**
	 * Make some equipment
	 * @param input Equipment source line to be parsed
	 * @return true if OK
	 */
public static boolean makeEquipment(final String input) {
    loadPlugins();
    try {
        final CampaignSourceEntry source = createSource(TestHelper.class);
        eqLoader.parseLine(Globals.getContext(), null, input, source);
        return true;
    } catch (Exception e) {
    // TODO Deal with Exception?
    }
    return false;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) URISyntaxException(java.net.URISyntaxException) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) IOException(java.io.IOException)

Example 29 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class CampaignFeatToken method parseTokenWithSeparator.

@Override
protected ParseResult parseTokenWithSeparator(LoadContext context, Campaign campaign, String value) {
    Logging.deprecationPrint("FEAT has been deprecated, use ABILITY: " + "and put CATEGORY: entries in the LST file");
    CampaignSourceEntry cse = context.getCampaignSourceEntry(campaign, value);
    if (cse == null) {
        //Error
        return ParseResult.INTERNAL_ERROR;
    }
    context.getObjectContext().addToList(campaign, ListKey.FILE_FEAT, cse);
    return ParseResult.SUCCESS;
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry)

Example 30 with CampaignSourceEntry

use of pcgen.persistence.lst.CampaignSourceEntry in project pcgen by PCGen.

the class AddClassSkillsTest method testGetChoicesListWithClassSkill.

/**
	 * Test method for 'pcgen.core.levelability.LevelAbilityClassSkills.getChoicesList(String, PlayerCharacter)'
	 */
@Test
public void testGetChoicesListWithClassSkill() {
    CampaignSourceEntry source;
    try {
        source = new CampaignSourceEntry(new Campaign(), new URI("file:/" + getClass().getName() + ".java"));
    } catch (URISyntaxException e) {
        throw new UnreachableError(e);
    }
    String classPCCText = "CLASS:Cleric	HD:8		TYPE:Base.PC	ABB:Clr\n" + "CLASS:Cleric	STARTSKILLPTS:2	CSKILL:KEY_Knowledge (Dungeoneering)";
    PCClass po;
    try {
        po = parsePCClassText(classPCCText, source);
    } catch (PersistenceLayerException e) {
        throw new UnreachableError(e);
    }
    getCharacter().incrementClassLevel(1, po, false);
    PCTemplate pct = new PCTemplate();
    Skill bluff = Globals.getContext().getReferenceContext().silentlyGetConstructedCDOMObject(Skill.class, "KEY_Bluff");
    pct.addToListFor(ListKey.CSKILL, CDOMDirectSingleRef.getRef(bluff));
    getCharacter().addTemplate(pct);
    Globals.getContext().unconditionallyProcess(po, "ADD", "CLASSSKILLS|2|KEY_Bluff,KEY_Listen,KEY_Knowledge (Arcana)");
    assertTrue(Globals.getContext().getReferenceContext().resolveReferences(null));
    List<PersistentTransitionChoice<?>> choiceList = po.getListFor(ListKey.ADD);
    assertEquals(1, choiceList.size());
    TransitionChoice<?> choice = choiceList.get(0);
    Collection<?> choiceSet = choice.getChoices().getSet(getCharacter());
    assertEquals(3, choiceSet.size());
    Set<Object> limitedSet = new HashSet<>();
    ClassSkillChoiceActor csca = new ClassSkillChoiceActor(po, 0);
    for (Object sc : choiceSet) {
        if (csca.allow((Skill) sc, getCharacter(), true)) {
            limitedSet.add(sc);
        }
    }
    assertEquals(2, limitedSet.size());
    assertEquals(2, choice.getCount().resolve(getCharacter(), ""));
    List<String> choiceStrings = new ArrayList<>();
    for (Object o : limitedSet) {
        choiceStrings.add(o.toString());
    }
    assertTrue(choiceStrings.contains("Listen"));
    assertTrue(choiceStrings.contains("Knowledge (Arcana)"));
}
Also used : PersistentTransitionChoice(pcgen.cdom.base.PersistentTransitionChoice) ArrayList(java.util.ArrayList) URISyntaxException(java.net.URISyntaxException) UnreachableError(pcgen.base.lang.UnreachableError) PCClass(pcgen.core.PCClass) URI(java.net.URI) CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) PersistenceLayerException(pcgen.persistence.PersistenceLayerException) Skill(pcgen.core.Skill) Campaign(pcgen.core.Campaign) ClassSkillChoiceActor(pcgen.cdom.helper.ClassSkillChoiceActor) PCTemplate(pcgen.core.PCTemplate) HashSet(java.util.HashSet) Test(org.junit.Test)

Aggregations

CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)95 URI (java.net.URI)54 Campaign (pcgen.core.Campaign)44 URISyntaxException (java.net.URISyntaxException)27 LoadContext (pcgen.rules.context.LoadContext)25 UnreachableError (pcgen.base.lang.UnreachableError)19 BeforeClass (org.junit.BeforeClass)16 PCClassLoader (pcgen.persistence.lst.PCClassLoader)15 TreeSet (java.util.TreeSet)12 PlayerCharacter (pcgen.core.PlayerCharacter)11 PersistenceLayerException (pcgen.persistence.PersistenceLayerException)11 ArrayList (java.util.ArrayList)9 PCClass (pcgen.core.PCClass)9 File (java.io.File)8 GenericLoader (pcgen.persistence.lst.GenericLoader)8 CDOMReference (pcgen.cdom.base.CDOMReference)7 SourceEntry (pcgen.persistence.lst.SourceEntry)7 Ability (pcgen.core.Ability)6 FeatLoader (pcgen.persistence.lst.FeatLoader)6 AbilityList (pcgen.cdom.list.AbilityList)5