feat: add weapon type filter (heavy, light, finesse, 2H, bow, crossbow, thrown, caster)

Backend: new weapon_type query parameter on /search/items.
Uses skill ID from IntValues[218103840] for melee types (Heavy=44,
Light=45, Finesse=46, TwoHanded=41) and name matching for missile
sub-types (bow, crossbow, thrown). Caster = ObjectClass 31.

Frontend: dropdown appears when "Weapons" radio selected, hidden otherwise.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Erik 2026-04-08 17:41:07 +02:00
parent 35a11d0cf1
commit 9749eafde4
3 changed files with 60 additions and 4 deletions

View file

@ -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.