What I’m trying to do
I’m making a fairly elaborate DnD character sheet setup with Bases and using a series of formulas to aggregate different active sources of modifications to certain Skills.
My starting point for what I need to do is a list with entries in the following format: Skill | Modifier
Here’s a copy of the current list output from Skills Compiled shown in the screenshot.
["Acrobatics | ADV", "Acrobatics | DIS", "Arcana | Proficiency", "Athletics | Expertise", "Athletics | Proficiency", "Deception | DIS", "Deception | Expertise"]
Because they can all come in from different sources at any of those modifier values (ADV, DIS, Proficiency, and Expertise), it’s important for them to start separately, but eventually I need them consolidated all in one place.
You can see where I have multiple entries per Skill; I’d like to be able find a way to map/filter/reduce this list so that it merges the modifiers of Skills which share the same value before the bar. For instance, in the example above, I’m trying to get Acrobatics | ADV and Acrobatics | DIS to become Acrobatics | ADV, DIS and Deception | Expertise & Deception | DIS to become Deception | Expertise, DIS (the commas aren’t necessary per se, but they are readable).
The goal is to fold the values together per Skill so that some more logic can be applied (e.g. if the same value contains ADV & DIS, cancel them out from the final compilation; and if the same value contains “Proficiency” & “Expertise,” just show Expertise). I think I know how to handle that part of it all, however, once I get the entries into the proper format.
Bear in mind that in theory any given Skill value could contain any/all of those 4 values, and that some Skill names are multiple words long like Animal Handling or Sleight of Hand.
Things I have tried
I’ve been scratching my head at this for a while trying things, and the closest I could get was something like the following, but although it helps remove the duplicate Skill items and preserves the order…the result is just a disconnected list, not one grouped by Skill anymore:
this.formula["Skills Compiled"].map(value.split(" | ").slice(0,-1)+value.split(" | ").slice(-1)).flat().unique().join(", ")
Returns Acrobatics, ADV, DIS, Arcana, Proficiency, Athletics, Expertise, Deception …not sure if that’s helpful, but it shows I tried first?!
Much obliged!

