OK, I did a large amount of work to enable this. Revision 16163 does this:
- For all "problematic" monsters - ones which have an ID of 0 which we previously did not disambiguate - there are now monsters with distinct names and the expected monster ID.
ancient protector spirit( The Hidden Apartment Building)
ancient protector spirit( The Hidden Bowling Alley)
ancient protector spirit( The Hidden Hospital)
ancient protector spirit( The Hidden Office Building)
batwinged gremlin (tool)
clingy pirate (female)
clingy pirate (male)
erudite gremlin (tool)
spider gremlin (tool)
vegetable gremlin (tool)
Ninja Snowman (Hilt)
Ninja Snowman (Mask )
bizarre construct (translated)
hulking construct (translated)
industrious construct (translated)
lonely construct (translated)
menacing construct (translated)
towering construct (translated)
animated nightstand (White 1)
animated nightstand (Mahogany 1)
animated nightstand (White 2)
animated nightstand (Mahogany 2)
Note that those names all have a name which differs from Manuel's name. So do many other monsters, so:
- Monsters whose KoLmafia name does not agree with Manuel's name - because they require disambiguation; otherwise, we change our names to agree - now have a Manuel: "NAME" annotation in monsters.txt.
- There is a corresponding $monster proxy field in ASH: string .manuel_name will be the name you look up the monster in Manuel with. That will be either the monster's name, or the name specified as above.
We want to observe and cache info when you look at Manuel pages
- MonsterManuelRequest is an internal class to look up a specific page, or look up the page that a particular monster ID will be on, based on the manuel_name, as specified above. When you use this request class internally - or look at Manuel in the Relay Browser - be parse the response and pass each Manuel entry to:
- MonsterManuelManager keeps a cache of what we have observed in Manuel. It keeps two maps:
ID -> STRING - maps monster ID to the cached Manuel entry HTML text
IS - INT - is the number of factoids in the currently cached text for this monster ID
So, how do we manage this?
- When you log out and log in as a new user, we flush those maps for all IDs which have fewer than 3 factoids saved; if you have 3 factoids, there will be no difference, no matter the character. If you have less than 3, the new character might have better factoids.
- When you learn a factoid in battle, we flush the entries for the current monster; you will have to revisit Manuel to get it again, with the new factoid.
There are two ASH functions to access the above caches
int monster_factoids_available ( monster )
how many factoids are in the currently cached HTML text for the monster
string monster_manuel_text( monster )
the saved HTML for the monster
Both of the above will query the cache, first. If present, it returns the value, with no server hits. If not present, it attempts to look up the Manuel data for the monster - which will load that (and all he other monsters on the same page ) into the cache.
That last function could be helpful for scripts like missingManuel: you can choose to get the text every monster whose id is non-zero, rather than looking up every page of manuel and parsing out the monsters and doing all sorts of heuristics to disambiguate the monster into KoLmafia's name for the monster.
I don't know; it might still want to lookup every page, first, because Manuel might have new monsters in it - and when we look at the page, MonsterManuelManager will add dummy monsters to the internal ID -> MonsterData map for each monster it sees with an unrecognized ID. I'm not sure how an ASH program would find out which monsters those were, although we will log them to the gCLI - which will be a signal to KoLmafia devs to update monsters.txt
- I added checkManuel, which will look at every Manuel page and let MonsterManuelManager cache all the data - including registering unknown monsters, as above. Here is what I get when I run it:
> checkmanuel
Checking Monster Manuel...
Page A
Page B
Page C
Page D
Page E
Page F
Page G
Page H
Page I
Page J
Page K
Page L
Page M
Monster #1667 has name 'Your winged yeti' but Manuel calls it 'Mraderick'
Page N
Page O
Page P
Page Q
Page R
Page S
Page T
Page U
Page V
Monster #1669 has name 'You the Adventurer' but Manuel calls it 'Veracity the Adventurer'
Page W
Page X
Page Y
Page Z
Page -
Monster Manuel checked.
That was how I figured out which monsters needed Manuel: attributes in monsters.txt.
That reminds me - we need to flush Manuel data for those two monster IDs when you log in as a new player.
Just for fun, type this into the gCLI:
ash monster_manuel_text( $monster[ writing desk ] )
(or the monster of your choice).
I think you can see how we could use something like that in our own popup from the Encyclopedia, were we to add Monsters.