User:Aldyron/Sandbox/Template List of monsters in habitat

Chaotic notes
The namespace constraint is currently redundant. Keep it if querying time is lower with it.

Using Missing in Action as our work-in-progress target quest gives no results. Using The Grotto gives 1 result. It's the system-wide limit of 500 again: when querying the whole alphabetic-sorted list of monsters (WASLOM), no monster from Missing in Action appears in the first 500 (the first one is Dog, beyond the 500th in the WASLOM, currently Darkfang Hunter), while one monster from The Grotto is in the first 500 (Aging Sahuagin Warrior). That is, instead of querying everything and then limiting at 500, it queries at most 500 and then checks for matches. It will never be suitable this way. Showstopper.

Using Vault of Night yields a few results, useful for mixed-formats wrangling.

Eureka. Using linksto severely limits page selections to the few monsters that actually link to the quest. Less CPU load, less storage load, less time. Drawback: doesn't take redirects into account. Oh, well, I wanted to correct every link in every monster page anyway. :-)))

Must check that the link to the quest actually is in the habitat parameter, otherwise you get false positives (e.g.: Velah cites Vault of Night in the description parameter, but the monster is not in the quest).

Linked. Must provide for empty field values, otherwise we get. Employ phantom template. Update: done.

N.B.: Vault of Night should be The Vault of Night. It works anyway. Check for implications.

Using Missing in Action *and* Stealthy Repossession together, I'll have a Kobold Shaman for trying to make CR work.

I'm beginning to think Template:Infobox-monster is fundamentally flawed for what I have in mind. I currently have a "master" list of properties with optional quest-rows overriding some of the details quest-wise (and I'm possibly abusing the template while doing that). Adequate for Human readers, but not when you feed it to dpl. I think I need a database-like modular structure containing quest-rows with *all* properties but the monster's name. I may be wrong. Must mull. BTW, is it even *possible* to do it like that?

Staging area

 * |includematch = /the grotto/i
 * It works, but we need a much stricter check.
 * |includematch = /\x7c\s*habitat\s*=\s*[^\x7c]*Missing in Action/i
 * |includematch =    /     \x7c     \s*     habitat     \s*     =     \s*     [^\x7c]*     Missing in Action     /     i  (rewritten for clarity)
 * (slash) opens the regex
 * matches the pipe character, |
 * matches whitespace/tabs/newlines in any quantity, including zero quantity
 * matches any character except | in any quantity, including zero quantity
 * (slash) closes the regex
 * at the end is a PCRE Pattern Modifier for caseless matching (though I personally prefer caseful matching)

Coding
(see source)