Search in sources :

Example 6 with SpecialProperty

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

the class SpropToken method unparse.

@Override
public String[] unparse(LoadContext context, Equipment eq) {
    Changes<SpecialProperty> changes = context.getObjectContext().getListChanges(eq, ListKey.SPECIAL_PROPERTIES);
    if (changes == null || changes.isEmpty()) {
        return null;
    }
    List<String> list = new ArrayList<>();
    Collection<SpecialProperty> added = changes.getAdded();
    boolean globalClear = changes.includesGlobalClear();
    if (globalClear) {
        list.add(Constants.LST_DOT_CLEAR);
    }
    if (added != null && !added.isEmpty()) {
        for (SpecialProperty sp : added) {
            StringBuilder sb = new StringBuilder();
            sb.append(sp.getDisplayName());
            if (sp.hasPrerequisites()) {
                sb.append(Constants.PIPE);
                sb.append(getPrerequisiteString(context, sp.getPrerequisiteList()));
            }
            list.add(sb.toString());
        }
    }
    if (list.isEmpty()) {
        context.addWriteMessage(getTokenName() + " was expecting non-empty changes to include " + "added items or global clear");
        return null;
    }
    return list.toArray(new String[list.size()]);
}
Also used : SpecialProperty(pcgen.core.SpecialProperty) ArrayList(java.util.ArrayList)

Aggregations

SpecialProperty (pcgen.core.SpecialProperty)6 ArrayList (java.util.ArrayList)2 Equipment (pcgen.core.Equipment)2 Formula (pcgen.base.formula.Formula)1 Type (pcgen.cdom.enumeration.Type)1 EquipmentHead (pcgen.cdom.inst.EquipmentHead)1 EquipmentModifier (pcgen.core.EquipmentModifier)1 BonusObj (pcgen.core.bonus.BonusObj)1 HtmlInfoBuilder (pcgen.gui2.util.HtmlInfoBuilder)1