diff --git a/inventory-service/main.py b/inventory-service/main.py index 3a78d2f4..4ff4f5a8 100644 --- a/inventory-service/main.py +++ b/inventory-service/main.py @@ -2865,6 +2865,10 @@ async def search_items( armor_only: bool = Query(False, description="Show only armor items"), jewelry_only: bool = Query(False, description="Show only jewelry items"), weapon_only: bool = Query(False, description="Show only weapon items"), + weapon_type: str = Query( + None, + description="Weapon sub-type filter: heavy, light, finesse, two_handed, bow, crossbow, thrown, caster", + ), clothing_only: bool = Query( False, description="Show only clothing items (shirts/pants)" ), @@ -3239,9 +3243,30 @@ async def search_items( conditions.append("object_class = 4") elif weapon_only: # Weapons: ObjectClass 1 (MeleeWeapon), 9 (MissileWeapon), 31 (WandStaffOrb) - conditions.append( - "object_class IN (1, 9, 31)" - ) + if weapon_type: + wt = weapon_type.lower() + # Skill-based: Heavy=44, Light=45, Finesse=46, TwoHanded=41 + if wt == 'heavy': + conditions.append("(object_class = 1 AND (rd.int_values->>'218103840')::int = 44)") + elif wt == 'light': + conditions.append("(object_class = 1 AND (rd.int_values->>'218103840')::int = 45)") + elif wt == 'finesse': + conditions.append("(object_class = 1 AND (rd.int_values->>'218103840')::int = 46)") + elif wt == 'two_handed': + conditions.append("(object_class = 1 AND (rd.int_values->>'218103840')::int = 41)") + # Name-based missile sub-types + elif wt == 'bow': + conditions.append("(object_class = 9 AND name ILIKE '%bow%' AND name NOT ILIKE '%crossbow%')") + elif wt == 'crossbow': + conditions.append("(object_class = 9 AND name ILIKE '%crossbow%')") + elif wt == 'thrown': + conditions.append("(object_class = 9 AND (name ILIKE '%atlatl%' OR name ILIKE '%throwing%' OR name ILIKE '%javelin%' OR name ILIKE '%shuriken%' OR name ILIKE '%dart%' OR name ILIKE '%slingshot%'))") + elif wt == 'caster': + conditions.append("object_class = 31") + else: + conditions.append("object_class IN (1, 9, 31)") + else: + conditions.append("object_class IN (1, 9, 31)") elif clothing_only: # Clothing: ObjectClass 3 (Clothing) - shirts and pants only, exclude cloaks and robes # Focus on underclothes: shirts, pants, breeches, etc. diff --git a/static/inventory.html b/static/inventory.html index 8cf513ba..2f217965 100644 --- a/static/inventory.html +++ b/static/inventory.html @@ -552,6 +552,20 @@ +