Bug - Fixed Command "drink soft green" not working as expected

Zeferis

New member
Using command "drink soft green" in cli results in mafia attempting to drink a Soft Green Echo Eyedrop Antidote and failing instead of drinking a Soft Green Echo Eyedrop Antidote Martini
Tested in version 12219
 

Winterbay

Active member
So type "drink soft martini" or "drink soft green martini" instead? It's intended behaviour of fuzzy item matching and most likely not worth chaning.
 

lostcalpolydude

Developer
Staff member
UseItemCommand has ItemFinder.setMatchType( ItemFinder.BOOZE_MATCH ); before the getMatchingItemList() call, so I don't understand how this is happening, but I'm seeing the same result. For future reference, please post the exact error message you get (when there's one conveniently provided by mafia) instead of just saying that it failed.
 

Veracity

Developer
Staff member
ItemFinder.getFirstMatchingItemName( List<String> nameList, String searchString, int filterType ) does this:

// If there are multiple matches, such that one is a substring of the
// others, choose the shorter one, on the grounds that the user would
// have included part of the unique section of the longer name if that
// was the item they actually intended. This makes it easier to refer
// to non-clockwork in-a-boxes, and DoD potions by flavor.

BEFORE applying the filter. If this results in a single match, it is returned.
It then filters, and then it does exactly the same check again.

Net result is that when the list is:

soft green echo eyedrop antidote
soft green echo eyedrop antidote martini

the long name gets dropped before the filtering happens, and, since there is only one item left, it is returned, even though the remaining item will not pass the filtering.

Clearly, it needs to filter first. That would simplify that function. I'll look at it...
 
Top