Search in sources :

Example 11 with Description

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

the class PCGVer2Creator method appendDomainLines.

private void appendDomainLines(StringBuilder buffer) {
    for (final Domain domain : charDisplay.getDomainSet()) {
        // TODO is any of this commented out code any use anymore?:
        //
        //  			// improve here - performance and concept!!!!
        //  			domainSpells.clear();
        //  			for (Iterator it2 = Globals.getSpellMap().values().iterator(); it2.hasNext();)
        //  			{
        //  				aSpell = (Spell)it2.next();
        //  //			levelString = aSpell.levelForClass(aDomain.getName());
        //  				if ((levelString.length() > 0) &&
        //  				  (levelString.indexOf("-1") < 0))
        //  				{
        //  					tokens = new StringTokenizer(levelString, ",");
        //  					while (tokens.hasMoreTokens())
        //  					{
        //  						if (tokens.nextToken().equals(aDomain.getName()))
        //  						{
        //  							break;
        //  						}
        //  					}
        //  					domainSpells.add(((tokens.hasMoreTokens()) ? tokens.nextToken() + " " : "") +
        //  					  aSpell.getName());
        //  				}
        //  			}
        buffer.append(IOConstants.TAG_DOMAIN).append(':');
        buffer.append(EntityEncoder.encode(domain.getKeyName()));
        for (String assoc : thePC.getAssociationList(domain)) {
            buffer.append('|');
            buffer.append(IOConstants.TAG_ASSOCIATEDDATA).append(':');
            buffer.append(EntityEncoder.encode(assoc));
        }
        for (final Description desc : domain.getSafeListFor(ListKey.DESCRIPTION)) {
            buffer.append('|');
            buffer.append(IOConstants.TAG_DOMAINGRANTS).append(':');
            buffer.append(desc.getPCCText());
        }
        buffer.append('|');
        appendSourceInTaggedFormat(buffer, getDomainSourcePcgString(domain));
        //			buffer.append('|');
        //			buffer.append(TAG_DOMAINFEATS).append(':');
        //			buffer.append(aDomain.getFeatList());
        //			buffer.append('|');
        //			buffer.append(TAG_DOMAINSKILLS).append(':');
        //			buffer.append(aDomain.getSkillList());
        //			buffer.append('|');
        //			buffer.append(TAG_DOMAINSPECIALS).append(':');
        //			buffer.append(aDomain.getSpecialAbility());
        //			buffer.append('|');
        //			buffer.append(TAG_DOMAINSPELLS).append(':');
        //			buffer.append(aDomain.getSpellList());
        appendAddTokenInfo(buffer, domain);
        buffer.append(IOConstants.LINE_SEP);
    /*
			 * not working yet anyways
			 *
			 * author: Thomas Behr 09-09-02
			 */
    //  			buffer.append(TAG_DOMAINSPELLS).append(':');
    //  			buffer.append(EntityEncoder.encode(aDomain.getKeyName()));
    //  			buffer.append('|');
    //  			buffer.append(TAG_SPELLLIST).append(':');
    //			buffer.append('[');
    //  			del = "";
    //  			Collections.sort(domainSpells);
    //  			for (Iterator it2 = domainSpells.iterator(); it2.hasNext();)
    //  			{
    //  				buffer.append(del);
    //  				buffer.append(TAG_SPELL).append(':');
    //				buffer.append(EntityEncoder.encode((String)it2.next()));
    //  				del = "|";
    //  			}
    //			buffer.append(']');
    //  			buffer.append(LINE_SEP);
    }
}
Also used : Description(pcgen.core.Description) Domain(pcgen.core.Domain)

Example 12 with Description

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

the class PCGVer2Creator method appendDeityLine.

/*
	 * ###############################################################
	 * Character Deity/Domain methods
	 * ###############################################################
	 */
private void appendDeityLine(StringBuilder buffer) {
    if (charDisplay.getDeity() != null) {
        final Deity aDeity = charDisplay.getDeity();
        buffer.append(IOConstants.TAG_DEITY).append(':');
        buffer.append(EntityEncoder.encode(aDeity.getKeyName()));
        /*
			 * currently unused information
			 *
			 * author: Thomas Behr 09-09-02
			 */
        buffer.append('|');
        buffer.append(IOConstants.TAG_DEITYDOMAINS).append(':');
        buffer.append('[');
        String del = Constants.EMPTY_STRING;
        for (CDOMReference<Domain> ref : aDeity.getSafeListMods(Deity.DOMAINLIST)) {
            for (Domain d : ref.getContainedObjects()) {
                buffer.append(del);
                buffer.append(IOConstants.TAG_DOMAIN).append(':');
                buffer.append(EntityEncoder.encode(d.getKeyName()));
                //$NON-NLS-1$
                del = "|";
            }
        }
        buffer.append(']');
        buffer.append('|');
        buffer.append(IOConstants.TAG_ALIGNALLOW).append(':');
        //TODO Need to clean this up?
        for (final Description desc : aDeity.getSafeListFor(ListKey.DESCRIPTION)) {
            buffer.append('|');
            buffer.append(IOConstants.TAG_DESC).append(':');
            buffer.append(desc.getPCCText());
        }
        buffer.append('|');
        buffer.append(IOConstants.TAG_DEITYFAVWEAP).append(':');
        buffer.append('[');
        List<CDOMReference<WeaponProf>> dwp = aDeity.getListFor(ListKey.DEITYWEAPON);
        if (dwp != null) {
            del = Constants.EMPTY_STRING;
            for (CDOMReference<WeaponProf> ref : dwp) {
                buffer.append(del);
                buffer.append(IOConstants.TAG_WEAPON).append(':');
                buffer.append(EntityEncoder.encode(ref.getLSTformat(false)));
                //$NON-NLS-1$
                del = "|";
            }
        }
        buffer.append(']');
        buffer.append('|');
        buffer.append(IOConstants.TAG_DEITYALIGN).append(':');
        CDOMSingleRef<PCAlignment> al = aDeity.get(ObjectKey.ALIGNMENT);
        if (al != null) {
            buffer.append(al.getLSTformat(false));
        }
        buffer.append(IOConstants.LINE_SEP);
    }
}
Also used : Deity(pcgen.core.Deity) PCAlignment(pcgen.core.PCAlignment) Description(pcgen.core.Description) WeaponProf(pcgen.core.WeaponProf) Domain(pcgen.core.Domain) CDOMReference(pcgen.cdom.base.CDOMReference)

Example 13 with Description

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

the class BenefitToken method unparse.

@Override
public String[] unparse(LoadContext context, Ability ability) {
    PatternChanges<Description> changes = context.getObjectContext().getListPatternChanges(ability, ListKey.BENEFIT);
    if (changes == null || changes.isEmpty()) {
        return null;
    }
    List<String> list = new ArrayList<>();
    Collection<String> removedItems = changes.getRemoved();
    if (changes.includesGlobalClear()) {
        if (removedItems != null && !removedItems.isEmpty()) {
            context.addWriteMessage("Non-sensical relationship in " + getTokenName() + ": global .CLEAR and local .CLEAR. performed");
            return null;
        }
        list.add(Constants.LST_DOT_CLEAR);
    } else if (removedItems != null && !removedItems.isEmpty()) {
        for (String d : removedItems) {
            list.add(Constants.LST_DOT_CLEAR_DOT + d);
        }
    }
    Collection<Description> added = changes.getAdded();
    if (added != null && !added.isEmpty()) {
        for (Description d : added) {
            list.add(d.getPCCText());
        }
    }
    if (list.isEmpty()) {
        return null;
    }
    return list.toArray(new String[list.size()]);
}
Also used : Description(pcgen.core.Description) ArrayList(java.util.ArrayList)

Example 14 with Description

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

the class BenefitToken method parseNonEmptyToken.

@Override
protected ParseResult parseNonEmptyToken(LoadContext context, Ability ability, String value) {
    if (Constants.LST_DOT_CLEAR.equals(value)) {
        context.getObjectContext().removeList(ability, ListKey.BENEFIT);
        return ParseResult.SUCCESS;
    }
    if (value.startsWith(Constants.LST_DOT_CLEAR_DOT)) {
        context.getObjectContext().removePatternFromList(ability, ListKey.BENEFIT, value.substring(7));
        return ParseResult.SUCCESS;
    }
    Description ben = parseBenefit(value);
    if (ben == null) {
        return ParseResult.INTERNAL_ERROR;
    }
    context.getObjectContext().addToList(ability, ListKey.BENEFIT, ben);
    return ParseResult.SUCCESS;
}
Also used : Description(pcgen.core.Description)

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