@@ -9,6 +9,7 @@ local curl = require("lcurl.safe")
99local m_max = math.max
1010local s_format = string.format
1111local t_insert = table.insert
12+ local tradeHelpers = LoadModule (" Classes/CompareTradeHelpers" )
1213
1314-- TODO generate these from data files
1415local itemCategoryTags = {
@@ -762,103 +763,25 @@ function TradeQueryGeneratorClass:StartQuery(slot, options)
762763 itemCategory = " AnyJewel"
763764 itemCategoryQueryStr = " jewel"
764765 end
765- elseif slot .slotName :find (" ^Weapon %d" ) then
766- if existingItem then
767- if existingItem .type == " Shield" then
768- itemCategoryQueryStr = " armour.shield"
769- itemCategory = " Shield"
770- elseif existingItem .type == " Quiver" then
771- itemCategoryQueryStr = " armour.quiver"
772- itemCategory = " Quiver"
773- elseif existingItem .type == " Bow" then
774- itemCategoryQueryStr = " weapon.bow"
775- itemCategory = " Bow"
776- elseif existingItem .type == " Staff" then
777- itemCategoryQueryStr = " weapon.staff"
778- itemCategory = " Staff"
779- elseif existingItem .type == " Two Handed Sword" then
780- itemCategoryQueryStr = " weapon.twosword"
781- itemCategory = " 2HSword"
782- elseif existingItem .type == " Two Handed Axe" then
783- itemCategoryQueryStr = " weapon.twoaxe"
784- itemCategory = " 2HAxe"
785- elseif existingItem .type == " Two Handed Mace" then
786- itemCategoryQueryStr = " weapon.twomace"
787- itemCategory = " 2HMace"
788- elseif existingItem .type == " Fishing Rod" then
789- itemCategoryQueryStr = " weapon.rod"
790- itemCategory = " FishingRod"
791- elseif existingItem .type == " One Handed Sword" then
792- itemCategoryQueryStr = " weapon.onesword"
793- itemCategory = " 1HSword"
794- elseif existingItem .type == " One Handed Axe" then
795- itemCategoryQueryStr = " weapon.oneaxe"
796- itemCategory = " 1HAxe"
797- elseif existingItem .type == " One Handed Mace" or existingItem .type == " Sceptre" then
798- itemCategoryQueryStr = " weapon.onemace"
799- itemCategory = " 1HMace"
800- elseif existingItem .type == " Wand" then
801- itemCategoryQueryStr = " weapon.wand"
802- itemCategory = " Wand"
803- elseif existingItem .type == " Dagger" then
804- itemCategoryQueryStr = " weapon.dagger"
805- itemCategory = " Dagger"
806- elseif existingItem .type == " Claw" then
807- itemCategoryQueryStr = " weapon.claw"
808- itemCategory = " Claw"
809- elseif existingItem .type :find (" Two Handed" ) ~= nil then
810- itemCategoryQueryStr = " weapon.twomelee"
811- itemCategory = " 2HWeapon"
812- elseif existingItem .type :find (" One Handed" ) ~= nil then
813- itemCategoryQueryStr = " weapon.one"
814- itemCategory = " 1HWeapon"
766+ else
767+ itemCategoryQueryStr , itemCategory = tradeHelpers .getTradeCategoryInfo (slot .slotName , existingItem )
768+
769+ -- Generic Jewel slot: caller selects the jewel subtype.
770+ if slot .slotName :find (" Jewel" ) ~= nil and not slot .slotName :find (" Abyssal" ) then
771+ itemCategory = options .jewelType .. " Jewel"
772+ if itemCategory == " AbyssJewel" then
773+ itemCategoryQueryStr = " jewel.abyss"
774+ elseif itemCategory == " BaseJewel" then
775+ itemCategoryQueryStr = " jewel.base"
815776 else
816- logToFile (" '%s' is not supported for weighted trade query generation" , existingItem .type )
817- return
777+ itemCategoryQueryStr = " jewel"
818778 end
819- else
820- -- Item does not exist in this slot so assume 1H weapon
821- itemCategoryQueryStr = " weapon.one"
822- itemCategory = " 1HWeapon"
823779 end
824- elseif slot .slotName == " Body Armour" then
825- itemCategoryQueryStr = " armour.chest"
826- itemCategory = " Chest"
827- elseif slot .slotName == " Helmet" then
828- itemCategoryQueryStr = " armour.helmet"
829- itemCategory = " Helmet"
830- elseif slot .slotName == " Gloves" then
831- itemCategoryQueryStr = " armour.gloves"
832- itemCategory = " Gloves"
833- elseif slot .slotName == " Boots" then
834- itemCategoryQueryStr = " armour.boots"
835- itemCategory = " Boots"
836- elseif slot .slotName == " Amulet" then
837- itemCategoryQueryStr = " accessory.amulet"
838- itemCategory = " Amulet"
839- elseif slot .slotName == " Ring 1" or slot .slotName == " Ring 2" or slot .slotName == " Ring 3" then
840- itemCategoryQueryStr = " accessory.ring"
841- itemCategory = " Ring"
842- elseif slot .slotName == " Belt" then
843- itemCategoryQueryStr = " accessory.belt"
844- itemCategory = " Belt"
845- elseif slot .slotName :find (" Abyssal" ) ~= nil then
846- itemCategoryQueryStr = " jewel.abyss"
847- itemCategory = " AbyssJewel"
848- elseif slot .slotName :find (" Jewel" ) ~= nil then
849- itemCategoryQueryStr = " jewel"
850- itemCategory = options .jewelType .. " Jewel"
851- if itemCategory == " AbyssJewel" then
852- itemCategoryQueryStr = " jewel.abyss"
853- elseif itemCategory == " BaseJewel" then
854- itemCategoryQueryStr = " jewel.base"
780+
781+ if not itemCategoryQueryStr then
782+ logToFile (" '%s' is not supported for weighted trade query generation" , existingItem and existingItem .type or " n/a" )
783+ return
855784 end
856- elseif slot .slotName :find (" Flask" ) ~= nil then
857- itemCategoryQueryStr = " flask"
858- itemCategory = " Flask"
859- else
860- logToFile (" '%s' is not supported for weighted trade query generation" , existingItem and existingItem .type or " n/a" )
861- return
862785 end
863786
864787 -- Create a temp item for the slot with no mods
0 commit comments