@@ -159,6 +159,59 @@ function M.findTradeHash(item, modLine, modType, isDesecrated)
159159 end
160160end
161161
162+ -- Map slot name + item type to (trade API category string, itemCategoryTags key).
163+ -- queryStr: e.g. "armour.shield", "weapon.onemace"
164+ -- categoryLabel: e.g. "Shield", "1HMace", "1HWeapon" (nil for flask / generic jewel / unsupported)
165+ --- @param slotName string
166+ --- @param item table
167+ function M .getTradeCategory (slotName , item )
168+ if not slotName then return nil , nil end
169+ local itemType = item and (item .type or (item .base and item .base .type ))
170+ if slotName :find (" ^Weapon %d" ) then
171+ if not itemType then return " weapon.one" , " 1HWeapon" end
172+ if itemType == " Shield" then return " armour.shield" , " Shield"
173+ elseif itemType == " Focus" then return " armour.focus" , " Focus"
174+ elseif itemType == " Buckler" then return " armour.buckler" , " Buckler"
175+ elseif itemType == " Quiver" then return " armour.quiver" , " Quiver"
176+ elseif itemType == " Bow" then return " weapon.bow" , " Bow"
177+ elseif itemType == " Crossbow" then return " weapon.crossbow" , " Crossbow"
178+ elseif itemType == " Talisman" then return " weapon.talisman" , " Talisman"
179+ elseif itemType == " Staff" and item .base .subType == " Warstaff" then return " weapon.warstaff" , " Quarterstaff"
180+ elseif itemType == " Staff" then return " weapon.staff" , " Staff"
181+ elseif itemType == " Two Hand Sword" then return " weapon.twosword" , " 2HSword"
182+ elseif itemType == " Two Hand Axe" then return " weapon.twoaxe" , " 2HAxe"
183+ elseif itemType == " Two Hand Mace" then return " weapon.twomace" , " 2HMace"
184+ elseif itemType == " Fishing Rod" then return " weapon.rod" , " FishingRod"
185+ elseif itemType == " One Hand Sword" then return " weapon.onesword" , " 1HSword"
186+ elseif itemType == " Spear" then return " weapon.spear" , " Spear"
187+ elseif itemType == " Flail" then return " weapon.flail" , " weapon.flail"
188+ elseif itemType == " One Hand Axe" then return " weapon.oneaxe" , " 1HAxe"
189+ elseif itemType == " One Hand Mace" then return " weapon.onemace" , " 1HMace"
190+ elseif itemType == " Sceptre" then return " weapon.sceptre" , " Sceptre"
191+ elseif itemType == " Wand" then return " weapon.wand" , " Wand"
192+ elseif itemType == " Dagger" then return " weapon.dagger" , " Dagger"
193+ elseif itemType == " Claw" then return " weapon.claw" , " Claw"
194+ elseif itemType :find (" Two Hand" ) then return " weapon.twomelee" , " 2HWeapon"
195+ elseif itemType :find (" One Hand" ) then return " weapon.one" , " 1HWeapon"
196+ else
197+ return nil , nil
198+ end
199+ elseif slotName == " Body Armour" then return " armour.chest" , " Chest"
200+ elseif slotName == " Helmet" then return " armour.helmet" , " Helmet"
201+ elseif slotName == " Gloves" then return " armour.gloves" , " Gloves"
202+ elseif slotName == " Boots" then return " armour.boots" , " Boots"
203+ elseif slotName == " Amulet" then return " accessory.amulet" , " Amulet"
204+ elseif slotName == " Ring 1" or slotName == " Ring 2" or slotName == " Ring 3" then return " accessory.ring" , " Ring"
205+ elseif slotName == " Belt" then return " accessory.belt" , " Belt"
206+ elseif slotName :find (" Jewel" ) then return " jewel" , " Jewel"
207+ elseif slotName :find (" Flask 1" ) then return " flask.life" , " Life Flask"
208+ elseif slotName :find (" Flask 2" ) then return " flask.mana" , " Mana Flask"
209+ -- these don't have a unique string so overlapping mods of the same benefit could interfere. , "Charm"
210+ elseif slotName :find (" Charm" ) ~= nil then return " flask"
211+ else return nil , nil
212+ end
213+ end
214+
162215-- Helper: get a display-friendly category name from slot name
163216function M .getTradeCategoryLabel (slotName , item )
164217 if not item or not item .base then return " Item" end
0 commit comments