// Compact defensive-equipment metrics derived from forge compositions. #import "../../chapters/craft/forge-data.typ": equipments #let defense-category-labels = (Armors: "Armure", Shields: "Bouclier") #let defense-nature-labels = ( Light: "Léger", Medium: "Moyen", Heavy: "Lourd", SuperHeavy: "Super-lourd", ) #let minimum-torque(item) = { let available = (item.torque_one_handed, item.torque_two_handed).filter( value => value != none, ) if available.len() == 0 { none } else { calc.min(..available) } } #let defensive-equipment = ( equipments .filter(item => ( item.apply_category in ("Armors", "Shields") )) .map(item => ( name: defense-category-labels.at(item.apply_category) + " · " + defense-nature-labels.at(item.nature_category), category: item.apply_category, category-label: defense-category-labels.at(item.apply_category), nature: item.nature_category, nature-label: defense-nature-labels.at(item.nature_category), protection: item.protection, integrity: item.integrity, parry: item.parry, torque-one: item.torque_one_handed, torque-two: item.torque_two_handed, torque: minimum-torque(item), source: item, )) ) #let all-equipment-efficiency = ( equipments .filter(item => ( item.apply_category in ("Weapons", "Armors", "Shields") )) .map(item => ( name: item.name, category: item.apply_category, protection: item.protection, torque: minimum-torque(item), )) .filter(item => item.torque != none and item.torque > 0) ) #let defense-leader(key, filter: item => true) = ( defensive-equipment .filter(filter) .sorted( key: item => if key == "torque" { item.at(key) } else { -item.at(key) }, ) .first() ) #let protection-leader = defense-leader("protection") #let integrity-leader = defense-leader("integrity") #let parry-leader = defense-leader("parry") #let torque-leader = defense-leader("torque") #let defense-efficiency(item, key) = if item.torque == 0 { 0 } else { item.at(key) / item.torque } #let protection-efficiency-leader = ( defensive-equipment .sorted( key: item => -defense-efficiency(item, "protection"), ) .first() ) #let global-protection-efficiency-leader = ( all-equipment-efficiency .sorted( key: item => -(item.protection / item.torque), ) .first() )