MCPcopy Create free account
hub / github.com/PCGen/pcgen / unparse

Method unparse

code/src/java/plugin/lsttokens/race/MoncskillToken.java:185–260  ·  view source on GitHub ↗
(LoadContext context, Race race)

Source from the content-addressed store, hash-verified

183 }
184
185 @Override
186 public String[] unparse(LoadContext context, Race race)
187 {
188 CDOMGroupRef<ClassSkillList> monsterList =
189 context.getReferenceContext().getCDOMTypeReference(ClassSkillList.class, "Monster");
190 AssociatedChanges<CDOMReference<Skill>> changes =
191 context.getListContext().getChangesInList(getTokenName(), race, monsterList);
192 Changes<ChooseSelectionActor<?>> listChanges =
193 context.getObjectContext().getListChanges(race, ListKey.NEW_CHOOSE_ACTOR);
194 List<String> list = new ArrayList<>();
195 Collection<CDOMReference<Skill>> removedItems = changes.getRemoved();
196 if (removedItems != null && !removedItems.isEmpty())
197 {
198 if (changes.includesGlobalClear())
199 {
200 context.addWriteMessage(
201 "Non-sensical relationship in " + getTokenName() + ": global .CLEAR and local .CLEAR. performed");
202 return null;
203 }
204 list.add(Constants.LST_DOT_CLEAR_DOT + ReferenceUtilities.joinLstFormat(removedItems, "|.CLEAR."));
205 }
206 Collection<ChooseSelectionActor<?>> listRemoved = listChanges.getRemoved();
207 if (listRemoved != null && !listRemoved.isEmpty())
208 {
209 if (listRemoved.contains(this))
210 {
211 list.add(".CLEAR.LIST");
212 }
213 }
214 if (changes.includesGlobalClear())
215 {
216 list.add(Constants.LST_DOT_CLEAR);
217 }
218 MapToList<CDOMReference<Skill>, AssociatedPrereqObject> map = changes.getAddedAssociations();
219 if (map != null && !map.isEmpty())
220 {
221 Set<CDOMReference<Skill>> added = map.getKeySet();
222 for (CDOMReference<Skill> ab : added)
223 {
224 for (AssociatedPrereqObject assoc : map.getListFor(ab))
225 {
226 if (!SkillCost.CLASS.equals(assoc.getAssociation(AssociationKey.SKILL_COST)))
227 {
228 context.addWriteMessage("Skill Cost must be " + "CLASS for Token " + getTokenName());
229 return null;
230 }
231 }
232 }
233 list.add(ReferenceUtilities.joinLstFormat(added, Constants.PIPE));
234 }
235 Collection<ChooseSelectionActor<?>> listAdded = listChanges.getAdded();
236 if (listAdded != null && !listAdded.isEmpty())
237 {
238 for (ChooseSelectionActor<?> csa : listAdded)
239 {
240 if (csa.getSource().equals(getTokenName()))
241 {
242 try

Callers

nothing calls this directly

Calls 15

getTokenNameMethod · 0.95
joinLstFormatMethod · 0.95
getCDOMTypeReferenceMethod · 0.80
getReferenceContextMethod · 0.65
getChangesInListMethod · 0.65
getListContextMethod · 0.65
getListChangesMethod · 0.65
getObjectContextMethod · 0.65
getRemovedMethod · 0.65
isEmptyMethod · 0.65
includesGlobalClearMethod · 0.65
addWriteMessageMethod · 0.65

Tested by

no test coverage detected