use of pcgen.cdom.enumeration.AssociationKey in project pcgen by PCGen.
the class SpellsLst method processAdds.
private Collection<? extends String> processAdds(LoadContext context, MapToList<CDOMReference<Spell>, AssociatedPrereqObject> mtl) {
TripleKeyMap<Set<Prerequisite>, Map<AssociationKey<?>, Object>, CDOMReference<Spell>, String> m = new TripleKeyMap<>();
for (CDOMReference<Spell> lw : mtl.getKeySet()) {
for (AssociatedPrereqObject assoc : mtl.getListFor(lw)) {
Map<AssociationKey<?>, Object> am = new HashMap<>();
String dc = null;
for (AssociationKey<?> ak : assoc.getAssociationKeys()) {
// else
if (AssociationKey.DC_FORMULA.equals(ak)) {
dc = assoc.getAssociation(AssociationKey.DC_FORMULA);
} else {
am.put(ak, assoc.getAssociation(ak));
}
}
m.put(new HashSet<>(assoc.getPrerequisiteList()), am, lw, dc);
}
}
Set<String> set = new TreeSet<>();
for (Set<Prerequisite> prereqs : m.getKeySet()) {
for (Map<AssociationKey<?>, Object> am : m.getSecondaryKeySet(prereqs)) {
StringBuilder sb = new StringBuilder();
sb.append(am.get(AssociationKey.SPELLBOOK));
Formula times = AssociationKey.TIMES_PER_UNIT.cast(am.get(AssociationKey.TIMES_PER_UNIT));
sb.append(Constants.PIPE).append("TIMES=").append(times);
String timeunit = AssociationKey.TIME_UNIT.cast(am.get(AssociationKey.TIME_UNIT));
if (timeunit != null) {
sb.append(Constants.PIPE).append("TIMEUNIT=").append(timeunit);
}
String casterLvl = AssociationKey.CASTER_LEVEL.cast(am.get(AssociationKey.CASTER_LEVEL));
if (casterLvl != null) {
sb.append(Constants.PIPE).append("CASTERLEVEL=").append(casterLvl);
}
Set<String> spellSet = new TreeSet<>();
for (CDOMReference<Spell> spell : m.getTertiaryKeySet(prereqs, am)) {
String spellString = spell.getLSTformat(false);
String dc = m.get(prereqs, am, spell);
if (dc != null) {
spellString += Constants.COMMA + dc;
}
spellSet.add(spellString);
}
sb.append(Constants.PIPE);
sb.append(StringUtil.join(spellSet, Constants.PIPE));
if (prereqs != null && !prereqs.isEmpty()) {
sb.append(Constants.PIPE);
sb.append(getPrerequisiteString(context, prereqs));
}
set.add(sb.toString());
}
}
return set;
}
Aggregations