Search in sources :

Example 1 with Description

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

the class SourceFileLoader method addCustomFilesToStartOfList.

private void addCustomFilesToStartOfList() {
    CampaignSourceEntry tempSource = null;
    // The dummy campaign for custom data.
    Campaign customCampaign = new Campaign();
    customCampaign.setName("Custom");
    customCampaign.addToListFor(ListKey.DESCRIPTION, new Description("Custom data"));
    //
    // Add the custom bioset file to the start of the list if it exists
    //
    File bioSetFile = new File(CustomData.customBioSetFilePath(true));
    if (bioSetFile.exists()) {
        tempSource = new CampaignSourceEntry(customCampaign, bioSetFile.toURI());
        fileLists.removeFromListFor(ListKey.FILE_BIO_SET, tempSource);
        fileLists.addToListFor(ListKey.FILE_BIO_SET, 0, tempSource);
    }
    //
    // Add the custom class file to the start of the list if it exists
    //
    File classFile = new File(CustomData.customClassFilePath(true));
    if (classFile.exists()) {
        tempSource = new CampaignSourceEntry(customCampaign, classFile.toURI());
        fileLists.removeFromListFor(ListKey.FILE_CLASS, tempSource);
        fileLists.addToListFor(ListKey.FILE_CLASS, 0, tempSource);
    }
    //
    // Add the custom deity file to the start of the list if it exists
    //
    File deityFile = new File(CustomData.customDeityFilePath(true));
    if (deityFile.exists()) {
        tempSource = new CampaignSourceEntry(customCampaign, deityFile.toURI());
        fileLists.removeFromListFor(ListKey.FILE_DEITY, tempSource);
        fileLists.addToListFor(ListKey.FILE_DEITY, 0, tempSource);
    }
    //
    // Add the custom domain file to the start of the list if it exists
    //
    File domainFile = new File(CustomData.customDomainFilePath(true));
    if (domainFile.exists()) {
        tempSource = new CampaignSourceEntry(customCampaign, domainFile.toURI());
        fileLists.removeFromListFor(ListKey.FILE_DOMAIN, tempSource);
        fileLists.addToListFor(ListKey.FILE_DOMAIN, 0, tempSource);
    }
    //
    // Add the custom ability file to the start of the list if it exists
    //
    File abilityFile = new File(CustomData.customAbilityFilePath(true));
    if (abilityFile.exists()) {
        tempSource = new CampaignSourceEntry(customCampaign, abilityFile.toURI());
        fileLists.removeFromListFor(ListKey.FILE_ABILITY, tempSource);
        fileLists.addToListFor(ListKey.FILE_ABILITY, 0, tempSource);
    }
    //
    // Add the custom feat file to the start of the list if it exists
    //
    File featFile = new File(CustomData.customFeatFilePath(true));
    if (featFile.exists()) {
        tempSource = new CampaignSourceEntry(customCampaign, featFile.toURI());
        fileLists.removeFromListFor(ListKey.FILE_FEAT, tempSource);
        fileLists.addToListFor(ListKey.FILE_FEAT, 0, tempSource);
    }
    //
    // Add the custom language file to the start of the list if it exists
    //
    File languageFile = new File(CustomData.customLanguageFilePath(true));
    if (languageFile.exists()) {
        tempSource = new CampaignSourceEntry(customCampaign, languageFile.toURI());
        fileLists.removeFromListFor(ListKey.FILE_LANGUAGE, tempSource);
        fileLists.addToListFor(ListKey.FILE_LANGUAGE, 0, tempSource);
    }
    //
    // Add the custom race file to the start of the list if it exists
    //
    File raceFile = new File(CustomData.customRaceFilePath(true));
    if (raceFile.exists()) {
        tempSource = new CampaignSourceEntry(customCampaign, raceFile.toURI());
        fileLists.removeFromListFor(ListKey.FILE_RACE, tempSource);
        fileLists.addToListFor(ListKey.FILE_RACE, 0, tempSource);
    }
    //
    // Add the custom skill file to the start of the list if it exists
    //
    File skillFile = new File(CustomData.customSkillFilePath(true));
    if (skillFile.exists()) {
        tempSource = new CampaignSourceEntry(customCampaign, skillFile.toURI());
        fileLists.removeFromListFor(ListKey.FILE_SKILL, tempSource);
        fileLists.addToListFor(ListKey.FILE_SKILL, 0, tempSource);
    }
    //
    // Add the custom spell file to the start of the list if it exists
    //
    File spellFile = new File(CustomData.customSpellFilePath(true));
    if (spellFile.exists()) {
        tempSource = new CampaignSourceEntry(customCampaign, spellFile.toURI());
        fileLists.removeFromListFor(ListKey.FILE_SPELL, tempSource);
        fileLists.addToListFor(ListKey.FILE_SPELL, 0, tempSource);
    }
    //
    // Add the custom template file to the start of the list if it exists
    //
    File templateFile = new File(CustomData.customTemplateFilePath(true));
    if (templateFile.exists()) {
        tempSource = new CampaignSourceEntry(customCampaign, templateFile.toURI());
        fileLists.removeFromListFor(ListKey.FILE_TEMPLATE, tempSource);
        fileLists.addToListFor(ListKey.FILE_TEMPLATE, 0, tempSource);
    }
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) Description(pcgen.core.Description) PCGFile(pcgen.io.PCGFile) File(java.io.File)

Example 2 with Description

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

the class PCGVer2Creator method writeAbilityToBuffer.

private void writeAbilityToBuffer(StringBuilder buffer, CNAbility cna) {
    Category<Ability> cat = cna.getAbilityCategory();
    Nature nature = cna.getNature();
    Ability ability = cna.getAbility();
    buffer.append(IOConstants.TAG_ABILITY).append(IOConstants.TAG_END);
    buffer.append(EntityEncoder.encode(cat.getKeyName())).append(IOConstants.TAG_SEPARATOR);
    buffer.append(IOConstants.TAG_TYPE).append(IOConstants.TAG_END);
    buffer.append(EntityEncoder.encode(nature.toString())).append(IOConstants.TAG_SEPARATOR);
    buffer.append(IOConstants.TAG_CATEGORY).append(IOConstants.TAG_END);
    buffer.append(EntityEncoder.encode(ability.getCategory())).append(IOConstants.TAG_SEPARATOR);
    buffer.append(IOConstants.TAG_MAPKEY).append(IOConstants.TAG_END);
    buffer.append(EntityEncoder.encode(ability.getKeyName())).append(IOConstants.TAG_SEPARATOR);
    if (ability.getSafe(ObjectKey.MULTIPLE_ALLOWED)) {
        buffer.append(IOConstants.TAG_APPLIEDTO).append(IOConstants.TAG_END);
        List<String> assocList = thePC.getAssociationList(cna);
        boolean first = true;
        for (String assoc : assocList) {
            if (!first) {
                buffer.append(Constants.COMMA);
            }
            first = false;
            buffer.append(EntityEncoder.encode(assoc));
        }
        buffer.append(IOConstants.TAG_SEPARATOR);
    }
    buffer.append(IOConstants.TAG_TYPE).append(IOConstants.TAG_END);
    buffer.append(EntityEncoder.encode(ability.getType()));
    for (final BonusObj save : thePC.getSaveableBonusList(ability)) {
        buffer.append('|');
        buffer.append(IOConstants.TAG_SAVE).append(':');
        buffer.append(EntityEncoder.encode("BONUS|" + save));
    }
    for (final Description desc : ability.getSafeListFor(ListKey.DESCRIPTION)) {
        buffer.append(Constants.PIPE);
        buffer.append(IOConstants.TAG_DESC).append(':');
        buffer.append(EntityEncoder.encode(desc.getPCCText()));
    }
    buffer.append(IOConstants.LINE_SEP);
}
Also used : Ability(pcgen.core.Ability) CNAbility(pcgen.cdom.content.CNAbility) SpecialAbility(pcgen.core.SpecialAbility) Nature(pcgen.cdom.enumeration.Nature) Description(pcgen.core.Description) BonusObj(pcgen.core.bonus.BonusObj)

Example 3 with Description

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

the class DescriptionActor method process.

@Override
public TemplateModel process(CharID id, PObject d) throws TemplateModelException {
    List<Description> theBenefits = d.getListFor(listKey);
    if (theBenefits == null) {
        return FacetLibrary.getFacet(ObjectWrapperFacet.class).wrap(id, Constants.EMPTY_STRING);
    }
    PlayerCharacterTrackingFacet charStore = SpringHelper.getBean(PlayerCharacterTrackingFacet.class);
    PlayerCharacter aPC = charStore.getPC(id);
    final StringBuilder buf = new StringBuilder(250);
    boolean needSpace = false;
    for (final Description desc : theBenefits) {
        final String str = desc.getDescription(aPC, Collections.singletonList(d));
        if (!str.isEmpty()) {
            if (needSpace) {
                buf.append(' ');
            }
            buf.append(str);
            needSpace = true;
        }
    }
    return FacetLibrary.getFacet(ObjectWrapperFacet.class).wrap(id, buf.toString());
}
Also used : Description(pcgen.core.Description) PlayerCharacter(pcgen.core.PlayerCharacter) ObjectWrapperFacet(pcgen.cdom.facet.ObjectWrapperFacet) PlayerCharacterTrackingFacet(pcgen.cdom.facet.PlayerCharacterTrackingFacet)

Example 4 with Description

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

the class BenefitToken method parseBenefit.

/**
	 * Parses the BENEFIT tag into a Description object.
	 * 
	 * @param aDesc
	 *            The LST tag
	 * @return A <tt>Description</tt> object
	 */
public Description parseBenefit(final String aDesc) {
    if (isEmpty(aDesc) || hasIllegalSeparator('|', aDesc)) {
        return null;
    }
    final StringTokenizer tok = new StringTokenizer(aDesc, Constants.PIPE);
    String firstToken = tok.nextToken();
    if (PreParserFactory.isPreReqString(firstToken)) {
        Logging.errorPrint("Invalid " + getTokenName() + ": " + aDesc);
        Logging.errorPrint("  PRExxx can not be only value");
        return null;
    }
    String ds = EntityEncoder.decode(firstToken);
    if (!StringUtil.hasBalancedParens(ds)) {
        Logging.log(Logging.LST_ERROR, getTokenName() + " encountered imbalanced Parenthesis: " + aDesc);
        return null;
    }
    Description desc = new Description(ds);
    boolean isPre = false;
    while (tok.hasMoreTokens()) {
        final String token = tok.nextToken();
        if (PreParserFactory.isPreReqString(token)) {
            Prerequisite prereq = getPrerequisite(token);
            if (prereq == null) {
                Logging.errorPrint(getTokenName() + " had invalid prerequisite : " + token);
                return null;
            }
            desc.addPrerequisite(prereq);
            isPre = true;
        } else {
            if (isPre) {
                Logging.errorPrint("Invalid " + getTokenName() + ": " + aDesc);
                Logging.errorPrint("  PRExxx must be at the END of the Token");
                return null;
            }
            desc.addVariable(token);
        }
    }
    return desc;
}
Also used : StringTokenizer(java.util.StringTokenizer) Description(pcgen.core.Description) Prerequisite(pcgen.core.prereq.Prerequisite)

Example 5 with Description

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

the class PCTLTermEvaluatorTest method 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"));
    CampaignSourceEntry source = new CampaignSourceEntry(customCampaign, new URI("file:/" + getClass().getName() + ".java"));
    // Create the humanoid class
    String classDef = "CLASS:Humanoid	KEY:KEY_Humanoid	HD:8		CLASSTYPE:Monster	STARTSKILLPTS:1	" + "MODTOSKILLS:NO	MONSKILL:6+INT	MONNONSKILLHD:1|PRESIZELTEQ:M	" + "MONNONSKILLHD:2|PRESIZEEQ:L";
    PCClassLoader classLoader = new PCClassLoader();
    LoadContext context = Globals.getContext();
    humanoidClass = classLoader.parseLine(context, null, classDef, source);
    Globals.getContext().getReferenceContext().importObject(humanoidClass);
    // Create the BugBear race
    bugbearRace = new Race();
    bugbearRace.setName("Bugbear");
    bugbearRace.put(StringKey.KEY_NAME, "KEY_Bugbear");
    CDOMDirectSingleRef<SizeAdjustment> mediumRef = CDOMDirectSingleRef.getRef(medium);
    bugbearRace.put(FormulaKey.SIZE, new FixedSizeFormula(mediumRef));
    bugbearRace.addToListFor(ListKey.HITDICE_ADVANCEMENT, Integer.MAX_VALUE);
    bugbearRace.put(IntegerKey.INITIAL_SKILL_MULT, 1);
    Globals.getContext().getReferenceContext().importObject(bugbearRace);
}
Also used : CampaignSourceEntry(pcgen.persistence.lst.CampaignSourceEntry) Campaign(pcgen.core.Campaign) Description(pcgen.core.Description) Race(pcgen.core.Race) LoadContext(pcgen.rules.context.LoadContext) PCClassLoader(pcgen.persistence.lst.PCClassLoader) URI(java.net.URI) SizeAdjustment(pcgen.core.SizeAdjustment) FixedSizeFormula(pcgen.cdom.formula.FixedSizeFormula)

Aggregations

Description (pcgen.core.Description)14 Campaign (pcgen.core.Campaign)4 FixedSizeFormula (pcgen.cdom.formula.FixedSizeFormula)3 SizeAdjustment (pcgen.core.SizeAdjustment)3 CampaignSourceEntry (pcgen.persistence.lst.CampaignSourceEntry)3 URI (java.net.URI)2 ArrayList (java.util.ArrayList)2 StringTokenizer (java.util.StringTokenizer)2 Ability (pcgen.core.Ability)2 Domain (pcgen.core.Domain)2 PlayerCharacter (pcgen.core.PlayerCharacter)2 Race (pcgen.core.Race)2 Prerequisite (pcgen.core.prereq.Prerequisite)2 PCClassLoader (pcgen.persistence.lst.PCClassLoader)2 LoadContext (pcgen.rules.context.LoadContext)2 File (java.io.File)1 CDOMReference (pcgen.cdom.base.CDOMReference)1 CNAbility (pcgen.cdom.content.CNAbility)1 LevelCommandFactory (pcgen.cdom.content.LevelCommandFactory)1 Nature (pcgen.cdom.enumeration.Nature)1