Search in sources :

Example 1 with PlayerCharacterTrackingFacet

use of pcgen.cdom.facet.PlayerCharacterTrackingFacet 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)

Aggregations

ObjectWrapperFacet (pcgen.cdom.facet.ObjectWrapperFacet)1 PlayerCharacterTrackingFacet (pcgen.cdom.facet.PlayerCharacterTrackingFacet)1 Description (pcgen.core.Description)1 PlayerCharacter (pcgen.core.PlayerCharacter)1