Search in sources :

Example 16 with PersistentTransitionChoice

use of pcgen.cdom.base.PersistentTransitionChoice in project pcgen by PCGen.

the class RemoveFeatToken method unparse.

@Override
public String[] unparse(LoadContext context, CDOMObject obj) {
    Changes<PersistentTransitionChoice<?>> grantChanges = context.getObjectContext().getListChanges(obj, ListKey.REMOVE);
    Collection<PersistentTransitionChoice<?>> addedItems = grantChanges.getAdded();
    if (addedItems == null || addedItems.isEmpty()) {
        // Zero indicates no Token
        return null;
    }
    List<String> addStrings = new ArrayList<>();
    for (TransitionChoice<?> container : addedItems) {
        SelectableSet<?> cs = container.getChoices();
        if (getTokenName().equals(cs.getName()) && CAT_ABILITY_SELECTION_CLASS.equals(cs.getChoiceClass())) {
            Formula f = container.getCount();
            if (f == null) {
                context.addWriteMessage("Unable to find " + getFullName() + " Count");
                return null;
            }
            StringBuilder sb = new StringBuilder();
            if (!FormulaFactory.ONE.equals(f)) {
                sb.append(f).append(Constants.PIPE);
            }
            sb.append(cs.getLSTformat());
            addStrings.add(sb.toString());
        }
    }
    return addStrings.toArray(new String[addStrings.size()]);
}
Also used : Formula(pcgen.base.formula.Formula) ConcretePersistentTransitionChoice(pcgen.cdom.base.ConcretePersistentTransitionChoice) PersistentTransitionChoice(pcgen.cdom.base.PersistentTransitionChoice) ArrayList(java.util.ArrayList)

Aggregations

PersistentTransitionChoice (pcgen.cdom.base.PersistentTransitionChoice)16 ArrayList (java.util.ArrayList)12 Formula (pcgen.base.formula.Formula)9 ConcretePersistentTransitionChoice (pcgen.cdom.base.ConcretePersistentTransitionChoice)9 PCClass (pcgen.core.PCClass)4 HashSet (java.util.HashSet)3 Test (org.junit.Test)3 CDOMObject (pcgen.cdom.base.CDOMObject)3 ClassSkillChoiceActor (pcgen.cdom.helper.ClassSkillChoiceActor)3 PCTemplate (pcgen.core.PCTemplate)2 PlayerCharacter (pcgen.core.PlayerCharacter)2 URI (java.net.URI)1 URISyntaxException (java.net.URISyntaxException)1 Collection (java.util.Collection)1 IdentityHashMap (java.util.IdentityHashMap)1 Set (java.util.Set)1 UnreachableError (pcgen.base.lang.UnreachableError)1 HashMapToList (pcgen.base.util.HashMapToList)1 AssociatedPrereqObject (pcgen.cdom.base.AssociatedPrereqObject)1 AbilityChoiceSet (pcgen.cdom.base.ChoiceSet.AbilityChoiceSet)1