(LoadContext context, Spell spell)
| 214 | } |
| 215 | |
| 216 | @Override |
| 217 | public String[] unparse(LoadContext context, Spell spell) |
| 218 | { |
| 219 | DoubleKeyMapToList<Prerequisite, Integer, CDOMReference<ClassSpellList>> dkmtl = new DoubleKeyMapToList<>(); |
| 220 | List<String> list = new ArrayList<>(); |
| 221 | Changes<CDOMReference<ClassSpellList>> masterChanges = |
| 222 | context.getListContext().getMasterListChanges(getTokenName(), spell, SPELLLIST_CLASS); |
| 223 | if (masterChanges.includesGlobalClear()) |
| 224 | { |
| 225 | list.add(Constants.LST_DOT_CLEAR_ALL); |
| 226 | } |
| 227 | if (masterChanges.hasRemovedItems()) |
| 228 | { |
| 229 | for (CDOMReference<ClassSpellList> swl : masterChanges.getRemoved()) |
| 230 | { |
| 231 | AssociatedChanges<Spell> changes = |
| 232 | context.getListContext().getChangesInMasterList(getTokenName(), spell, swl); |
| 233 | MapToList<Spell, AssociatedPrereqObject> map = changes.getRemovedAssociations(); |
| 234 | if (map != null && !map.isEmpty()) |
| 235 | { |
| 236 | for (Spell added : map.getKeySet()) |
| 237 | { |
| 238 | if (!spell.getKeyName().equals(added.getKeyName())) |
| 239 | { |
| 240 | context.addWriteMessage("Spell " + getTokenName() + " token cannot remove another Spell " |
| 241 | + "(must only remove itself)"); |
| 242 | return null; |
| 243 | } |
| 244 | for (AssociatedPrereqObject assoc : map.getListFor(added)) |
| 245 | { |
| 246 | List<Prerequisite> prereqs = assoc.getPrerequisiteList(); |
| 247 | if (prereqs != null && !prereqs.isEmpty()) |
| 248 | { |
| 249 | context.addWriteMessage("Incoming Remove " + "Edge to " + spell.getKeyName() + " had a " |
| 250 | + "Prerequisite: " + prereqs.size()); |
| 251 | return null; |
| 252 | } |
| 253 | dkmtl.addToListFor(null, -1, swl); |
| 254 | } |
| 255 | } |
| 256 | } |
| 257 | } |
| 258 | } |
| 259 | for (CDOMReference<ClassSpellList> swl : masterChanges.getAdded()) |
| 260 | { |
| 261 | AssociatedChanges<Spell> changes = |
| 262 | context.getListContext().getChangesInMasterList(getTokenName(), spell, swl); |
| 263 | Collection<Spell> removedItems = changes.getRemoved(); |
| 264 | if (removedItems != null && !removedItems.isEmpty() || changes.includesGlobalClear()) |
| 265 | { |
| 266 | context.addWriteMessage(getTokenName() + " does not support .CLEAR."); |
| 267 | return null; |
| 268 | } |
| 269 | MapToList<Spell, AssociatedPrereqObject> map = changes.getAddedAssociations(); |
| 270 | if (map != null && !map.isEmpty()) |
| 271 | { |
| 272 | for (Spell added : map.getKeySet()) |
| 273 | { |
nothing calls this directly
no test coverage detected