I’m at the point where complex prerequisites can be parsed and resolved.
Prerequisites: Spell Focus (conjuration) or Skill Focus (Spellcraft) and Alertness feat or Arcane Strike feat, Weapon Focus.
This is contrived — the original is just “Spell Focus (conjuration)”, but I wanted to see if I could do something more complicated… and I can.
The prerequisites above are parsed (Word file to XML) and split up on three grades of delimiter: ‘,’, ‘or’, and ‘and’. To qualify for this feat, you must have:
- One of
- Spell Focus (conjuration)
- both of
- Skill Focus (Spellcraft)
- Alertness
- Arcane Strike
- Weapon Focus
Basically, the process does:
- treats any element that is not a doc:text element, or is a doc:text element with ‘style’ or ‘format’ attribute, as an inviolable block: at all times it is carried through the process without modification (this lets me mark certain text blocks with styles that serve other purposes and have them not tampered with, including not being split apart by further steps);
- examine each eligible for bracketing characters (left paren, right paren, left bracket, right bracket) and split the text blocks on those delimiters [“this is a (test) string” -> “this is a “, ‘(‘, “test”, ‘)’, “string”];
- recursively nest (only one layer here) these to create ‘doc:paren’ objects containing parenthesized information, protecting text and other content within the parenthesized expressions from further tampering [this is a test string];
- do a similar delimitation on ‘\s*,\s*’ (unformatted text objects are split on ‘,’ surrounded on each side by zero or more spaces); each such group will be a prerequisite, output a and process that group inside the new element;
- inside the new element, delimit on ‘\s+or\s+’ (‘or’ with one or more spaces on each side); if any delimiters are found then there are multiple prerequisites inside the ‘new one’ (give it the ‘prereq-type=”or”‘ attribute), then for each group create a new child and process the group inside (splitting on ‘\s+and\s+’).
This gives me the nested hierarchy shown below. I then ran the entire thing against an index of parsed object names (and other stuff), looking for singular matches. You’ll notice the ‘Spell Focus’ has a style of ‘refFeat’ (manual markup in Word, carried through the parsing process to hint that the string here is a feat), so when resolving the link I looked only for feats. ‘Skill Focus’ resolved just fine (only one thing in the entire system is called ‘Skill Focus’), but initially ‘Alertness’ and ‘Arcane Strike’ did not: ‘Alertness’ is a feat and a black blade ability, “Arcane Strike” is a feat and a feature of the arcane duelist archetype). Appending ‘ feat’ to the prerequisite line turned them into “alertness feat” and “arcane strike feat” respectively, which each have a single match. It didn’t try to match ‘Spellcraft’ at all because it is not the primary focus of the prerequisite, the prerequisite linking engine doesn’t look at subordinate bits in parentheses, and the text was not marked as a reference. “Weapon Focus” didn’t resolve either because it is a feat and a feature of the kensai archetype (which in turn simply grants the Weapon Focus feat with the kensai’s chosen weapon… I will likely have rules for resolving ambiguities like this).
So… what do you do for fun?
This ends today’s peek at what goes into building the Echelon Reference Series. Stay tuned for how this gets turned into the diagrams illustrating the relationships between various game entities.