Quite clear now. I can see why you need to make use of mafia's fuzzy matching to convert text into items. That's necessary in order to check the slots that the items occupy, not just to use the equip command.
Veracity, what do you think about creating that fuzzy_match() function so that he can do a EQUIP_MATCH to ensure he matches equipment? It would improve his chances of matching the right item. He's got an actual implementation for it, after all. No doubt that is the reason equip will match "mayfly" to the necklace even though to_item("mayfly") will match it to the packet. That's just not good enough for his needs.
I've been thinking about this again, now that I have thinking about the "eat" and "drink" commands needing to be able to match on consumables, not items.
The way our fuzzy matching works, we require a sorted array of "canonical names" - lower cased, etc. Given those names, we need to be able to map them back to the "real" name. So, when searching items, if you have "game token", that should match to "game grid token" in the item array, and you'll get back "Game Grid token".
So, what about Darzil's current project to allow item numbers rather than item names? Without that, what should you get when you search for "Staff of Ed"? I don't have an answer, yet, but am watching how it develops.
The thing is, we could & should have multiple "canonical name arrays" - one for each kind of fuzzy matching we want to do. Additionally, we may want to filter the results of such a match, depending on the purpose. Here are some examples:
"item" - search all items, no filter
"inventory" - search all items, filter on inventory
"closet" - search all items, filter on closet
"storage" - search all items, filter on storage.
"accessible" - search all items, filter on those which "is_accessible" matches - inventory, closet (if use closet is allowed), storage (if not Hardcore or Ronin), and so on.
So, the "pull" command would do a "storage" search - any item is allowed, but those not currently in storage will not cause ambiguity. The "closet take" command does a "closet" search, the "closet put" or "autosell" do an "inventory" search, and so on.
"use" needs "accessible", since it will "acquire"
How about subsets of items?
"equipment" - have a smaller "canonical" array with just equipment, or is this a filter?
"hat", "pants", "weapon", "off-hand", "shirt", "back", "accessory", "familiar item" - filters, I assume
"equip" wants the "equipment" matcher and the "acquirale" filter.
How about consumables?
"food", "drink", "spleen" - for use by "eat", "drink", and "chew" commands. These are not just items! It will be nice to have food items + chez snootee + hot dogs + sushi all be matchable.
Non-items?
"skill" - for "cast"
"familiar" - for "familiar"
"thrall", "servant", ...
"outfit"
"effect" - for "uneffect" or "up".
What about "creatable", for concoctions?
So, perhaps we want three arguments:
table: "item", "skill", "effect", "familiar", "thrall", "servant", "equipment", "food", "drink", "spleen"
filter: "accessory", "hat", ... (for the "equipment" or "item" tables)
location: "accessible", "inventory", "closet", "storage" (with "any" as default") (for the "equipment" or "item" tables).
I'm going to work on adding "canonical name" arrays for consumables, soon, so that "eat" will be able to find sushi, for example. I expect that regularizing the fuzzy matching library - which is currently partly in StringUtilities and partly in ItemFinder - will be a natural followup to (or part of) this. And then fixing the CLI commands to use it appropriately, and adding the ASH facility.
There's more design to be done, first.
And comments from y'all, here.
