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