Exemple #1
0
 public String[] unparse(LoadContext context, PCClassLevel obj) {
   Changes<CDOMReference<Skill>> changes =
       context.getObjectContext().getListChanges(obj, ListKey.LOCALCCSKILL);
   List<String> list = new ArrayList<String>();
   Collection<CDOMReference<Skill>> removedItems = changes.getRemoved();
   if (removedItems != null && !removedItems.isEmpty()) {
     if (changes.includesGlobalClear()) {
       context.addWriteMessage(
           "Non-sensical relationship in "
               + getTokenName()
               + ": global .CLEAR and local .CLEAR. performed");
       return null;
     }
     list.add(
         Constants.LST_DOT_CLEAR_DOT + ReferenceUtilities.joinLstFormat(removedItems, "|.CLEAR."));
   }
   if (changes.includesGlobalClear()) {
     list.add(Constants.LST_DOT_CLEAR);
   }
   Collection<CDOMReference<Skill>> added = changes.getAdded();
   if (added != null && !added.isEmpty()) {
     list.add(ReferenceUtilities.joinLstFormat(added, Constants.PIPE));
   }
   if (list.isEmpty()) {
     return null;
   }
   return list.toArray(new String[list.size()]);
 }
Exemple #2
0
 @Override
 public String[] unparse(LoadContext context, PCTemplate pct) {
   Changes<CDOMReference<Ability>> changes =
       context.getObjectContext().getListChanges(pct, ListKey.FEAT_TOKEN_LIST);
   Collection<CDOMReference<Ability>> added = changes.getAdded();
   Collection<CDOMReference<Ability>> removedItems = changes.getRemoved();
   String returnVal = null;
   if (changes.includesGlobalClear()) {
     if (removedItems != null && !removedItems.isEmpty()) {
       context.addWriteMessage(
           "Non-sensical relationship in "
               + getTokenName()
               + ": global .CLEAR and local .CLEAR. performed");
       return null;
     }
     returnVal = Constants.LST_DOT_CLEAR;
   } else if (removedItems != null && !removedItems.isEmpty()) {
     context.addWriteMessage(getTokenName() + " does not support " + Constants.LST_DOT_CLEAR_DOT);
     return null;
   }
   if (added != null && !added.isEmpty()) {
     returnVal = ReferenceUtilities.joinLstFormat(added, Constants.PIPE);
   }
   if (returnVal == null) {
     return null;
   }
   return new String[] {returnVal};
 }
Exemple #3
0
  @Override
  public String toString() {
    final StringBuilder info = new StringBuilder(100);
    if (skillList.size() > 1) {
      // This is a choice of skills.
      info.append(getSafeCount() + " of (");
      info.append(ReferenceUtilities.joinLstFormat(skillList, ", "));
      info.append(")");
    } else {
      info.append(skillList.get(0).getLSTformat(false));
    }
    info.append(" (").append(rank);

    if (info.toString().endsWith(".0")) {
      info.setLength(info.length() - 2);
    }

    if (isFree()) {
      info.append("/free");
    }

    if (selection != null && !selection.isEmpty()) {
      info.append("/");
      info.append(StringUtil.join(selection, ", "));
    }

    info.append(')');

    return info.toString();
  }
Exemple #4
0
 @Override
 public String[] unparse(LoadContext context, KitAbilities KitAbilities) {
   Collection<CDOMReference<Ability>> ref = KitAbilities.getAbilityKeys();
   if (ref == null || ref.isEmpty()) {
     return null;
   }
   return new String[] {ReferenceUtilities.joinLstFormat(ref, Constants.PIPE)};
 }
Exemple #5
0
 @Override
 public String[] unparse(LoadContext context, KitDeity kitDeity) {
   Collection<CDOMSingleRef<Domain>> domains = kitDeity.getDomains();
   if (domains == null || domains.isEmpty()) {
     return null;
   }
   return new String[] {ReferenceUtilities.joinLstFormat(domains, Constants.PIPE)};
 }
  @Override
  public String[] unparse(LoadContext context, CDOMObject obj) {
    Changes<FollowerOption> changes =
        context.getObjectContext().getListChanges(obj, ListKey.COMPANIONLIST);
    Collection<FollowerOption> removedItems = changes.getRemoved();
    if (removedItems != null && !removedItems.isEmpty() || changes.includesGlobalClear()) {
      context.addWriteMessage(getTokenName() + " does not support .CLEAR");
      return null;
    }
    Collection<FollowerOption> added = changes.getAdded();
    if (added == null || added.isEmpty()) {
      // Zero indicates no Token (and no global clear, so nothing to do)
      return null;
    }
    TripleKeyMapToList<
            Set<Prerequisite>, CDOMReference<? extends CDOMList<?>>, Integer, CDOMReference<Race>>
        m = new TripleKeyMapToList<>();
    for (FollowerOption fo : added) {
      m.addToListFor(
          new HashSet<>(fo.getPrerequisiteList()),
          fo.getListRef(),
          fo.getAdjustment(),
          fo.getRaceRef());
    }
    Set<String> set = new TreeSet<>();
    StringBuilder sb = new StringBuilder();
    for (Set<Prerequisite> prereqs : m.getKeySet()) {
      String prereqString = null;
      if (prereqs != null && !prereqs.isEmpty()) {
        prereqString = getPrerequisiteString(context, prereqs);
      }

      for (CDOMReference<? extends CDOMList<?>> cl : m.getSecondaryKeySet(prereqs)) {
        for (Integer fa : m.getTertiaryKeySet(prereqs, cl)) {
          sb.setLength(0);
          sb.append(cl.getLSTformat(false));
          sb.append(Constants.PIPE);
          Set<CDOMReference<Race>> raceSet = new TreeSet<>(ReferenceUtilities.REFERENCE_SORTER);
          raceSet.addAll(m.getListFor(prereqs, cl, fa));
          sb.append(ReferenceUtilities.joinLstFormat(raceSet, Constants.COMMA, true));
          if (fa != null && fa != 0) {
            sb.append(Constants.PIPE);
            sb.append("FOLLOWERADJUSTMENT:");
            sb.append(fa);
          }
          if (prereqString != null) {
            sb.append(Constants.PIPE);
            sb.append(prereqString);
          }
          set.add(sb.toString());
        }
      }
    }
    return set.toArray(new String[set.size()]);
  }
Exemple #7
0
 @Override
 public String[] unparse(LoadContext context, PCTemplate pct) {
   Changes<CDOMReference<WeaponProf>> changes =
       context.getObjectContext().getListChanges(pct, ListKey.WEAPONBONUS);
   Collection<CDOMReference<WeaponProf>> added = changes.getAdded();
   if (added == null || added.isEmpty()) {
     // Zero indicates no add
     return null;
   }
   return new String[] {ReferenceUtilities.joinLstFormat(added, Constants.PIPE)};
 }
Exemple #8
0
  @Override
  public String[] unparse(LoadContext context, CDOMObject obj) {
    Collection<CDOMReference<? extends CDOMList<?>>> changedLists =
        context.getListContext().getChangedLists(obj, AbilityList.class);
    Changes<ListKey<ChooseSelectionActor<?>>> actors =
        context.getObjectContext().getListChanges(obj, ListKey.GA_CAKEYS);
    Set<String> returnSet = new TreeSet<String>();
    TripleKeyMapToList<
            Nature, CDOMSingleRef<AbilityCategory>, List<Prerequisite>, CDOMReference<Ability>>
        m =
            new TripleKeyMapToList<
                Nature,
                CDOMSingleRef<AbilityCategory>,
                List<Prerequisite>,
                CDOMReference<Ability>>();
    TripleKeyMapToList<
            Nature, CDOMSingleRef<AbilityCategory>, List<Prerequisite>, CDOMReference<Ability>>
        clear =
            new TripleKeyMapToList<
                Nature,
                CDOMSingleRef<AbilityCategory>,
                List<Prerequisite>,
                CDOMReference<Ability>>();

    Changes<ChooseSelectionActor<?>> listChanges =
        context.getObjectContext().getListChanges(obj, ListKey.NEW_CHOOSE_ACTOR);
    Collection<ChooseSelectionActor<?>> listAdded = listChanges.getAdded();
    if (listAdded != null && !listAdded.isEmpty()) {
      for (ChooseSelectionActor<?> csa : listAdded) {
        if (csa.getSource().equals(getTokenName())) {
          try {
            AbilitySelector as = (AbilitySelector) csa;
            StringBuilder sb = new StringBuilder();
            sb.append(as.getAbilityCategory().getLSTformat(false)).append(Constants.PIPE);
            sb.append(as.getNature()).append(Constants.PIPE);
            sb.append(as.getLstFormat());
            returnSet.add(sb.toString());
          } catch (PersistenceLayerException e) {
            context.addWriteMessage(getTokenName() + " encountered error: " + e.getMessage());
            return null;
          }
        }
      }
    }

    for (CDOMReference ref : changedLists) {
      AssociatedChanges<CDOMReference<Ability>> changes =
          context.getListContext().getChangesInList(getTokenName(), obj, ref);
      if (changes.includesGlobalClear()) {
        CDOMDirectSingleRef<AbilityList> dr = (CDOMDirectSingleRef<AbilityList>) ref;
        AbilityList al = dr.get();
        StringBuilder sb = new StringBuilder();
        sb.append(al.getCategory().getLSTformat(false)).append(Constants.PIPE);
        sb.append(al.getNature()).append(Constants.PIPE);
        sb.append(Constants.LST_DOT_CLEAR);
        returnSet.add(sb.toString());
      }
      MapToList<CDOMReference<Ability>, AssociatedPrereqObject> mtl =
          changes.getAddedAssociations();
      if (mtl != null) {
        for (CDOMReference<Ability> ab : mtl.getKeySet()) {
          for (AssociatedPrereqObject assoc : mtl.getListFor(ab)) {
            Nature nature = assoc.getAssociation(AssociationKey.NATURE);
            CDOMSingleRef<AbilityCategory> cat = assoc.getAssociation(AssociationKey.CATEGORY);
            m.addToListFor(nature, cat, assoc.getPrerequisiteList(), ab);
          }
        }
      }
      mtl = changes.getRemovedAssociations();
      if (mtl != null) {
        for (CDOMReference<Ability> ab : mtl.getKeySet()) {
          for (AssociatedPrereqObject assoc : mtl.getListFor(ab)) {
            Nature nature = assoc.getAssociation(AssociationKey.NATURE);
            CDOMSingleRef<AbilityCategory> cat = assoc.getAssociation(AssociationKey.CATEGORY);
            clear.addToListFor(nature, cat, assoc.getPrerequisiteList(), ab);
          }
        }
      }
    }

    for (Nature nature : m.getKeySet()) {
      for (CDOMSingleRef<AbilityCategory> category : m.getSecondaryKeySet(nature)) {
        for (List<Prerequisite> prereqs : m.getTertiaryKeySet(nature, category)) {
          StringBuilder sb = new StringBuilder();
          sb.append(category.getLSTformat(false)).append(Constants.PIPE);
          sb.append(nature);
          List<CDOMReference<Ability>> clearList = clear.removeListFor(nature, category, prereqs);
          if (clearList != null && !clearList.isEmpty()) {
            sb.append(Constants.PIPE);
            sb.append(Constants.LST_DOT_CLEAR_DOT);
            sb.append(
                ReferenceUtilities.joinLstFormat(
                    clearList, Constants.PIPE + Constants.LST_DOT_CLEAR_DOT));
          }
          sb.append(Constants.PIPE);
          sb.append(
              ReferenceUtilities.joinLstFormat(
                  m.getListFor(nature, category, prereqs), Constants.PIPE));
          if (prereqs != null && !prereqs.isEmpty()) {
            sb.append(Constants.PIPE);
            sb.append(getPrerequisiteString(context, prereqs));
          }
          returnSet.add(sb.toString());
        }
      }
    }
    for (Nature nature : clear.getKeySet()) {
      for (CDOMSingleRef<AbilityCategory> category : clear.getSecondaryKeySet(nature)) {
        for (List<Prerequisite> prereqs : clear.getTertiaryKeySet(nature, category)) {
          StringBuilder sb = new StringBuilder();
          sb.append(category.getLSTformat(false)).append(Constants.PIPE);
          sb.append(nature).append(Constants.PIPE).append(Constants.LST_DOT_CLEAR_DOT);
          sb.append(
              ReferenceUtilities.joinLstFormat(
                  clear.getListFor(nature, category, prereqs),
                  Constants.PIPE + Constants.LST_DOT_CLEAR_DOT));
          if (prereqs != null && !prereqs.isEmpty()) {
            sb.append(Constants.PIPE);
            sb.append(getPrerequisiteString(context, prereqs));
          }
          returnSet.add(sb.toString());
        }
      }
    }
    Collection<ListKey<ChooseSelectionActor<?>>> addedActors = actors.getAdded();
    if (addedActors != null) {
      for (ListKey<ChooseSelectionActor<?>> lk : addedActors) {
        Changes<ChooseSelectionActor<?>> cras = context.getObjectContext().getListChanges(obj, lk);
        for (ChooseSelectionActor<?> cra : cras.getAdded()) {
          if (getTokenName().equals(cra.getSource())) {
            try {
              AbilityTargetSelector ats = (AbilityTargetSelector) cra;
              StringBuilder sb = new StringBuilder();
              sb.append(ats.getAbilityCategory().getLSTformat(false)).append(Constants.PIPE);
              sb.append(ats.getNature()).append(Constants.PIPE).append(cra.getLstFormat());
              List<Prerequisite> prereqs = ats.getPrerequisiteList();
              if (prereqs != null && !prereqs.isEmpty()) {
                sb.append(Constants.PIPE);
                sb.append(getPrerequisiteString(context, prereqs));
              }
              returnSet.add(sb.toString());
            } catch (PersistenceLayerException e) {
              context.addWriteMessage(getTokenName() + " encountered error: " + e.getMessage());
              return null;
            }
          }
        }
      }
    }
    if (returnSet.isEmpty()) {
      return null;
    }
    return returnSet.toArray(new String[returnSet.size()]);
  }
Exemple #9
0
  @Override
  public String[] unparse(LoadContext context, CDOMObject obj) {
    Set<String> returnSet = new TreeSet<String>();
    List<String> returnList = new ArrayList<String>();
    MapToList<List<Prerequisite>, CDOMReference<Ability>> m =
        new HashMapToList<List<Prerequisite>, CDOMReference<Ability>>();
    AbilityCategory category = AbilityCategory.FEAT;
    Nature nature = Nature.AUTOMATIC;

    CDOMReference<AbilityList> abilList = AbilityList.getAbilityListReference(category, nature);
    AssociatedChanges<CDOMReference<Ability>> changes =
        context.getListContext().getChangesInList(getFullName(), obj, abilList);
    Collection<CDOMReference<Ability>> 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;
      }
      returnList.add(Constants.LST_DOT_CLEAR);
    } else if (removedItems != null && !removedItems.isEmpty()) {
      returnList.add(
          Constants.LST_DOT_CLEAR_DOT
              + ReferenceUtilities.joinLstFormat(removedItems, "|.CLEAR.", true));
    }

    Changes<ChooseSelectionActor<?>> listChanges =
        context.getObjectContext().getListChanges(obj, ListKey.NEW_CHOOSE_ACTOR);
    Collection<ChooseSelectionActor<?>> listAdded = listChanges.getAdded();
    if (listAdded != null && !listAdded.isEmpty()) {
      for (ChooseSelectionActor<?> csa : listAdded) {
        if (csa.getSource().equals(SOURCE)) {
          try {
            returnList.add(csa.getLstFormat());
          } catch (PersistenceLayerException e) {
            context.addWriteMessage(getTokenName() + " encountered error: " + e.getMessage());
            return null;
          }
        }
      }
    }

    MapToList<CDOMReference<Ability>, AssociatedPrereqObject> mtl = changes.getAddedAssociations();
    if (mtl != null) {
      for (CDOMReference<Ability> ab : mtl.getKeySet()) {
        for (AssociatedPrereqObject assoc : mtl.getListFor(ab)) {
          m.addToListFor(assoc.getPrerequisiteList(), ab);
        }
      }
    }

    for (List<Prerequisite> prereqs : m.getKeySet()) {
      StringBuilder sb = new StringBuilder();
      sb.append(ReferenceUtilities.joinLstFormat(m.getListFor(prereqs), Constants.PIPE));
      if (prereqs != null && !prereqs.isEmpty()) {
        sb.append(Constants.PIPE);
        sb.append(getPrerequisiteString(context, prereqs));
      }
      returnSet.add(sb.toString());
    }
    returnList.addAll(returnSet);
    return returnList.toArray(new String[returnList.size()]);
  }