import { STAT_GROUPS , StatGroup } from "../../../game-data" ; import { Modifier } from "../types/Modifier" ; import { describeSingleMod } from "./describeSingleMod" ; /**
 * Creates "custom" mods to track groups of mods that should be searched or displayed together:
 * all resistances, damage ranges, poison damage, etc.
 */ function addGroup ( group , allModifiers ) { const mods = allModifiers ?. filter ( ( { id } ) => group . statsInGroup . includes ( id ) ) ?? [ ] ; if ( mods . length !== group . statsInGroup . length ) { return false ; } if ( group . allEqual && mods . some ( ( { value } ) => value !== mods [ 0 ] . value ) ) { return false ; } if ( group . isRange && ( mods [ 0 ] . value ?? 0 ) > ( mods [ 1 ] . value ?? 0 ) ) { return false ; } if ( group . stat === "group:secondary-dmg" || group . stat === "group:min-dmg" || group . stat === "group:max-dmg" ) { if ( allModifiers ?. find ( ( mod ) => mod . stat === "group:primary-dmg" ) ) { for ( const mod of mods ) { delete mod . description ; } return false ; } } const extraMod = { id : - 1 , stat : group . stat , priority : group . descPriority , value : group . allEqual ? mods [ 0 ] . value : undefined , values : mods . map ( ( { value } ) => value ?? 0 ) , } ; extraMod . description = describeSingleMod ( extraMod , group ) ; if ( group . allEqual ) { extraMod . range = mods [ 0 ] . range ; } allModifiers ?. push ( extraMod ) ; for ( const mod of mods ) { delete mod . description ; } return true ; } export function addModGroups ( modifiers ) { for ( const group of STAT_GROUPS ) { addGroup ( group , modifiers ) ; } }