-- Slightly lower armor bases so end-of-fight hero HP% stays within gear-check (75% cap) when
-- Legendary primary is +40% vs Common; weapon primaries unchanged.
UPDATE public.armor SET defense = CASE type
    WHEN 'light' THEN 2
    WHEN 'medium' THEN 4
    WHEN 'heavy' THEN 10
END;

UPDATE public.gear AS g
SET
    base_primary = a.defense,
    primary_stat = ROUND(a.defense * CASE a.rarity
        WHEN 'common' THEN 1.0
        WHEN 'uncommon' THEN 1.0877573
        WHEN 'rare' THEN 1.1832160
        WHEN 'epic' THEN 1.2870518
        WHEN 'legendary' THEN 1.40
    END)::integer
FROM public.armor AS a
WHERE g.slot = 'chest'
  AND g.name = a.name;
