diff --git a/docs/DESIGN_SYSTEM.md b/docs/DESIGN_SYSTEM.md index 687ea9b..46a4b56 100644 --- a/docs/DESIGN_SYSTEM.md +++ b/docs/DESIGN_SYSTEM.md @@ -341,17 +341,29 @@ squeezed beside long module headings on mobile. ### Command Grid builder The production builder uses Command Grid as its loadout workbench. Keep the -entire build visible in a dense matrix while one connected editor configures the -selected cell. The full-width Specialization and Focus cell is the root choice. -Its three supplied abilities appear directly below it, followed by two weapons, -six gear positions, and one full-width OS Protocol. +entire build visible in a compact matrix while one connected editor configures +the selected cell. The editor uses two lanes when its container has enough +width. Equipment identity and base values occupy the first lane; allocations, +rolls, Talents, and upgrades occupy the second. The lanes stack when either +would become too narrow. The full-width Specialization and Focus cell is the +root choice. Its three supplied abilities appear directly below it, followed by +two weapons, six gear positions, and one full-width OS Protocol. -Matrix cells summarize selected Talent names, Attribute names and values, Brand -Sets, or Skill Chips. Do not replace those choices with configuration counts. -Selecting an ability opens its three attached Skill Chip positions. Selecting -equipment opens the searchable real-data catalog and its compatible -configuration controls. Do not display a prototype option that the current -loadout schema cannot save. +Matrix cells show the slot and equipped item at rest. The selected cell reveals +its compact Talent, Attribute, Brand Set, or Skill Chip summary. This +progressive disclosure keeps the matrix scannable without replacing configured +choices with counts. Selecting an ability opens its three attached Skill Chip +positions. Selecting equipment opens the searchable real-data catalog and its +compatible configuration controls. Large Talent pools show the selected Talent +at rest and open their search grid through an explicit Change action. Do not +display a prototype option that the current loadout schema cannot save. + +Each equipped gear or weapon Talent exposes two adjacent icon choices for Tier I +and Tier II. Both choices reuse the Talent artwork; Tier II applies a restrained +warm recolor so players can distinguish the pair before reading the labels. +Every tile retains `T1` or `T2`, its full tier name, and selected or unavailable +text. Disable Tier II when the canonical Talent has no authored Tier II data. +Weapon equipment tier and Talent tier are independent selections. Equipment readiness belongs at the point of resolution. Mark an incomplete matrix cell with a compact red text indicator and status rail, then let the cell @@ -361,20 +373,19 @@ and Skill DPS, encounter assumptions, activation profiles, rotations, and simulation as `COMING SOON`; they do not report calculation-profile blockers as current player errors. -The builder uses three workbench columns on wide screens, moves the live summary -below the matrix and editor at intermediate widths, and stacks all three regions -on narrow screens. Every grid track and editor child must accept content -shrinkage. At 560px and below, stack attribute picker/value pairs and section -headings; keep the command actions in two equal columns. Validation markers use -short visible labels while their full messages remain available to assistive -technology and pointer users. +The builder uses two primary workbench columns on wide screens: the compact +matrix and the two-lane editor. The live summary spans both columns below them. +Narrow screens stack the matrix, editor, and summary. Every grid track and +editor child must accept content shrinkage. At 560px and below, stack Attribute +picker/value pairs and section headings; keep the command actions in two equal +columns. Validation markers use short visible labels while their full messages +remain available to assistive technology and pointer users. Use `--shd-builder-canvas` for recessed equipment fields. Use `--shd-builder-selection` with `--shd-builder-selection-border` for the selected cell. Preserve button semantics, `aria-pressed`, focus-visible outlines, pressed -feedback, and textual readiness states. At narrower desktop widths, keep the -matrix and editor together and move live results below them. On mobile, stack -the matrix, editor, and live results in that order. +feedback, and textual readiness states. On mobile, stack the matrix, editor, and +live results in that order. The command header contains the required build name, local and account save actions, account visibility, and optional sharing notes. Sharing notes include a @@ -2575,7 +2586,7 @@ conditional Talent outcomes, weapon and Skill DPS, encounter assumptions, activation profiles, rotations, and simulation behind explicit `COMING SOON` panels. -Loadout schema version 5 retains `maximum`, `custom`, conditional state, +Loadout schema version 6 retains `maximum`, `custom`, conditional state, encounter-assumption, and per-ability activation fields. Version 4 is obsolete prototype data rather than a compatibility format. The current player UI ignores the simulation fields. When player simulation ships, one required two-option diff --git a/docs/TALENT_MECHANIC_RULES.md b/docs/TALENT_MECHANIC_RULES.md index 6e27ebf..0fb1bf9 100644 --- a/docs/TALENT_MECHANIC_RULES.md +++ b/docs/TALENT_MECHANIC_RULES.md @@ -26,8 +26,8 @@ Use these event boundaries: - **Healing:** Count each healing event. A heal-over-time effect counts each tick as a separate event. - **Extra Health gained:** Count every Extra Health grant, including a grant - received while the Agent already has Extra Health. Use - `extra_health_granted` for the grant action. + received while the Agent already has Extra Health. Use `extra_health_granted` + for the grant action. - **Extra Health state changed:** `extra_health_changed` is Agent-scoped. Emit it when the Agent receives a grant, when the remaining amount changes, and when it is depleted to zero. Every event requires the boolean @@ -35,8 +35,8 @@ Use these event boundaries: `values.currentExtraHealth`, which must agree with that status. This state event is distinct from the `extra_health_granted` grant action. - **Reloading:** Trigger on reload completion when the weapon had at least one - round to load. A canceled reload does not count. A weapon that loads one - round at a time produces one completed-reload event for each round. + round to load. A canceled reload does not count. A weapon that loads one round + at a time produces one completed-reload event for each round. - **Taking damage:** Require Health loss. A hit absorbed by Extra Health does not count as taking damage. @@ -59,8 +59,8 @@ Inspiration and Crossfire use a binary deployed-Skill state: - The benefit remains active while the Agent has at least one persistent deployed Skill object. -- Destruction or timed expiration removes that object from the active count. - The benefit ends when no qualifying objects remain. +- Destruction or timed expiration removes that object from the active count. The + benefit ends when no qualifying objects remain. - Instant-use Skills do not qualify. - Multiple deployed Skill objects do not multiply the benefit. @@ -75,8 +75,8 @@ meters: - Moving within 30 meters of an ally who is already downed qualifies. - Each qualifying presence refreshes the ten-second duration. -- Leaving the radius or reviving the ally does not cancel the current - ten-second duration. +- Leaving the radius or reviving the ally does not cancel the current ten-second + duration. - The wearer does not count as an ally. ## Emergency Retreat @@ -93,9 +93,9 @@ qualifies when the weapon had at least one round to load. This includes each round inserted by a weapon that reloads one round at a time. A canceled reload does not qualify. -Resolve the Extra Health amount from the Agent's displayed Firepower when -Second Wind activates. Include all equipped-item and active-buff contributions -in that Firepower value: +Resolve the Extra Health amount from the Agent's displayed Firepower when Second +Wind activates. Include all equipped-item and active-buff contributions in that +Firepower value: - Tier I grants Extra Health equal to 600% of displayed Firepower. - Tier II grants Extra Health equal to 840% of displayed Firepower. @@ -103,19 +103,39 @@ in that Firepower value: Second Wind adds its Extra Health to Extra Health from other sources. Its five-second duration and five-second cooldown start when it activates. Expiry removes only the Second Wind contribution. At the five-second boundary, the -prior grant can expire as a qualifying reload completion grants a new amount. -If Second Wind supplies the Agent's only Extra Health, the old amount expires -and the new amount begins at that boundary. +prior grant can expire as a qualifying reload completion grants a new amount. If +Second Wind supplies the Agent's only Extra Health, the old amount expires and +the new amount begins at that boundary. ## Nothing to Lose Nothing to Lose uses a forward-looking deployment window: -- Each Health-damage instance makes its own 50% activation roll. Damage - absorbed by Extra Health does not roll. +- Each Health-damage instance makes its own 50% activation roll. Damage absorbed + by Extra Health does not roll. - A successful activation applies to every Skill deployed during the five - seconds after that damage instance. Several Skills can qualify during the - same window. + seconds after that damage instance. Several Skills can qualify during the same + window. - Calculate each reduction from the Skill's total cooldown after equipment modifiers. - A Skill can receive no more than three reductions during one cooldown cycle. + +## OS Protocol Talents + +Happy Survival restores Health once per second while it has a qualifying nearby +enemy count. Each restoration resolves 0.5% of maximum Health per enemy within +10 meters, capped at 2.5% before OS Protocol upgrade scaling. + +Explosive Charge requires three seconds of uninterrupted firing. Completion +opens an eight-second window to deploy the next Skill. The window ends when the +Agent deploys that Skill. Only the enhanced Skill's first damaging hit creates +the five-meter explosion. The shared Talent cooldown rule starts its five-second +cooldown when that explosion activates. + +Heavy Armor and Pummeling Shield replace and refresh their own active Extra +Health grant when the same Talent activates again. Extra Health grants from +different sources remain separate. + +Pummeling Shield counts confirmed weapon hits while the Agent possesses Extra +Health. Losing all Extra Health resets the hit count. The full-Health condition +checks Health immediately before the incoming hit resolves. diff --git a/docs/architecture.md b/docs/architecture.md index 4685962..d362c44 100644 --- a/docs/architecture.md +++ b/docs/architecture.md @@ -584,6 +584,9 @@ state, with sprinting taking precedence. Enabled Skill activation profiles emit the deployed ability. An `on_event` Skill modifier applies to that activation until the ability's next deployment or the encounter ends. +`skill_deployed.values.abilityId` and `skill_hit.values.abilityId` identify the +same ability for mechanics that bind an effect to the next deployed Skill. + Each source supplies a fixed value-variant contract: - Standard Talents require Tier I and Tier II values. Exotic Talents require @@ -631,11 +634,11 @@ timestamp. the hit resolved. A producer omits the field when it lacks authoritative aiming state; the runtime does not replace missing evidence with a scenario assumption. Predicates compare this field explicitly with `true` or `false`; negation and -inequality cannot turn missing evidence into a match. A weapon-hit event may -also include an event-target-centered area sample. The bounded sample lists up -to 256 valid ally and enemy entity IDs with their distances from the hit target -and includes that target as an enemy at zero meters. Duplicate IDs, negative -distances, or a missing center target invalidate the evaluation. +inequality cannot turn missing evidence into a match. A `weapon_hit` or +`skill_hit` event may include an event-target-centered area sample. The bounded +sample lists up to 256 valid ally and enemy entity IDs with their distances from +the hit target and includes that target as an enemy at zero meters. Duplicate +IDs, negative distances, or a missing center target invalidate the evaluation. `extra_health_changed` is Agent-scoped. Normalized timeline producers emit it when the Agent receives an Extra Health grant, when the remaining amount @@ -730,11 +733,13 @@ substitute zero. The read-only `combat.currentHealthPercent` reference divides resolved current Health by resolved maximum Health and returns a value from 0 through 100. The runtime derives it when a predicate is evaluated instead of storing a second -Health value that could become stale. Current timing observes deterministic -resource changes from earlier branches at the same event. Health-band mechanics -use strict upper bounds and inclusive lower bounds, so bands do not overlap and -an exact threshold enters the next weaker band. Maximum-potential evaluation -applies the same predicates before emitting passive outcomes. +Health value that could become stale. Pre-event timing reads the combat snapshot +before mechanic branches process the event. Current timing observes +deterministic resource changes from earlier branches at the same event. +Health-band mechanics use strict upper bounds and inclusive lower bounds, so +bands do not overlap and an exact threshold enters the next weaker band. +Maximum-potential evaluation applies the same predicates before emitting passive +outcomes. Continuous restoration resolves the outcome's total when the branch activates, then delivers that total at a constant rate over the configured duration. @@ -876,17 +881,18 @@ applicable, default value, and best-case value. ISAC retains these definitions for continued mechanic authoring. Current Builder and shared Build pages do not render or evaluate them. Their calculation panels display `COMING SOON` instead. -Loadout schema version 5 stores one focus, selected tree ranks, nine Skill -Chips, a unified conditional-effect state map, encounter assumptions, -per-ability activation controls, and `calculationMode`. Runtime readers accept -the exact version 5 structure. The schema retains its simulation fields, but the -current player UI ignores them. Version 4 is obsolete prototype data. A -backed-up prototype migration removes version 4 drafts, saved builds, and -calibration snapshots instead of translating them. +Loadout schema version 6 stores one focus, selected tree ranks, nine Skill +Chips, independent T1/T2 choices for each equipped gear and weapon Talent, a +unified conditional-effect state map, encounter assumptions, per-ability +activation controls, and `calculationMode`. Runtime readers accept the exact +version 6 structure. A backed-up migration translated version 5 equipment +Talents from their previous equipment-tier-derived behavior. The schema retains +its simulation fields, but the current player UI ignores them. Version 4 remains +obsolete prototype data. ## Planned player calculation modes -Loadout v5 defines `maximum` and `custom` modes for the planned simulation UI: +Loadout v6 defines `maximum` and `custom` modes for the planned simulation UI: - Maximum mode supplies each scenario input's best-case value, selects peak conditional-effect state, and runs selected abilities on cooldown against diff --git a/scripts/db-migrate.mjs b/scripts/db-migrate.mjs index ece67fe..24c4a32 100644 --- a/scripts/db-migrate.mjs +++ b/scripts/db-migrate.mjs @@ -45,7 +45,8 @@ const isRoll = (value) => isFiniteNumber(value.value); const isRollPair = (value) => Array.isArray(value) && value.length === 2 && value.every(isRoll); -const isGearSelection = (value) => +const isTalentTier = (value) => value === 1 || value === 2; +const isLegacyGearSelection = (value) => hasExactKeys(value, [ 'itemId', 'level', @@ -68,7 +69,7 @@ const isGearSelection = (value) => isRollPair(value.rolls) && Array.isArray(value.augmentSlots) && value.augmentSlots.every(isFiniteNumber); -const isWeaponSelection = (value) => +const isLegacyWeaponSelection = (value) => hasExactKeys(value, [ 'itemId', 'level', @@ -88,6 +89,57 @@ const isWeaponSelection = (value) => (key) => isFiniteNumber(value[key]), ) && isRollPair(value.rolls); +const isGearSelection = (value) => + hasExactKeys(value, [ + 'itemId', + 'level', + 'brandId', + 'talentId', + 'talentTier', + 'health', + 'armor', + 'firepower', + 'toughness', + 'engineering', + 'rolls', + 'augmentSlots', + ]) && + ['itemId', 'brandId', 'talentId'].every( + (key) => typeof value[key] === 'string', + ) && + isTalentTier(value.talentTier) && + ['level', 'health', 'armor', 'firepower', 'toughness', 'engineering'].every( + (key) => isFiniteNumber(value[key]), + ) && + isRollPair(value.rolls) && + Array.isArray(value.augmentSlots) && + value.augmentSlots.every(isFiniteNumber); +const isWeaponSelection = (value) => + hasExactKeys(value, [ + 'itemId', + 'level', + 'tier', + 'damage', + 'firepower', + 'toughness', + 'engineering', + 'talent1Id', + 'talent1Tier', + 'talent2Id', + 'talent2Tier', + 'exoticTalentTier', + 'rolls', + ]) && + ['itemId', 'talent1Id', 'talent2Id'].every( + (key) => typeof value[key] === 'string', + ) && + isTalentTier(value.talent1Tier) && + isTalentTier(value.talent2Tier) && + isTalentTier(value.exoticTalentTier) && + ['level', 'tier', 'damage', 'firepower', 'toughness', 'engineering'].every( + (key) => isFiniteNumber(value[key]), + ) && + isRollPair(value.rolls); const isChipSelection = (value) => hasExactKeys(value, ['setId', 'quality', 'primary', 'secondary']) && typeof value.setId === 'string' && @@ -190,7 +242,7 @@ const isCurrentLoadoutSnapshot = (raw) => { 'skillActivations', 'specialization', ]) && - value.version === 5 && + value.version === 6 && typeof value.buildName === 'string' && ['maximum', 'custom'].includes(value.calculationMode) && hasExactKeys(value.gear, gearSlots) && @@ -212,6 +264,49 @@ const isCurrentLoadoutSnapshot = (raw) => { ); }; +const isLegacyLoadoutSnapshot = (raw) => { + let value; + try { + value = typeof raw === 'string' ? JSON.parse(raw) : raw; + } catch { + return false; + } + return ( + hasExactKeys(value, [ + 'version', + 'buildName', + 'gear', + 'weapons', + 'chips', + 'protocol', + 'conditionalEffects', + 'combatProfile', + 'calculationMode', + 'skillActivations', + 'specialization', + ]) && + value.version === 5 && + typeof value.buildName === 'string' && + ['maximum', 'custom'].includes(value.calculationMode) && + hasExactKeys(value.gear, gearSlots) && + gearSlots.every((slot) => isLegacyGearSelection(value.gear[slot])) && + Array.isArray(value.weapons) && + value.weapons.length === 2 && + value.weapons.every(isLegacyWeaponSelection) && + Array.isArray(value.chips) && + value.chips.length === 9 && + value.chips.every(isChipSelection) && + isProtocolSelection(value.protocol) && + isEffectStates(value.conditionalEffects) && + isCombatProfile(value.combatProfile) && + isSkillActivations(value.skillActivations) && + hasExactKeys(value.specialization, ['focusId', 'nodeRanks']) && + typeof value.specialization.focusId === 'string' && + isRecord(value.specialization.nodeRanks) && + Object.values(value.specialization.nodeRanks).every(isFiniteNumber) + ); +}; + const databasePath = resolve( process.env.TDR_DATABASE_PATH || './data/shd-build.db', ); @@ -3223,6 +3318,41 @@ if ( } } +const [loadoutGearRows, loadoutWeaponRows, loadoutTalentTierRows] = + await Promise.all([ + (await database.prepare('SELECT id,tier FROM gear')).all(), + (await database.prepare('SELECT id,exotic_talent_id FROM weapons')).all(), + (await database.prepare('SELECT talent_id,tier FROM talent_tiers')).all(), + ]); +const migrateLegacyLoadoutSnapshot = (raw) => { + if (!isLegacyLoadoutSnapshot(raw)) return null; + const value = + typeof raw === 'string' ? JSON.parse(raw) : structuredClone(raw); + for (const slot of gearSlots) { + const item = loadoutGearRows.find( + (entry) => String(entry.id) === String(value.gear[slot].itemId), + ); + value.gear[slot].talentTier = Number(item?.tier) >= 2 ? 2 : 1; + } + for (const selection of value.weapons) { + const inheritedTier = Number(selection.tier) >= 2 ? 2 : 1; + selection.talent1Tier = inheritedTier; + selection.talent2Tier = inheritedTier; + const weapon = loadoutWeaponRows.find( + (entry) => String(entry.id) === String(selection.itemId), + ); + const exoticTalentId = String(weapon?.exotic_talent_id ?? ''); + const hasExoticTierTwo = loadoutTalentTierRows.some( + (entry) => + String(entry.talent_id) === exoticTalentId && entry.tier === 'II', + ); + selection.exoticTalentTier = + inheritedTier === 2 && hasExoticTierTwo ? 2 : 1; + } + value.version = 6; + return isCurrentLoadoutSnapshot(value) ? JSON.stringify(value) : null; +}; + const buildColumns = await ( await database.prepare("PRAGMA table_info('builds')") ).all(); @@ -3237,9 +3367,34 @@ if (buildColumns.length) { await database.exec( "UPDATE builds SET visibility='private' WHERE visibility='draft'", ); - const builds = await ( + let builds = await ( await database.prepare('SELECT id,loadout_json FROM builds') ).all(); + const migratedBuilds = builds + .map((build) => ({ + id: String(build.id), + loadout: migrateLegacyLoadoutSnapshot(build.loadout_json), + })) + .filter((build) => build.loadout); + if (migratedBuilds.length) { + console.log( + `Migrating ${migratedBuilds.length} build loadout snapshot(s) to version 6 Talent tiers.`, + ); + await database.exec('BEGIN'); + try { + for (const build of migratedBuilds) + await ( + await database.prepare('UPDATE builds SET loadout_json=? WHERE id=?') + ).run(build.loadout, build.id); + await database.exec('COMMIT'); + } catch (error) { + await database.exec('ROLLBACK'); + throw error; + } + builds = await ( + await database.prepare('SELECT id,loadout_json FROM builds') + ).all(); + } const obsoleteBuildIds = builds .filter((build) => !isCurrentLoadoutSnapshot(build.loadout_json)) .map((build) => String(build.id)); @@ -3629,11 +3784,42 @@ if ( ); } -const calibrationCases = await ( +let calibrationCases = await ( await database.prepare( 'SELECT id,loadout_snapshot_json FROM calculation_calibration_cases', ) ).all(); +const migratedCalibrationCases = calibrationCases + .map((calibrationCase) => ({ + id: String(calibrationCase.id), + loadout: migrateLegacyLoadoutSnapshot( + calibrationCase.loadout_snapshot_json, + ), + })) + .filter((calibrationCase) => calibrationCase.loadout); +if (migratedCalibrationCases.length) { + console.log( + `Migrating ${migratedCalibrationCases.length} calibration snapshot(s) to version 6 Talent tiers.`, + ); + await database.exec('BEGIN'); + try { + for (const calibrationCase of migratedCalibrationCases) + await ( + await database.prepare( + 'UPDATE calculation_calibration_cases SET loadout_snapshot_json=? WHERE id=?', + ) + ).run(calibrationCase.loadout, calibrationCase.id); + await database.exec('COMMIT'); + } catch (error) { + await database.exec('ROLLBACK'); + throw error; + } + calibrationCases = await ( + await database.prepare( + 'SELECT id,loadout_snapshot_json FROM calculation_calibration_cases', + ) + ).all(); +} const obsoleteCalibrationIds = calibrationCases .filter( (calibrationCase) => diff --git a/src/app.css b/src/app.css index 71a125d..93d7b7c 100644 --- a/src/app.css +++ b/src/app.css @@ -9006,6 +9006,47 @@ a.secondary:active { padding: 0 9px !important; font-size: var(--shd-type-telemetry) !important; } +.builder-radio-toggle { + width: 100%; + min-height: 48px; + display: grid; + grid-template-columns: 34px minmax(0, 1fr) auto; + align-items: center; + gap: 8px; + margin-bottom: 5px; + padding: 6px 8px; + border: 1px solid var(--shd-border); + background: var(--shd-builder-canvas); + color: var(--shd-text); + text-align: left; +} +.builder-radio-toggle > img, +.builder-radio-toggle > i { + width: 32px; + height: 32px; + object-fit: contain; +} +.builder-radio-toggle > span { + min-width: 0; + display: grid; + gap: 2px; +} +.builder-radio-toggle b, +.builder-radio-toggle small { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.builder-radio-toggle em { + color: var(--shd-orange); + font-size: var(--shd-type-telemetry); + font-style: normal; + font-weight: 900; +} +.builder-radio-toggle:hover, +.builder-radio-toggle:focus-visible { + border-color: var(--shd-orange); +} .builder-radio-grid > div { display: grid; grid-template-columns: repeat(var(--builder-radio-columns), minmax(0, 1fr)); @@ -9131,6 +9172,40 @@ a.secondary:active { gap: 3px; margin-top: 6px; } +.builder-talent-slot { + min-width: 0; + padding-top: 8px; + border-top: 1px solid var(--shd-border-soft); +} +.builder-talent-slot:first-child { + padding-top: 0; + border-top: 0; +} +.builder-exotic-talent > div:first-child { + min-height: 48px; + display: grid; + grid-template-columns: 38px minmax(0, 1fr); + align-items: center; + gap: 8px; + padding: 6px 8px; + border: 1px solid var(--shd-border); + background: var(--shd-builder-canvas); +} +.builder-exotic-talent > div:first-child > .item-icon { + width: 36px; + height: 36px; +} +.builder-exotic-talent > div:first-child > span { + min-width: 0; + display: grid; + gap: 2px; +} +.builder-exotic-talent small { + color: var(--shd-orange); + font-size: var(--shd-type-telemetry); + font-weight: 900; + letter-spacing: 0.07em; +} .builder-rolls.required > div { grid-template-columns: minmax(0, 1fr) minmax(180px, 0.65fr); } @@ -9178,7 +9253,7 @@ a.secondary:active { } .builder-core-grid { display: grid; - grid-template-columns: repeat(3, minmax(0, 1fr)); + grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 7px; } .builder-range-grid.weapon-damage { @@ -9278,6 +9353,8 @@ a.secondary:active { } .loadout-slots > header, .summary-section > header { + height: auto; + min-height: 36px; display: flex; justify-content: space-between; align-items: center; @@ -9356,6 +9433,116 @@ a.secondary:active { min-height: 680px; padding: 12px; border-top: 2px solid var(--shd-orange); + container-type: inline-size; +} +.builder-editor-columns, +.builder-specialization-layout { + display: grid; + grid-template-columns: repeat(2, minmax(0, 1fr)); + gap: 16px; + margin-top: 10px; +} +.builder-editor-lane { + min-width: 0; + align-content: start; +} +.builder-editor-lane + .builder-editor-lane { + padding-left: 16px; + border-left: 1px solid var(--shd-border); +} +.builder-editor-lane > :first-child { + margin-top: 0; +} +.builder-editor-lane .builder-weapon-controls { + grid-template-columns: minmax(180px, 1fr) minmax(120px, 0.65fr); +} +.builder-editor-lane .builder-equipment-controls { + grid-template-columns: 1fr; +} +.builder-editor-lane + .builder-equipment-controls + > .builder-radio-grid:last-child:nth-child(3) { + grid-column: auto; +} +.builder-editor-lane .builder-weapon-controls .builder-fixed { + grid-column: 1/-1; +} +.builder-editor-lane .builder-range-grid { + grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); +} +.builder-editor-lane .range-value-inputs { + grid-template-columns: minmax(0, 1fr) 72px; +} +.builder-editor-lane .builder-rolls.required > div, +.builder-editor-lane .builder-chip-rolls > div { + grid-template-columns: minmax(0, 1fr) minmax(150px, 0.72fr); +} +.builder-specialization-layout .builder-ability-chip-panels { + grid-template-columns: 1fr; +} +.builder-focus-abilities { + display: grid; + gap: var(--shd-gap-xs); +} +.builder-focus-abilities > button { + min-width: 0; + min-height: 58px; + display: grid; + grid-template-columns: 38px minmax(0, 1fr) auto; + align-items: center; + gap: var(--shd-gap-sm); + padding: var(--shd-gap-sm); + border: 1px solid var(--shd-border); + background: var(--shd-builder-canvas); + color: var(--shd-text); + text-align: left; +} +.builder-focus-abilities > button:hover, +.builder-focus-abilities > button:focus-visible { + border-color: var(--shd-orange); +} +.builder-focus-abilities img { + width: 38px; + height: 38px; +} +.builder-focus-abilities span { + min-width: 0; + display: grid; + gap: 2px; +} +.builder-focus-abilities small, +.builder-focus-abilities b { + color: var(--shd-text-muted); + font-size: var(--shd-type-telemetry); + letter-spacing: 0.6px; +} +.builder-focus-abilities strong { + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} +.builder-focus-abilities b { + white-space: nowrap; +} +.builder-specialization-layout .builder-specialization-identity { + grid-template-columns: auto minmax(0, 1fr); +} +.builder-specialization-layout .builder-specialization-identity > b { + grid-column: 1/-1; + width: max-content; +} +@container (max-width: 700px) { + .builder-editor-columns, + .builder-specialization-layout { + grid-template-columns: 1fr; + gap: 12px; + } + .builder-editor-lane + .builder-editor-lane { + padding-top: 12px; + padding-left: 0; + border-top: 1px solid var(--shd-border); + border-left: 0; + } } .loadout-editor-head { display: flex; @@ -9688,11 +9875,12 @@ a.secondary:active { } .summary-core { display: grid; - grid-template-columns: repeat(3, 1fr); + grid-template-columns: repeat(3, minmax(0, 1fr)); border-top: 1px solid #303536; border-bottom: 1px solid #303536; } .summary-core > div { + min-width: 0; display: flex; align-items: center; gap: 5px; @@ -9707,13 +9895,18 @@ a.secondary:active { height: 22px; } .summary-core span { + min-width: 0; display: grid; color: #687072; font-size: var(--shd-type-telemetry); + overflow-wrap: anywhere; } .summary-core b { + min-width: 0; + overflow: hidden; color: #d6d9da; font-size: var(--shd-type-telemetry); + text-overflow: ellipsis; } .summary-scroll { max-height: calc(100vh - 340px); @@ -9726,14 +9919,15 @@ a.secondary:active { } .summary-stat, .summary-bonus { - display: flex; - justify-content: space-between; + display: grid; + grid-template-columns: minmax(0, 1fr) minmax(70px, auto); gap: 8px; padding: 8px 10px; border-top: 1px solid #252a2b; } .summary-stat > span, .summary-bonus > span { + min-width: 0; display: grid; gap: 3px; font-size: var(--shd-type-telemetry); @@ -9744,10 +9938,14 @@ a.secondary:active { font-size: var(--shd-type-telemetry); } .summary-stat > b { + min-width: 0; + overflow-wrap: anywhere; color: #d9dbdc; font-size: var(--shd-type-telemetry); } .summary-bonus em { + min-width: 0; + overflow-wrap: anywhere; color: var(--shd-success); font-size: var(--shd-type-telemetry); font-style: normal; @@ -12003,10 +12201,7 @@ a.secondary:active { } .loadout-workspace { min-width: 0; - grid-template-columns: minmax(300px, 350px) minmax(480px, 1fr) minmax( - 290px, - 340px - ); + grid-template-columns: minmax(300px, 350px) minmax(0, 1fr); gap: 6px; } .loadout-workspace > *, @@ -12040,8 +12235,20 @@ a.secondary:active { } .loadout-summary { min-width: 0; + position: static; + grid-column: 1/3; + max-height: none; + overflow: visible; background: var(--shd-surface); } +.loadout-summary .summary-scroll { + max-height: none; + display: grid; + grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); +} +.builder-editor-lane .builder-radio-grid:not(.icon-only) > div { + grid-template-columns: repeat(2, minmax(0, 1fr)); +} .builder-picker-current > * { min-width: 0; } @@ -12118,11 +12325,13 @@ a.secondary:active { .loadout-summary { position: static; grid-column: 1/3; + max-height: none; + overflow: visible; } .summary-scroll { max-height: none; display: grid; - grid-template-columns: repeat(3, 1fr); + grid-template-columns: repeat(auto-fit, minmax(290px, 1fr)); } } @media (max-width: 1050px) { @@ -12699,10 +12908,9 @@ a.secondary:active { } .mod-secondary-pool-option { display: grid; - grid-template-columns: 30px minmax(220px, 0.9fr) repeat( - 3, - minmax(285px, 1fr) - ) 30px; + grid-template-columns: + 30px minmax(220px, 0.9fr) repeat(3, minmax(285px, 1fr)) + 30px; align-items: stretch; gap: 6px; padding: 6px; @@ -12814,10 +13022,9 @@ a.secondary:active { } .skill-chip-profile-option.selectable { - grid-template-columns: 32px minmax(210px, 1.2fr) repeat( - 3, - minmax(130px, 1fr) - ) 34px; + grid-template-columns: + 32px minmax(210px, 1.2fr) repeat(3, minmax(130px, 1fr)) + 34px; } .skill-chip-profile-option > div:first-child, @@ -15494,18 +15701,23 @@ a.secondary:active { .builder-ability-chip-panels > section { min-width: 0; display: grid; - grid-template-rows: auto minmax(48px, auto) auto; + grid-template-rows: auto auto; gap: var(--shd-gap-sm); padding: var(--shd-gap-sm); border: 1px solid var(--shd-border); background: var(--shd-surface); } .builder-ability-chip-panels header { + height: auto; + position: static; min-width: 0; display: grid; grid-template-columns: auto minmax(0, 1fr) auto; gap: var(--shd-gap-sm); align-items: center; + padding: 0; + border: 0; + background: transparent; } .builder-ability-chip-panels header img { width: 38px; @@ -15528,13 +15740,6 @@ a.secondary:active { .builder-ability-chip-panels header b { white-space: nowrap; } -.builder-ability-chip-panels > section > p { - min-width: 0; - margin: 0; - color: var(--shd-text-muted); - font-size: var(--shd-type-supporting); - overflow-wrap: anywhere; -} .builder-ability-chip-panels > section > div { min-width: 0; display: grid; @@ -15600,6 +15805,9 @@ a.secondary:active { background: var(--shd-model-surface); } .builder-focus-tree > section > header { + height: auto; + min-height: 32px; + position: static; display: flex; justify-content: space-between; padding: 6px 8px; diff --git a/src/lib/builder/loadout-combat.test.ts b/src/lib/builder/loadout-combat.test.ts index d8fa0f2..0b1ced0 100644 --- a/src/lib/builder/loadout-combat.test.ts +++ b/src/lib/builder/loadout-combat.test.ts @@ -259,7 +259,7 @@ describe('loadout mechanic timeline', () => { ).toEqual([1, 2]); }); - it('falls back to a documented Tier I mechanic when equipment Tier II is absent', () => { + it('falls back to a documented Tier I mechanic when exotic Tier II is absent', () => { const persistedRule = { rule: { id: 'tier-i-only', @@ -327,6 +327,7 @@ describe('loadout mechanic timeline', () => { const adapted = equippedConditionalProgram({ key: 'weapon:0:exotic-talent', tier: 2, + isExotic: true, rule: persistedRule, }); diff --git a/src/lib/builder/loadout-combat.ts b/src/lib/builder/loadout-combat.ts index 6f84def..1239ecf 100644 --- a/src/lib/builder/loadout-combat.ts +++ b/src/lib/builder/loadout-combat.ts @@ -283,7 +283,7 @@ export function equippedConditionalProgram( : 'base'; return ( conditionalProgram(equipped.rule, variant) ?? - (equipmentTalent && variant === 'II' + (equipmentTalent && equipped.isExotic && variant === 'II' ? conditionalProgram(equipped.rule, 'I') : null) ); diff --git a/src/lib/builder/loadout-summary.test.ts b/src/lib/builder/loadout-summary.test.ts index ea29f12..c4428d2 100644 --- a/src/lib/builder/loadout-summary.test.ts +++ b/src/lib/builder/loadout-summary.test.ts @@ -425,11 +425,58 @@ describe('summarizeLoadout', () => { expect(stat(summary, 'mechanic')).toBeUndefined(); }); - it('renders the selected Talent tier without applying its mechanic outcomes to stats', () => { + it('uses a gear Talent tier independently from the gear tier', () => { + const draft = createDraft(); + draft.gear.Holster.itemId = 'gear'; + draft.gear.Holster.talentId = 'talent'; + Object.assign(draft.gear.Holster, { talentTier: 2 }); + + const summary = summarizeLoadout( + draft, + catalog({ + attributes: [attribute('bonus', 'Bonus', { unit: '%' })], + gear: [{ id: 'gear', tier: 0, base_armor_min: null }], + talents: [ + { + id: 'talent', + name: 'Reinforced', + template: 'Gain {1}.', + tiers: [ + { + tier: 'I', + effects: [{ stat_attribute_id: 'bonus', value: 10 }], + }, + { + tier: 'II', + effects: [{ stat_attribute_id: 'bonus', value: 20 }], + }, + ], + }, + ], + }), + ); + + expect(summary.equippedTalents).toEqual([ + expect.objectContaining({ + id: 'talent', + tier: 2, + tierLabel: 'TIER II', + description: 'Gain 20%.', + }), + ]); + }); + + it('uses each weapon Talent tier independently without applying mechanic outcomes to stats', () => { const draft = createDraft(); draft.weapons[0].itemId = 'weapon'; draft.weapons[0].tier = 2; - draft.weapons[0].talent1Id = 'talent'; + draft.weapons[0].talent1Id = 'talent-one'; + draft.weapons[0].talent2Id = 'talent-two'; + Object.assign(draft.weapons[0], { + talent1Tier: 1, + talent2Tier: 2, + exoticTalentTier: 1, + }); const rule = { clauses: [ @@ -455,13 +502,13 @@ describe('summarizeLoadout', () => { { id: 'weapon', name: 'Test Weapon', - exotic_talent_id: null, + exotic_talent_id: 'exotic-talent', baseBonuses: [], }, ], talents: [ { - id: 'talent', + id: 'talent-one', name: 'Measured', template: 'Gain {1} for {2}.', tiers: [ @@ -482,17 +529,60 @@ describe('summarizeLoadout', () => { ], rule, }, + { + id: 'talent-two', + name: 'Calibrated', + template: 'Gain {1}.', + tiers: [ + { + tier: 'I', + effects: [{ stat_attribute_id: 'talent-stat', value: 30 }], + }, + { + tier: 'II', + effects: [{ stat_attribute_id: 'talent-stat', value: 40 }], + }, + ], + }, + { + id: 'exotic-talent', + name: 'Exotic Talent', + template: 'Gain {1}.', + tiers: [ + { + tier: 'I', + effects: [{ stat_attribute_id: 'talent-stat', value: 50 }], + }, + { + tier: 'II', + effects: [{ stat_attribute_id: 'talent-stat', value: 60 }], + }, + ], + }, ], }), ); expect(summary.equippedTalents).toEqual([ expect.objectContaining({ - id: 'talent', - tier: 2, - description: 'Gain 20% for 3 Shots.', + id: 'talent-one', + tier: 1, + tierLabel: 'TIER I', + description: 'Gain 10% for 2 Shots.', rule, }), + expect.objectContaining({ + id: 'talent-two', + tier: 2, + tierLabel: 'TIER II', + description: 'Gain 40%.', + }), + expect.objectContaining({ + id: 'exotic-talent', + tier: 1, + tierLabel: 'TIER I', + description: 'Gain 50%.', + }), ]); expect(stat(summary, 'talent-stat')).toBeUndefined(); }); diff --git a/src/lib/builder/loadout-summary.ts b/src/lib/builder/loadout-summary.ts index cc62fa8..aa2a3e6 100644 --- a/src/lib/builder/loadout-summary.ts +++ b/src/lib/builder/loadout-summary.ts @@ -1,4 +1,9 @@ -import { gearSlots, scaled, type LoadoutDraft } from '$lib/builder/loadout'; +import { + gearSlots, + scaled, + type LoadoutDraft, + type TalentTier, +} from '$lib/builder/loadout'; export type LoadoutCatalog = { attributes: any[]; @@ -100,18 +105,21 @@ function unitValue(catalog: LoadoutCatalog, value: unknown, statId: string) { return unit === 'Shots' ? `${rendered} ${unit}` : `${rendered}${unit}`; } -function talentTier(catalog: LoadoutCatalog, talentId: string, tier: number) { +function talentTier( + catalog: LoadoutCatalog, + talentId: string, + tier: TalentTier, +) { const item = catalog.talents.find((entry) => entry.id === talentId); - return ( - item?.tiers.find((entry: any) => entry.tier === (tier >= 2 ? 'II' : 'I')) ?? - item?.tiers[0] + return item?.tiers.find( + (entry: any) => entry.tier === (tier === 2 ? 'II' : 'I'), ); } function talentDescription( catalog: LoadoutCatalog, talentId: string, - tier: number, + tier: TalentTier, ) { const item = catalog.talents.find((entry) => entry.id === talentId); const configured = talentTier(catalog, talentId, tier); @@ -255,12 +263,14 @@ export function summarizeLoadout( rule: catalog.talents.find((entry) => entry.id === selection.talentId) ?.rule ?? null, - tier: Number(item.tier), + tier: selection.talentTier, + tierLabel: selection.talentTier === 2 ? 'TIER II' : 'TIER I', + isExotic: false, source: slot, description: talentDescription( catalog, selection.talentId, - Number(item.tier), + selection.talentTier, ), }); } @@ -305,19 +315,39 @@ export function summarizeLoadout( roll.value, `${index ? 'Secondary' : 'Primary'} weapon roll`, ); - for (const talentId of [ - selection.talent1Id, - selection.talent2Id, - item.exotic_talent_id, - ].filter(Boolean)) { + const equippedWeaponTalents = [ + { + id: selection.talent1Id, + tier: selection.talent1Tier, + isExotic: false, + }, + { + id: selection.talent2Id, + tier: selection.talent2Tier, + isExotic: false, + }, + { + id: item.exotic_talent_id, + tier: selection.exoticTalentTier, + isExotic: true, + }, + ].filter((entry) => entry.id); + for (const equippedTalent of equippedWeaponTalents) { equippedTalents.push({ - key: `weapon:${index}:${talentId}`, - id: talentId, + key: `weapon:${index}:${equippedTalent.id}`, + id: equippedTalent.id, rule: - catalog.talents.find((entry) => entry.id === talentId)?.rule ?? null, - tier: selection.tier, + catalog.talents.find((entry) => entry.id === equippedTalent.id) + ?.rule ?? null, + tier: equippedTalent.tier, + tierLabel: equippedTalent.tier === 2 ? 'TIER II' : 'TIER I', + isExotic: equippedTalent.isExotic, source: index ? 'Secondary weapon' : 'Primary weapon', - description: talentDescription(catalog, talentId, selection.tier), + description: talentDescription( + catalog, + equippedTalent.id, + equippedTalent.tier, + ), }); } } diff --git a/src/lib/builder/loadout.test.ts b/src/lib/builder/loadout.test.ts index 39d7bb2..07c1215 100644 --- a/src/lib/builder/loadout.test.ts +++ b/src/lib/builder/loadout.test.ts @@ -1,6 +1,7 @@ import { describe, expect, it } from 'vitest'; import { createDraft, + migrateLoadoutDraftV5, parseLoadoutDraft, skillChipSecondaryCapacity, type SkillChipQuality, @@ -8,13 +9,40 @@ import { const copyDraft = () => structuredClone(createDraft()); +const talentTierFields = [ + [ + 'gear talentTier', + (draft: ReturnType) => + draft.gear.Holster as unknown as Record, + 'talentTier', + ], + [ + 'weapon talent1Tier', + (draft: ReturnType) => + draft.weapons[0] as unknown as Record, + 'talent1Tier', + ], + [ + 'weapon talent2Tier', + (draft: ReturnType) => + draft.weapons[0] as unknown as Record, + 'talent2Tier', + ], + [ + 'weapon exoticTalentTier', + (draft: ReturnType) => + draft.weapons[0] as unknown as Record, + 'exoticTalentTier', + ], +] as const; + describe('parseLoadoutDraft', () => { it('accepts a current draft and returns an independent clone', () => { const draft = createDraft(); const parsed = parseLoadoutDraft(draft); expect(parsed).toEqual(draft); - expect(parsed?.version).toBe(5); + expect(parsed?.version).toBe(6); expect(parsed?.chips[0]).toEqual({ setId: '', quality: 'Standard', @@ -27,6 +55,37 @@ describe('parseLoadoutDraft', () => { expect(draft.gear.Holster.level).toBe(50); }); + it('defaults every equipment Talent tier to Tier I', () => { + const draft = createDraft(); + + expect( + Object.values(draft.gear).map( + (selection) => + (selection as unknown as Record).talentTier, + ), + ).toEqual(Array(6).fill(1)); + expect( + draft.weapons.map((selection) => { + const weapon = selection as unknown as Record; + return [ + weapon.talent1Tier, + weapon.talent2Tier, + weapon.exoticTalentTier, + ]; + }), + ).toEqual([ + [1, 1, 1], + [1, 1, 1], + ]); + }); + + it('accepts Tier II for every equipment Talent selection', () => { + const draft = copyDraft(); + for (const [, select, key] of talentTierFields) select(draft)[key] = 2; + + expect(parseLoadoutDraft(draft)).toEqual(draft); + }); + it('rejects the retired version 1 three-chip shape', () => { const retired = copyDraft() as unknown as Record; retired.version = 1; @@ -42,13 +101,77 @@ describe('parseLoadoutDraft', () => { expect(parseLoadoutDraft(retired)).toBeNull(); }); - it('rejects a version 5 draft that does not contain exactly nine chips', () => { + it('rejects the retired version 5 schema', () => { + const retired = copyDraft() as unknown as Record; + retired.version = 5; + + expect(parseLoadoutDraft(retired)).toBeNull(); + }); + + it('migrates version 5 equipment-derived Talent tiers once', () => { + const legacy = copyDraft() as unknown as Record; + legacy.version = 5; + for (const selection of Object.values(legacy.gear) as Record< + string, + any + >[]) { + delete selection.talentTier; + } + for (const selection of legacy.weapons as Record[]) { + delete selection.talent1Tier; + delete selection.talent2Tier; + delete selection.exoticTalentTier; + } + legacy.gear.Holster.itemId = 'tier-two-gear'; + legacy.weapons[0].itemId = 'exotic-weapon'; + legacy.weapons[0].tier = 2; + + const migrated = migrateLoadoutDraftV5(legacy, { + gear: [{ id: 'tier-two-gear', tier: 2 }], + weapons: [{ id: 'exotic-weapon', exotic_talent_id: 'exotic-talent' }], + talents: [ + { + id: 'exotic-talent', + tiers: [{ tier: 'I' }, { tier: 'II' }], + }, + ], + }); + + expect(migrated?.version).toBe(6); + expect(migrated?.gear.Holster.talentTier).toBe(2); + expect(migrated?.gear.Gloves.talentTier).toBe(1); + expect(migrated?.weapons[0]).toMatchObject({ + talent1Tier: 2, + talent2Tier: 2, + exoticTalentTier: 2, + }); + }); + + it('rejects a current draft that does not contain exactly nine chips', () => { const draft = copyDraft(); draft.chips.pop(); expect(parseLoadoutDraft(draft)).toBeNull(); }); + it.each(talentTierFields)('rejects a draft missing %s', (_, select, key) => { + const draft = copyDraft(); + delete select(draft)[key]; + + expect(parseLoadoutDraft(draft)).toBeNull(); + }); + + it.each( + talentTierFields.flatMap(([name, select, key]) => + [0, 1.5, 3].map((value) => [name, value, select, key] as const), + ), + )('rejects %s value %s', (_, value, select, key) => { + const draft = copyDraft(); + select(draft)[key] = value; + + expect(parseLoadoutDraft(draft)).toBeNull(); + }); + it.each([ ['Standard', 0], ['Specialized', 1], diff --git a/src/lib/builder/loadout.ts b/src/lib/builder/loadout.ts index baa9348..640cfc0 100644 --- a/src/lib/builder/loadout.ts +++ b/src/lib/builder/loadout.ts @@ -1,4 +1,5 @@ export type Roll = { statId: string; value: number }; +export type TalentTier = 1 | 2; export const skillChipQualities = [ 'Standard', 'Specialized', @@ -17,6 +18,7 @@ export type GearSelection = { level: number; brandId: string; talentId: string; + talentTier: TalentTier; health: number; armor: number; firepower: number; @@ -34,7 +36,10 @@ export type WeaponSelection = { toughness: number; engineering: number; talent1Id: string; + talent1Tier: TalentTier; talent2Id: string; + talent2Tier: TalentTier; + exoticTalentTier: TalentTier; rolls: [Roll, Roll]; }; export type ChipSelection = { @@ -81,7 +86,7 @@ export type SpecializationSelection = { nodeRanks: Record; }; export type LoadoutDraft = { - version: 5; + version: 6; buildName: string; calculationMode: CalculationMode; gear: Record; @@ -118,6 +123,7 @@ export const blankGear = (): GearSelection => ({ level: 50, brandId: '', talentId: '', + talentTier: 1, health: 0, armor: 0, firepower: 0, @@ -135,7 +141,10 @@ export const blankWeapon = (): WeaponSelection => ({ toughness: 0, engineering: 0, talent1Id: '', + talent1Tier: 1, talent2Id: '', + talent2Tier: 1, + exoticTalentTier: 1, rolls: [blankRoll(), blankRoll()], }); export const blankChip = (): ChipSelection => ({ @@ -161,7 +170,7 @@ export const defaultCombatProfile = (): CombatProfile => ({ extraHealthActive: false, }); export const createDraft = (): LoadoutDraft => ({ - version: 5, + version: 6, buildName: 'Untitled loadout', calculationMode: 'maximum', gear: Object.fromEntries(gearSlots.map((slot) => [slot, blankGear()])), @@ -187,6 +196,39 @@ export const createDraft = (): LoadoutDraft => ({ }, }); +export function migrateLoadoutDraftV5( + value: unknown, + catalog: { gear: any[]; weapons: any[]; talents: any[] }, +): LoadoutDraft | null { + if (!isRecord(value) || value.version !== 5) return null; + const migrated = structuredClone(value); + if (!isRecord(migrated.gear) || !Array.isArray(migrated.weapons)) return null; + + for (const slot of gearSlots) { + const selection = migrated.gear[slot]; + if (!isRecord(selection)) return null; + const item = catalog.gear.find((entry) => entry.id === selection.itemId); + selection.talentTier = Number(item?.tier) >= 2 ? 2 : 1; + } + for (const selection of migrated.weapons) { + if (!isRecord(selection)) return null; + const inheritedTier: TalentTier = Number(selection.tier) >= 2 ? 2 : 1; + selection.talent1Tier = inheritedTier; + selection.talent2Tier = inheritedTier; + const item = catalog.weapons.find((entry) => entry.id === selection.itemId); + const exoticTalent = catalog.talents.find( + (entry) => entry.id === item?.exotic_talent_id, + ); + selection.exoticTalentTier = + inheritedTier === 2 && + exoticTalent?.tiers?.some((entry: any) => entry.tier === 'II') + ? 2 + : 1; + } + migrated.version = 6; + return parseLoadoutDraft(migrated); +} + const isRecord = (value: unknown): value is Record => Boolean(value) && typeof value === 'object' && !Array.isArray(value); const hasExactKeys = (value: Record, keys: string[]) => @@ -194,6 +236,8 @@ const hasExactKeys = (value: Record, keys: string[]) => keys.every((key) => key in value); const isFiniteNumber = (value: unknown): value is number => typeof value === 'number' && Number.isFinite(value); +const isTalentTier = (value: unknown): value is TalentTier => + value === 1 || value === 2; const isNumberRecord = (value: unknown) => isRecord(value) && Object.values(value).every( @@ -213,6 +257,7 @@ const isGearSelection = (value: unknown): value is GearSelection => 'level', 'brandId', 'talentId', + 'talentTier', 'health', 'armor', 'firepower', @@ -224,6 +269,7 @@ const isGearSelection = (value: unknown): value is GearSelection => ['itemId', 'brandId', 'talentId'].every( (key) => typeof value[key] === 'string', ) && + isTalentTier(value.talentTier) && ['level', 'health', 'armor', 'firepower', 'toughness', 'engineering'].every( (key) => isFiniteNumber(value[key]), ) && @@ -241,12 +287,18 @@ const isWeaponSelection = (value: unknown): value is WeaponSelection => 'toughness', 'engineering', 'talent1Id', + 'talent1Tier', 'talent2Id', + 'talent2Tier', + 'exoticTalentTier', 'rolls', ]) && ['itemId', 'talent1Id', 'talent2Id'].every( (key) => typeof value[key] === 'string', ) && + isTalentTier(value.talent1Tier) && + isTalentTier(value.talent2Tier) && + isTalentTier(value.exoticTalentTier) && ['level', 'tier', 'damage', 'firepower', 'toughness', 'engineering'].every( (key) => isFiniteNumber(value[key]), ) && @@ -369,7 +421,7 @@ export function parseLoadoutDraft(value: unknown): LoadoutDraft | null { 'skillActivations', 'specialization', ]) || - value.version !== 5 || + value.version !== 6 || typeof value.buildName !== 'string' || !['maximum', 'custom'].includes(String(value.calculationMode)) ) diff --git a/src/lib/calculations/mechanic-editor.test.ts b/src/lib/calculations/mechanic-editor.test.ts index c6d02d2..f946454 100644 --- a/src/lib/calculations/mechanic-editor.test.ts +++ b/src/lib/calculations/mechanic-editor.test.ts @@ -791,9 +791,9 @@ describe('conditional mechanic authoring payload', () => { }); }); - it('rejects invalid pre-event timing for current Health percentage references', () => { - const invalid = draft(); - invalid.clauses[0].if = { + it('preserves pre-event timing for current Health percentage references', () => { + const value = draft(); + value.clauses[0].if = { kind: 'compare', left: { source: 'combat', @@ -803,11 +803,13 @@ describe('conditional mechanic authoring payload', () => { operator: 'lt', right: 50, }; - const result = parseConditionalMechanicDraft(invalid, { + const result = parseConditionalMechanicDraft(value, { variantKeys: ['I', 'II'], allowedAttributeIds: new Set(['weapon-damage']), }); - expect(result.ok).toBe(false); + expect(result.ok).toBe(true); + if (!result.ok) return; + expect(result.value.draft.clauses[0].if).toEqual(value.clauses[0].if); }); it('accepts compatible radius targeting and rejects incompatible scopes', () => { diff --git a/src/lib/calculations/mechanic-editor.ts b/src/lib/calculations/mechanic-editor.ts index 10723d2..5e29813 100644 --- a/src/lib/calculations/mechanic-editor.ts +++ b/src/lib/calculations/mechanic-editor.ts @@ -426,8 +426,7 @@ function isReference(value: unknown): value is ValueReference { Boolean(value.path.trim()) && (value.timing === undefined || value.timing === 'pre_event' || - value.timing === 'current') && - !(value.path === 'currentHealthPercent' && value.timing === 'pre_event') + value.timing === 'current') ); case 'equipment': return typeof value.path === 'string' && Boolean(value.path.trim()); diff --git a/src/lib/calculations/mechanic-persistence.test.ts b/src/lib/calculations/mechanic-persistence.test.ts index 9e0c80a..7b904c8 100644 --- a/src/lib/calculations/mechanic-persistence.test.ts +++ b/src/lib/calculations/mechanic-persistence.test.ts @@ -850,7 +850,7 @@ describe('conditional-effect persistence adapter', () => { left: { source: 'combat', path: 'currentHealthPercent', - timing: 'current', + timing: 'pre_event', }, operator: 'lt', right: 25, diff --git a/src/lib/calculations/mechanic-persistence.ts b/src/lib/calculations/mechanic-persistence.ts index 19d2e9d..cbc7fbd 100644 --- a/src/lib/calculations/mechanic-persistence.ts +++ b/src/lib/calculations/mechanic-persistence.ts @@ -216,8 +216,7 @@ function isValueReference(value: unknown) { Boolean(value.path.trim()) && (value.timing === undefined || value.timing === 'pre_event' || - value.timing === 'current') && - !(value.path === 'currentHealthPercent' && value.timing === 'pre_event') + value.timing === 'current') ); } if (value.source === 'attribute') { diff --git a/src/lib/calculations/mechanic.test.ts b/src/lib/calculations/mechanic.test.ts index c1969c4..105bf51 100644 --- a/src/lib/calculations/mechanic.test.ts +++ b/src/lib/calculations/mechanic.test.ts @@ -2834,13 +2834,13 @@ describe('mechanic validation and pseudo-script', () => { ]); }); - it('rejects pre-event timing for the derived current Health percentage', () => { - const invalid: MechanicProgram = { - id: 'invalid-health-percent', - name: 'Invalid Health Percent', + it('evaluates pre-event timing for the derived current Health percentage', () => { + const program: MechanicProgram = { + id: 'pre-event-health-percent', + name: 'Pre-event Health Percent', clauses: [ { - id: 'invalid', + id: 'full-health-before-event', when: 'tick', if: { kind: 'compare', @@ -2849,25 +2849,32 @@ describe('mechanic validation and pseudo-script', () => { path: 'currentHealthPercent', timing: 'pre_event', }, - operator: 'lt', - right: 50, + operator: 'gte', + right: 100, }, reducer: { kind: 'none' }, mutations: [], + outcomes: [ + { + id: 'matched', + label: 'Matched', + phase: 'on_event', + kind: 'marker', + scope: 'self', + basis: 'flat', + value: 1, + }, + ], }, ], }; - const result = validateMechanicProgram(invalid); - expect(result.ok).toBe(false); - if (!result.ok) { - expect(result.errors).toEqual( - expect.arrayContaining([ - expect.stringContaining( - 'current Health percentage must use current timing', - ), - ]), - ); - } + expect(validateMechanicProgram(program)).toMatchObject({ ok: true }); + expect( + evaluateMechanicProgram(program, [{ kind: 'tick', at: 0 }], custom(1), { + maxHealth: 100, + currentHealth: 100, + }).outcomes.map((outcome) => outcome.outcomeId), + ).toEqual(['matched']); }); it('formats nested conditions and state operations deterministically', () => { @@ -3104,6 +3111,42 @@ describe('mechanic validation and pseudo-script', () => { expect( maximum.outcomes.every((outcome) => outcome.probabilityRoll === 0), ).toBe(true); + + const skillProgram: MechanicProgram = { + ...program, + id: 'skill-hit-explosion', + clauses: program.clauses.map((clause) => ({ + ...clause, + when: 'skill_hit', + if: undefined, + })), + }; + expect(validateMechanicProgram(skillProgram)).toMatchObject({ ok: true }); + expect( + evaluateMechanicProgram( + skillProgram, + [ + { + kind: 'skill_hit', + at: 1, + targetId: 'enemy-b', + areaTargetSample: { + center: 'event_target', + validTargets: [ + { entityId: 'enemy-b', population: 'enemy', distanceMeters: 0 }, + { entityId: 'enemy-a', population: 'enemy', distanceMeters: 5 }, + ], + }, + }, + ], + custom(5), + { + maxHealth: 1000, + currentHealth: 1000, + attributes: { firepower: 100 }, + }, + ).outcomes.map((outcome) => outcome.targetId), + ).toEqual(['enemy-a', 'enemy-b']); }); it('requires authoritative area evidence only when an area outcome activates', () => { diff --git a/src/lib/calculations/mechanic.ts b/src/lib/calculations/mechanic.ts index 7993bc0..0bf928e 100644 --- a/src/lib/calculations/mechanic.ts +++ b/src/lib/calculations/mechanic.ts @@ -97,6 +97,11 @@ export const MECHANIC_EVENT_REGISTRY: Readonly< description: 'The Agent deploys or activates a specialization ability. An assigned-ability deployment may supply its active duration.', fields: [ + { + path: 'values.abilityId', + label: 'Deployed ability ID', + type: 'string', + }, { path: 'values.assignedAbilityDurationSeconds', label: 'Assigned ability duration', @@ -123,8 +128,9 @@ export const MECHANIC_EVENT_REGISTRY: Readonly< key: 'skill_hit', label: 'Skill hit', description: - 'A deployed skill connects with a target. Critical and distance details belong in event values.', + 'A deployed skill connects with a target. Critical and distance details belong in event values. An optional area-target sample lists valid entities by distance from the hit target.', fields: [ + { path: 'values.abilityId', label: 'Source ability ID', type: 'string' }, { path: 'values.critical', label: 'Critical hit', type: 'boolean' }, { path: 'values.assignedAbilityActive', @@ -1892,15 +1898,8 @@ function validateReference( } if (reference.source === 'event' && !reference.path.trim()) errors.push(`${path} requires an event path.`); - if (reference.source === 'combat') { - if (!reference.path.trim()) errors.push(`${path} requires a combat path.`); - if ( - reference.path === 'currentHealthPercent' && - reference.timing === 'pre_event' - ) { - errors.push(`${path} current Health percentage must use current timing.`); - } - } + if (reference.source === 'combat' && !reference.path.trim()) + errors.push(`${path} requires a combat path.`); if (reference.source === 'attribute' && !reference.attributeId.trim()) errors.push(`${path} requires an Attribute ID.`); if (reference.source === 'equipment' && !reference.path.trim()) @@ -2067,7 +2066,7 @@ function validateMechanicEvents(events: MechanicEvent[]) { if (sample === undefined) continue; const samplePath = `Event ${index + 1} (${definition.label}) area-target sample`; if ( - event.kind !== 'weapon_hit' || + !['weapon_hit', 'skill_hit'].includes(event.kind) || !objectValue(sample) || sample.center !== 'event_target' || !Array.isArray(sample.validTargets) || @@ -2075,7 +2074,7 @@ function validateMechanicEvents(events: MechanicEvent[]) { !event.targetId.trim() ) { errors.push( - `${samplePath} requires a weapon-hit event target and event-target-centered valid targets.`, + `${samplePath} requires a weapon-hit or skill-hit event target and event-target-centered valid targets.`, ); continue; } @@ -2769,10 +2768,10 @@ export function validateMechanicProgram( if (targetingError) errors.push(`${outcomePath} ${targetingError}`); if ( outcome.targeting?.kind === 'event_target_area' && - clause.when !== 'weapon_hit' + !['weapon_hit', 'skill_hit'].includes(clause.when) ) { errors.push( - `${outcomePath} event-target area damage requires a weapon-hit clause.`, + `${outcomePath} event-target area damage requires a weapon-hit or skill-hit clause.`, ); } if ( diff --git a/src/lib/components/BuilderRadioGrid.svelte b/src/lib/components/BuilderRadioGrid.svelte index c8b7da1..fe60141 100644 --- a/src/lib/components/BuilderRadioGrid.svelte +++ b/src/lib/components/BuilderRadioGrid.svelte @@ -24,6 +24,8 @@ } = $props(); let query = $state(''); + let open = $state(false); + const selected = $derived(items.find((item) => item.id === value)); const visible = $derived(items.filter((item) => !query.trim() || `${item.name} ${item.category ?? ''}`.toLocaleLowerCase().includes(query.trim().toLocaleLowerCase()) )); @@ -31,26 +33,33 @@ function choose(id: string) { value = id; onchange?.(id); + if (searchable) { + open = false; + query = ''; + } }
{label} - {#if searchable} + {#if searchable}{/if} + {#if searchable && open} {/if} -
- {#each visible as item} - - {:else} -

NO MATCHING OPTIONS

- {/each} -
+ {#if !searchable || open} +
+ {#each visible as item} + + {:else} +

NO MATCHING OPTIONS

+ {/each} +
+ {/if}
diff --git a/src/lib/components/builder/LoadoutMatrix.svelte b/src/lib/components/builder/LoadoutMatrix.svelte index dfc4743..bc1129f 100644 --- a/src/lib/components/builder/LoadoutMatrix.svelte +++ b/src/lib/components/builder/LoadoutMatrix.svelte @@ -37,9 +37,9 @@ && Math.floor(Number(active.split(':')[1]) / 3) === Number(cell.id.split(':')[1])); const issueLabel = (issue: string) => { - if (/not configured|required/i.test(issue)) return 'ACTION REQUIRED'; - if (/incomplete/i.test(issue)) return 'DATA INCOMPLETE'; - return 'CHECK CONFIGURATION'; + if (/not configured|required/i.test(issue)) return 'REQUIRED'; + if (/incomplete/i.test(issue)) return 'INCOMPLETE'; + return 'CHECK'; }; @@ -60,7 +60,7 @@ onclick={() => onselect(doctrine.id)} > - {doctrine.label}{doctrine.name}{doctrine.summary}{#if doctrine.issue}{doctrine.issue}{/if} + {doctrine.label}{doctrine.name}{doctrine.summary}{#if doctrine.issue}{doctrine.issue}{/if}
SUPPLIES 3 ABILITIES
@@ -68,7 +68,7 @@ {#each abilities as cell} {/each} @@ -80,7 +80,7 @@ {#each weapons as cell} {/each} @@ -93,7 +93,7 @@ {#each gear as cell} {/each} @@ -104,7 +104,7 @@ @@ -112,21 +112,20 @@ diff --git a/src/lib/components/builder/LoadoutStatsSummary.svelte b/src/lib/components/builder/LoadoutStatsSummary.svelte index 7860d25..9d25f86 100644 --- a/src/lib/components/builder/LoadoutStatsSummary.svelte +++ b/src/lib/components/builder/LoadoutStatsSummary.svelte @@ -40,7 +40,6 @@

KNOWN EQUIPMENT TOTALS

Agent stats

- {summary.stats.length}
{#each ['Firepower', 'Toughness', 'Engineering'] as name} @@ -78,24 +77,32 @@
EQUIPPED TALENTS{summary.equippedTalents.length}
{#each summary.equippedTalents as equipped}
- - {equipped.custom?.name ?? talent(equipped.id)?.name ?? 'Talent'} - {equipped.source} · CONDITIONAL EFFECT NOT INCLUDED - {equipped.description} +
+ {equipped.custom?.name ?? talent(equipped.id)?.name ?? 'Talent'}{equipped.source}{equipped.tierLabel ? ` · ${equipped.tierLabel}` : ''} +

{equipped.description}

{#if equipped.id && talentCooldown(equipped.id)}{talentCooldown(equipped.id)}{/if} - +
{:else}

Selected equipment Talents appear here.

{/each}
-

Totals reflect this saved loadout and the current canonical item definitions. They include fixed values, rolls, inherited profiles, enabled augments, set bonuses, Protocol effects, and static Specialization rank effects. Conditional Talent outcomes are reserved for the advanced combat model.

+

Includes deterministic equipment values only. Conditional Talent effects remain outside current totals.

diff --git a/src/lib/server/articles.ts b/src/lib/server/articles.ts index 2ac6e07..d7d47bf 100644 --- a/src/lib/server/articles.ts +++ b/src/lib/server/articles.ts @@ -77,7 +77,7 @@ export async function syncArticleTags(database: Database) { `specialization-${item.id}`, 'specialization', String(item.name), - `specialization-${slugify(String(item.name))}`, + `specialization-${slugify(String(item.name))}-${item.id}`, 'specialization', item.id, Number(item.active) ? 1 : 0, @@ -93,7 +93,7 @@ export async function syncArticleTags(database: Database) { `focus-${item.id}`, 'focus', name, - `focus-${slugify(name)}`, + `focus-${slugify(name)}-${item.id}`, 'focus', item.id, Number(item.active) ? 1 : 0, diff --git a/src/lib/server/shared-build.ts b/src/lib/server/shared-build.ts index a4417e7..fee9903 100644 --- a/src/lib/server/shared-build.ts +++ b/src/lib/server/shared-build.ts @@ -59,7 +59,7 @@ export async function loadSharedBuildProjection( ).all(), ( await database.prepare( - 'SELECT id,name,category,is_exotic,rpm,magazine,reload_speed,damage_type FROM weapons', + 'SELECT id,name,category,is_exotic,rpm,magazine,reload_speed,damage_type,exotic_talent_id FROM weapons', ) ).all(), (await database.prepare('SELECT id,name FROM skill_chip_sets')).all(), diff --git a/src/routes/builder/+page.server.ts b/src/routes/builder/+page.server.ts index 24b14e6..404a22a 100644 --- a/src/routes/builder/+page.server.ts +++ b/src/routes/builder/+page.server.ts @@ -125,6 +125,74 @@ async function validateSkillChipSelections( return null; } +async function validateEquipmentTalentSelections( + database: Awaited>, + loadout: LoadoutDraft, +) { + const [gearTalents, weaponTalents, weapons, talentTiers] = await Promise.all([ + ( + await database.prepare('SELECT gear_id,talent_id FROM gear_talents') + ).all(), + ( + await database.prepare( + 'SELECT weapon_id,talent_slot,talent_id FROM weapon_talent_options', + ) + ).all(), + (await database.prepare('SELECT id,exotic_talent_id FROM weapons')).all(), + (await database.prepare('SELECT talent_id,tier FROM talent_tiers')).all(), + ]); + const hasTier = (talentId: string, tier: 1 | 2) => + talentTiers.some( + (entry) => + String(entry.talent_id) === talentId && + String(entry.tier) === (tier === 2 ? 'II' : 'I'), + ); + + for (const slot of Object.keys(loadout.gear)) { + const selection = loadout.gear[slot]; + if (!selection.talentId) continue; + if ( + !gearTalents.some( + (entry) => + String(entry.gear_id) === selection.itemId && + String(entry.talent_id) === selection.talentId, + ) + ) + return `${slot} has a Talent that is not available for the equipped item.`; + if (!hasTier(selection.talentId, selection.talentTier)) + return `${slot} Talent T${selection.talentTier} is not configured.`; + } + + for (let index = 0; index < loadout.weapons.length; index += 1) { + const selection = loadout.weapons[index]; + const label = index ? 'Secondary weapon' : 'Primary weapon'; + for (const configured of [ + { id: selection.talent1Id, tier: selection.talent1Tier, slot: 1 }, + { id: selection.talent2Id, tier: selection.talent2Tier, slot: 2 }, + ]) { + if (!configured.id) continue; + if ( + !weaponTalents.some( + (entry) => + String(entry.weapon_id) === selection.itemId && + Number(entry.talent_slot) === configured.slot && + String(entry.talent_id) === configured.id, + ) + ) + return `${label} has a Talent that is not available in slot ${configured.slot}.`; + if (!hasTier(configured.id, configured.tier)) + return `${label} Talent ${configured.slot} T${configured.tier} is not configured.`; + } + const weapon = weapons.find( + (entry) => String(entry.id) === selection.itemId, + ); + const exoticTalentId = String(weapon?.exotic_talent_id ?? ''); + if (exoticTalentId && !hasTier(exoticTalentId, selection.exoticTalentTier)) + return `${label} exotic Talent T${selection.exoticTalentTier} is not configured.`; + } + return null; +} + export const load: PageServerLoad = async ({ cookies, url }) => { const database = await getDatabase(); const viewer = await getSessionUser(cookies); @@ -592,6 +660,12 @@ export const actions: Actions = { return fail(400, { buildError: 'Choose a valid build visibility.' }); const database = await getDatabase(); + const equipmentTalentError = await validateEquipmentTalentSelections( + database, + loadout, + ); + if (equipmentTalentError) + return fail(400, { buildError: equipmentTalentError }); const skillChipError = await validateSkillChipSelections(database, loadout); if (skillChipError) return fail(400, { buildError: skillChipError }); const now = new Date().toISOString(); diff --git a/src/routes/builder/+page.svelte b/src/routes/builder/+page.svelte index 5f078f4..2edf009 100644 --- a/src/routes/builder/+page.svelte +++ b/src/routes/builder/+page.svelte @@ -12,11 +12,12 @@ import LoadoutMatrix, { type MatrixCell } from '$lib/components/builder/LoadoutMatrix.svelte'; import LoadoutStatsSummary from '$lib/components/builder/LoadoutStatsSummary.svelte'; import PlannedCombatModel from '$lib/components/builder/PlannedCombatModel.svelte'; + import TalentTierChoice from '$lib/components/builder/TalentTierChoice.svelte'; import { summarizeLoadout } from '$lib/builder/loadout-summary'; import { toast } from '$lib/toast'; import { - blankRoll, clamp, createDraft, gearBaseStatRange, gearSlots, levelScaledRange, parseLoadoutDraft, remapRangeValue, scaled, skillChipQualities, skillChipSecondaryCapacity, weaponBaseRange, - type LoadoutDraft, type Roll, type SkillChipQuality + blankRoll, clamp, createDraft, gearBaseStatRange, gearSlots, levelScaledRange, migrateLoadoutDraftV5, parseLoadoutDraft, remapRangeValue, scaled, skillChipQualities, skillChipSecondaryCapacity, weaponBaseRange, + type LoadoutDraft, type Roll, type SkillChipQuality, type TalentTier } from '$lib/builder/loadout'; let { data, form } = $props(); @@ -71,6 +72,8 @@ return selectedRank ? [{ node, rank: node.ranks.find((entry: any) => Number(entry.rank) === selectedRank) }] : []; }) ?? []); const talent = (id: string) => data.talents.find((item) => item.id === id); + const supportedTalentTier = (id: string, tier: TalentTier): TalentTier => + talent(id)?.tiers.some((entry: any) => entry.tier === (tier === 2 ? 'II' : 'I')) ? tier : 1; const brand = (id: string) => data.brands.find((item) => item.id === id); const unitValue = (value: unknown, statId: string) => { const numeric = Number(value); @@ -207,6 +210,7 @@ selection.level = 50; selection.brandId = item?.brandIds[0] ?? ''; selection.talentId = item?.talentIds[0] ?? ''; + selection.talentTier = supportedTalentTier(selection.talentId, Number(item?.tier) >= 2 ? 2 : 1); selection.health = Number(item?.base_health_min ?? 0); selection.armor = Number(item?.base_armor_min ?? 0); const core = coreAllocationRange(Number(item?.tier ?? 0), selection.level, 'gear'); @@ -255,7 +259,10 @@ const core = coreAllocationRange(selection.tier, selection.level, 'weapon'); for (const key of coreKeys) selection[key] = core.min; selection.talent1Id = item?.talent1Ids[0] ?? ''; + selection.talent1Tier = supportedTalentTier(selection.talent1Id, selection.tier >= 2 ? 2 : 1); selection.talent2Id = item?.talent2Ids[0] ?? ''; + selection.talent2Tier = supportedTalentTier(selection.talent2Id, selection.tier >= 2 ? 2 : 1); + selection.exoticTalentTier = supportedTalentTier(item?.exotic_talent_id ?? '', selection.tier >= 2 ? 2 : 1); selection.rolls = [blankRoll(), blankRoll()]; }; const configureChip = (index: number, id: string) => { @@ -375,7 +382,7 @@ })); const weaponCells = $derived.by((): MatrixCell[] => draft.weapons.map((selection, index) => { const item = weaponItem(index); - const talents = [selection.talent1Id, selection.talent2Id].map((id) => talent(id)?.name).filter(Boolean); + const talents = [[selection.talent1Id, selection.talent1Tier], [selection.talent2Id, selection.talent2Tier]].map(([id,tier]) => id ? `${talent(String(id))?.name ?? 'Talent'} T${tier}` : '').filter(Boolean); const details = [...talents, rollSummary(selection.rolls)].filter(Boolean).join(' · '); return { id: `weapon:${index}`, @@ -392,7 +399,7 @@ const item = gearItem(slot); const details = [ brand(selection.brandId)?.name, - talent(selection.talentId)?.name, + selection.talentId ? `${talent(selection.talentId)?.name ?? 'Talent'} T${selection.talentTier}` : '', rollSummary(selection.rolls) ].filter(Boolean).join(' · '); return { @@ -429,17 +436,24 @@ localStorage.removeItem('shd-build-loadout-draft-v3'); localStorage.removeItem('shd-build-loadout-draft-v4'); if (data.initialBuild) return; - const stored = localStorage.getItem('shd-build-loadout-draft-v5'); + const current = localStorage.getItem('shd-build-loadout-draft-v6'); + const legacy = current ? null : localStorage.getItem('shd-build-loadout-draft-v5'); + const stored = current ?? legacy; if (!stored) return; try { - const parsed = parseLoadoutDraft(JSON.parse(stored)); + const raw = JSON.parse(stored); + const parsed = current ? parseLoadoutDraft(raw) : migrateLoadoutDraftV5(raw, data); if (parsed) { draft = parsed; + if (legacy) { + localStorage.setItem('shd-build-loadout-draft-v6', JSON.stringify(parsed)); + localStorage.removeItem('shd-build-loadout-draft-v5'); + } if (weaponItem(0) && weaponItem(1) && Number(weaponItem(0).is_exotic) && Number(weaponItem(1).is_exotic)) draft.weapons[1].itemId = ''; saved = true; - } else localStorage.removeItem('shd-build-loadout-draft-v5'); + } else localStorage.removeItem(current ? 'shd-build-loadout-draft-v6' : 'shd-build-loadout-draft-v5'); } catch { - localStorage.removeItem('shd-build-loadout-draft-v5'); + localStorage.removeItem(current ? 'shd-build-loadout-draft-v6' : 'shd-build-loadout-draft-v5'); } }); $effect(() => { @@ -457,7 +471,7 @@ : 'Build published to the SHD archive.'; }); function saveDraft() { - localStorage.setItem('shd-build-loadout-draft-v5', JSON.stringify(draft)); + localStorage.setItem('shd-build-loadout-draft-v6', JSON.stringify(draft)); saved = true; toast.success('Draft saved locally', 'This loadout is available on this device.'); } @@ -495,7 +509,7 @@ {#if persistedSlug && savedBuildVisibility !== 'private'}VIEW SHARE PAGE →{/if} {/if} -
KNOWN STATS ONLINEADVANCED MODEL · COMING SOON12 LOADOUT CELLS + 9 CHIPS{data.gear.length + data.weapons.length + data.chipSets.length + data.protocols.length} CATALOG ITEMS
+
KNOWN STATS ONLINEADVANCED MODEL · COMING SOON
{#if message}

{message}

{/if} {#if form?.buildError}{/if} @@ -518,29 +532,28 @@
AGENT CLASS

SPECIALIZATION FOCUS

{selectedFocus ? `${selectedSpecializationPoints} / ${data.specializationProgression.availablePoints} POINTS` : 'UNASSIGNED'}
{#if selectedFocus} -
{selectedFocus.specialization.name}

{selectedFocus.name}

{selectedFocus.description || 'No focus description has been entered.'}

{Number(selectedFocus.builder_ready) === 1 ? 'BUILDER READY' : 'ISAC DATA INCOMPLETE'}
-
- {#each [0,1,2] as abilityIndex} - {@const ability = selectedFocus.abilities[abilityIndex]} -
-
ABILITY {abilityIndex + 1}{ability?.name ?? 'NOT CONFIGURED'}
{draft.chips.slice(abilityIndex * 3, abilityIndex * 3 + 3).filter((chip) => chip.setId).length} / 3 CHIPS
-

{ability?.description ?? 'ISAC requires this class ability before compatible Skill Chips can be equipped.'}

-
{#each [0,1,2] as chipSlot}{@const chipIndex = abilityIndex * 3 + chipSlot}{@const item = chipItem(chipIndex)}{/each}
-
- {/each} -
-
POINTS {selectedSpecializationPoints} / {data.specializationProgression.availablePoints}CREDITS {selectedSpecializationCosts.credits.toLocaleString()}{#each selectedSpecializationCosts.resources as resource}{String(resource[0]).replace('resource-electronics-','').replaceAll('-',' ').toUpperCase()} × {resource[1]}{/each}
-
-
FOCUS UPGRADE TREEPREVIOUS ROWS REQUIRE EVERY AVAILABLE RANK 1 + 2 BEFORE ADVANCING
{selectedFocus.nodes.length} NODES
- {#each [...new Set(selectedFocus.nodes.map((node: any) => Number(node.row_number)))] as row} -
ROW {String(row).padStart(2, '0')}{row === 1 ? 'ENTRY ROW' : 'LOCKED BY PREVIOUS ROWS'}
- {#each selectedFocus.nodes.filter((node: any) => Number(node.row_number) === row) as node} -
{node.name}{node.description_template}
({value:String(index+1),label:`R${index+1}`,className:canSelectNodeRank(node,index+1)?'':'unavailable',disabled:!canSelectNodeRank(node,index+1)}))]} value={String(draft.specialization.nodeRanks[node.id] ?? 0)} onchange={(values) => setNodeRank(node,Number(values[0]))}/>
+
+
+
{selectedFocus.specialization.name}

{selectedFocus.name}

{selectedFocus.description || 'No focus description has been entered.'}

{Number(selectedFocus.builder_ready) === 1 ? 'BUILDER READY' : 'ISAC DATA INCOMPLETE'}
+
+ {#each [0,1,2] as abilityIndex} + {@const ability = selectedFocus.abilities[abilityIndex]} + {/each} -
- {/each} +
+
POINTS {selectedSpecializationPoints} / {data.specializationProgression.availablePoints}CREDITS {selectedSpecializationCosts.credits.toLocaleString()}{#each selectedSpecializationCosts.resources as resource}{String(resource[0]).replace('resource-electronics-','').replaceAll('-',' ').toUpperCase()} × {resource[1]}{/each}
+ +
+
FOCUS UPGRADE TREECOMPLETE EARLIER ROWS TO ADVANCE
{selectedFocus.nodes.length} NODES
+ {#each [...new Set(selectedFocus.nodes.map((node: any) => Number(node.row_number)))] as row} +
ROW {String(row).padStart(2, '0')}{row === 1 ? 'ENTRY ROW' : 'PREVIOUS ROWS REQUIRED'}
+ {#each selectedFocus.nodes.filter((node: any) => Number(node.row_number) === row) as node} +
{node.name}{node.description_template}
({value:String(index+1),label:`R${index+1}`,className:canSelectNodeRank(node,index+1)?'':'unavailable',disabled:!canSelectNodeRank(node,index+1)}))]} value={String(draft.specialization.nodeRanks[node.id] ?? 0)} onchange={(values) => setNodeRank(node,Number(values[0]))}/>
+ {/each} +
+ {/each} +
- {/if} {:else if activeParts[0] === 'ability'} {@const abilityIndex = Number(activeParts[1])} @@ -565,20 +578,27 @@ {#if item} {@const healthRange = gearBaseRange(item, 'health', selection.level)} {@const armorRange = item.base_armor_min !== null ? gearBaseRange(item, 'armor', selection.level) : null} -
- changeGearLevel(slot,value)}/> - brand(id)).filter(Boolean)} bind:value={selection.brandId} columns={Math.min(item.brandIds.length,4)} iconOnly required/> - {#if item.talentIds.length} talent(id)).filter(Boolean)} bind:value={selection.talentId} columns={Math.min(item.talentIds.length,4)} searchable={item.talentIds.length > 6} required/>{/if} -
-

{healthRange.provisional ? 'Estimated range: levels 1–9 remain provisional while additional game samples are collected.' : 'Base Health and Armor are calculated from the stored gear base ranges at the selected item level. Display values are truncated to match the game.'}

-
{#if armorRange}{/if}
{@const gearCore = coreAllocationRange(Number(item.tier), selection.level, 'gear')} -
CORE ATTRIBUTE ALLOCATIONSHARED T{item.tier} POOL · VALUES MAY BE REDISTRIBUTED BETWEEN CORES
gearCore.poolMax}>{coreTotal(selection)} / {gearCore.poolMin}–{gearCore.poolMax}
-
{#each coreKeys as key}{/each}
-
ROLLED ATTRIBUTESTWO REQUIRED SLOTS · VALUES ARE LIMITED TO GEAR RANGES
-
{#each selection.rolls as roll, index}{@const rollRange = attributeRange(attribute(roll.statId), 'gear', selection.level)}
setRollStat(roll,id,'gear',selection.level)} disabledIds={selection.rolls.filter((_, itemIndex) => itemIndex !== index).map((entry) => entry.statId).filter(Boolean)} label={`ATTRIBUTE ${index + 1}`}/>
{/each}
{@const augments = data.gearAugments.filter((entry) => entry.gear_slot === slot)} - {#if augments.length}
TACTICAL AUGMENTSENABLE COLLECTED UPGRADES · BASE BONUSES APPLY TO THIS ITEM ONLY
{selection.augmentSlots.length} / {augments.length} ACTIVE
{#each augments as augment}{/each}
{/if} +
+
+
+ changeGearLevel(slot,value)}/> + brand(id)).filter(Boolean)} bind:value={selection.brandId} columns={Math.min(item.brandIds.length,4)} iconOnly required/> + {#if item.talentIds.length} talent(id)).filter(Boolean)} value={selection.talentId} onchange={(id) => { selection.talentId = id; selection.talentTier = supportedTalentTier(id, selection.talentTier); }} columns={Math.min(item.talentIds.length,4)} searchable={item.talentIds.length > 6} required/>{/if} + {#if selection.talentId && talent(selection.talentId)}{/if} +
+

{healthRange.provisional ? 'Estimated range: levels 1–9 remain provisional.' : 'Base values scale with item level and use game-matching truncated display values.'}

+
{#if armorRange}{/if}
+
+
+
CORE ALLOCATIONSHARED T{item.tier} POOL
gearCore.poolMax}>{coreTotal(selection)} / {gearCore.poolMin}–{gearCore.poolMax}
+
{#each coreKeys as key}{/each}
+
ROLLED ATTRIBUTESTWO REQUIRED SLOTS
+
{#each selection.rolls as roll, index}{@const rollRange = attributeRange(attribute(roll.statId), 'gear', selection.level)}
setRollStat(roll,id,'gear',selection.level)} disabledIds={selection.rolls.filter((_, itemIndex) => itemIndex !== index).map((entry) => entry.statId).filter(Boolean)} label={`ATTRIBUTE ${index + 1}`}/>
{/each}
+ {#if augments.length}
TACTICAL AUGMENTSOPTIONAL ITEM UPGRADES
{selection.augmentSlots.length} / {augments.length} ACTIVE
{#each augments as augment}{/each}
{/if} +
+
{/if} {:else if activeParts[0] === 'weapon'} {@const index = Number(activeParts[1])}{@const selection = draft.weapons[index]}{@const item = weaponItem(index)}{@const other = weaponItem(index ? 0 : 1)} @@ -586,27 +606,32 @@ configureWeapon(index,id)} disabledIds={other && Number(other.is_exotic) ? data.weapons.filter((entry) => Number(entry.is_exotic)).map((entry) => entry.id) : []} label="WEAPON DEFINITION"/> {#if item} {#if Number(item.is_exotic) && other && Number(other.is_exotic)}

Only one exotic weapon may be equipped. Choose a standard weapon in either slot.

{/if} -
- changeWeaponLevel(index,value)}/> - ({ value: String(range.tier), label: `T${range.tier}` }))} value={String(selection.tier)} onchange={(values) => changeWeaponTier(index,Number(values[0]))} required/> -
{item.rpm} RPM{item.magazine} SHOTS{item.reload_speed}s RELOAD
-
{@const range = item.ranges.find((entry: any) => Number(entry.tier) === selection.tier)} - {#if range} -

{selection.level < 40 ? 'Estimated range: the weapon curve below level 40 is provisional and may change as observations are added.' : 'Damage is calculated from the stored weapon base range at the selected item level. Core attributes use the shared level-50 tier allocation pool.'}

- {@const damageRange = weaponStatRange(range,'damage',selection.level)} -
- {@const weaponCore = coreAllocationRange(selection.tier, selection.level, 'weapon')} -
CORE ATTRIBUTE ALLOCATIONSHARED T{selection.tier} POOL · VALUES MAY BE REDISTRIBUTED BETWEEN CORES
weaponCore.poolMax}>{coreTotal(selection)} / {weaponCore.poolMin}–{weaponCore.poolMax}
-
{#each coreKeys as key}{/each}
+ {#if range}{@const damageRange = weaponStatRange(range,'damage',selection.level)}{@const weaponCore = coreAllocationRange(selection.tier, selection.level, 'weapon')} +
+
+
+ changeWeaponLevel(index,value)}/> + ({ value: String(entry.tier), label: `T${entry.tier}` }))} value={String(selection.tier)} onchange={(values) => changeWeaponTier(index,Number(values[0]))} required/> +
{item.rpm} RPM{item.magazine} SHOTS{item.reload_speed}s RELOAD
+
+

{selection.level < 40 ? 'Estimated range below level 40.' : 'Damage scales with the selected item level.'}

+
+ {#if item.baseBonuses.length}
{#each item.baseBonuses as bonus}{attribute(bonus.stat_attribute_id)?.name}{unitValue(bonus.value,bonus.stat_attribute_id)}{/each}
{/if} +
+
+
CORE ALLOCATIONSHARED T{selection.tier} POOL
weaponCore.poolMax}>{coreTotal(selection)} / {weaponCore.poolMin}–{weaponCore.poolMax}
+
{#each coreKeys as key}{/each}
+
ROLLED ATTRIBUTESTWO REQUIRED SLOTS
+
{#each selection.rolls as roll, rollIndex}{@const rollRange = attributeRange(attribute(roll.statId), 'weapon', selection.level)}
setRollStat(roll,id,'weapon',selection.level)} disabledIds={selection.rolls.filter((_, itemIndex) => itemIndex !== rollIndex).map((entry) => entry.statId).filter(Boolean)} label={`ATTRIBUTE ${rollIndex + 1}`}/>
{/each}
+
+ {#if item.talent1Ids.length}
talent(id)).filter(Boolean)} value={selection.talent1Id} onchange={(id) => { selection.talent1Id = id; selection.talent1Tier = supportedTalentTier(id, selection.talent1Tier); }} columns={Math.min(item.talent1Ids.length,4)} searchable={item.talent1Ids.length > 6} required/>{#if selection.talent1Id && talent(selection.talent1Id)}{/if}
{/if} + {#if item.talent2Ids.length}
talent(id)).filter(Boolean)} value={selection.talent2Id} onchange={(id) => { selection.talent2Id = id; selection.talent2Tier = supportedTalentTier(id, selection.talent2Tier); }} columns={Math.min(item.talent2Ids.length,4)} searchable={item.talent2Ids.length > 6} required/>{#if selection.talent2Id && talent(selection.talent2Id)}{/if}
{/if} + {#if item.exotic_talent_id && talent(item.exotic_talent_id)}
EXOTIC TALENT{talent(item.exotic_talent_id).name}
{/if} +
+
+
{/if} -
ROLLED ATTRIBUTESTWO REQUIRED SLOTS · VALUES ARE LIMITED TO WEAPON RANGES
-
{#each selection.rolls as roll, rollIndex}{@const rollRange = attributeRange(attribute(roll.statId), 'weapon', selection.level)}
setRollStat(roll,id,'weapon',selection.level)} disabledIds={selection.rolls.filter((_, itemIndex) => itemIndex !== rollIndex).map((entry) => entry.statId).filter(Boolean)} label={`ATTRIBUTE ${rollIndex + 1}`}/>
{/each}
-
- {#if item.talent1Ids.length} talent(id)).filter(Boolean)} bind:value={selection.talent1Id} columns={Math.min(item.talent1Ids.length,4)} searchable={item.talent1Ids.length > 6} required/>{/if} - {#if item.talent2Ids.length} talent(id)).filter(Boolean)} bind:value={selection.talent2Id} columns={Math.min(item.talent2Ids.length,4)} searchable={item.talent2Ids.length > 6} required/>{/if} -
- {#if item.baseBonuses.length}
{#each item.baseBonuses as bonus}{attribute(bonus.stat_attribute_id)?.name}{unitValue(bonus.value,bonus.stat_attribute_id)}{/each}
{/if} {/if} {:else if activeParts[0] === 'chip'} {@const index = Number(activeParts[1])}{@const chip = draft.chips[index]}{@const item = chipItem(index)}{@const abilityIndex = Math.floor(index / 3)}{@const ability = selectedFocus?.abilities[abilityIndex]} @@ -615,24 +640,19 @@ {#if ability} entry.specialization_ability_id === ability.id)} bind:value={chip.setId} onchange={(id) => configureChip(index,id)} label="ABILITY-COMPATIBLE SKILL CHIP SET"/>{:else}

Select a focus with three configured class abilities before equipping Skill Chips.

{/if} {#if !chipProfileConfigured}

SHARED SKILL CHIP PROFILE · CONFIG REQUIRED. Complete every global quality range in ISAC before this loadout can be complete.

{/if} {#if item} -
- ({ value: quality, label: quality.toUpperCase() }))} value={chip.quality} onchange={(values) => changeChipQuality(index, values[0] as SkillChipQuality)} required/> +
+
+
({ value: quality, label: quality.toUpperCase() }))} value={chip.quality} onchange={(values) => changeChipQuality(index, values[0] as SkillChipQuality)} required/>
+
ABILITY-SCOPED PRIMARY{ability?.name?.toUpperCase() ?? 'ASSIGNED ABILITY'} ONLY
NOT YET DEFINED
+

Excluded from current Agent totals.

+
setChipRoll(chip.primary,id,'primary',chip.quality)} label="PRIMARY ATTRIBUTE"/>{#if validChipRange(chipRange('primary', chip.primary.statId, chip.quality))}{:else}

PRIMARY RANGE · CONFIG REQUIRED

{/if}
+
+
+
SECONDARY ATTRIBUTES{skillChipSecondaryCapacity[chip.quality]} SLOT{skillChipSecondaryCapacity[chip.quality] === 1 ? '' : 'S'}
+
{#each chip.secondary as roll, secondaryIndex}
setChipRoll(roll,id,'secondary',chip.quality)} disabledIds={chip.secondary.filter((_,i) => i !== secondaryIndex).map((entry) => entry.statId).filter(Boolean)} label={`SECONDARY ATTRIBUTE ${secondaryIndex + 1}`}/>{#if validChipRange(chipRange('secondary', roll.statId, chip.quality))}{:else}

SECONDARY RANGE · CONFIG REQUIRED

{/if}
{/each}
+ {#if skillChipSecondaryCapacity[chip.quality] === 0}

STANDARD QUALITY · NO SECONDARY ATTRIBUTES

{/if} +
-
ABILITY-SCOPED PRIMARY{ability?.name?.toUpperCase() ?? 'ASSIGNED ABILITY'} ONLY · EXCLUDED FROM KNOWN AGENT STATS
NOT YET DEFINED
-

The primary roll belongs to this ability. Its calculation application is NOT YET DEFINED, so it does not contribute to current Agent totals.

-
-
- setChipRoll(chip.primary,id,'primary',chip.quality)} label="PRIMARY ATTRIBUTE"/> - {#if validChipRange(chipRange('primary', chip.primary.statId, chip.quality))}{:else}

PRIMARY RANGE · CONFIG REQUIRED

{/if} -
- {#each chip.secondary as roll, secondaryIndex} -
- setChipRoll(roll,id,'secondary',chip.quality)} disabledIds={chip.secondary.filter((_,i) => i !== secondaryIndex).map((entry) => entry.statId).filter(Boolean)} label={`SECONDARY ATTRIBUTE ${secondaryIndex + 1}`}/> - {#if validChipRange(chipRange('secondary', roll.statId, chip.quality))}{:else}

SECONDARY RANGE · CONFIG REQUIRED

{/if} -
- {/each} -
- {#if skillChipSecondaryCapacity[chip.quality] === 0}

STANDARD QUALITY · NO SECONDARY ATTRIBUTES

{/if} {/if} {:else} {@const protocol = protocolItem()} diff --git a/src/routes/builder/skill-chip-save.test.ts b/src/routes/builder/skill-chip-save.test.ts index 73fb312..f200b91 100644 --- a/src/routes/builder/skill-chip-save.test.ts +++ b/src/routes/builder/skill-chip-save.test.ts @@ -183,4 +183,56 @@ describe('Builder Skill Chip save validation', () => { }); expect(mocks.insertBuild).toHaveBeenCalledOnce(); }); + + it('rejects an equipment Talent tier without canonical tier data', async () => { + const loadout = createDraft(); + loadout.buildName = 'Invalid Talent Tier'; + loadout.gear.Holster.itemId = 'gear-1'; + loadout.gear.Holster.talentId = 'talent-1'; + loadout.gear.Holster.talentTier = 2; + mocks.database.prepare.mockImplementation(async (sql: string) => ({ + all: vi.fn(async () => { + if (sql.includes('FROM gear_talents')) + return [{ gear_id: 'gear-1', talent_id: 'talent-1' }]; + if (sql.includes('FROM talent_tiers')) + return [{ talent_id: 'talent-1', tier: 'I' }]; + return []; + }), + run: mocks.insertBuild, + })); + + const result = await runSave(loadout); + + expect(result).toMatchObject({ + status: 400, + data: { buildError: 'Holster Talent T2 is not configured.' }, + }); + expect(mocks.insertBuild).not.toHaveBeenCalled(); + }); + + it('saves an equipment Talent with an authored Tier II', async () => { + const loadout = createDraft(); + loadout.buildName = 'Tier Two Talent'; + loadout.gear.Holster.itemId = 'gear-1'; + loadout.gear.Holster.talentId = 'talent-1'; + loadout.gear.Holster.talentTier = 2; + mocks.database.prepare.mockImplementation(async (sql: string) => ({ + all: vi.fn(async () => { + if (sql.includes('FROM gear_talents')) + return [{ gear_id: 'gear-1', talent_id: 'talent-1' }]; + if (sql.includes('FROM talent_tiers')) + return [ + { talent_id: 'talent-1', tier: 'I' }, + { talent_id: 'talent-1', tier: 'II' }, + ]; + return []; + }), + run: mocks.insertBuild, + })); + + const result = await runSave(loadout); + + expect(result).toMatchObject({ buildSaved: true }); + expect(mocks.insertBuild).toHaveBeenCalledOnce(); + }); }); diff --git a/src/routes/builds/[slug]/+page.svelte b/src/routes/builds/[slug]/+page.svelte index 57478f9..65db49a 100644 --- a/src/routes/builds/[slug]/+page.svelte +++ b/src/routes/builds/[slug]/+page.svelte @@ -10,6 +10,7 @@ const chip = (id: string) => data.chips.find((item) => item.id === id); const protocol = (id: string) => data.protocols.find((item) => item.id === id); const brand = (id: string) => data.brands.find((item) => item.id === id); + const talent = (id: string) => data.talents.find((item) => item.id === id); const attribute = (id: string) => data.attributes.find((item) => item.id === id); const number = new Intl.NumberFormat('en-US', { maximumFractionDigits: 2 }); const rollLine = (rolls: Array<{ statId: string; value: number }>) => rolls @@ -56,11 +57,11 @@
WEAPONS02 SLOTS
- {#each data.loadout.weapons as selection, index}{@const item=weapon(selection.itemId)}
{index ? 'SECONDARY' : 'PRIMARY'}{item?.name ?? 'EMPTY SLOT'}{item ? `${item.category} · ${item.damage_type} · T${selection.tier} · LEVEL ${selection.level}` : 'NOT CONFIGURED'}{#if item}
{number.format(selection.damage)} DAMAGE{item.rpm} RPM{item.magazine} ROUNDS{item.reload_speed}s RELOAD
{coreLine(selection)}{rollLine(selection.rolls) ? ` · ${rollLine(selection.rolls)}` : ''}{/if}
{/each} + {#each data.loadout.weapons as selection, index}{@const item=weapon(selection.itemId)}
{index ? 'SECONDARY' : 'PRIMARY'}{item?.name ?? 'EMPTY SLOT'}{item ? `${item.category} · ${item.damage_type} · T${selection.tier} · LEVEL ${selection.level}` : 'NOT CONFIGURED'}{#if item}
{number.format(selection.damage)} DAMAGE{item.rpm} RPM{item.magazine} ROUNDS{item.reload_speed}s RELOAD{#if selection.talent1Id}{talent(selection.talent1Id)?.name ?? 'TALENT 1'} · T{selection.talent1Tier}{/if}{#if selection.talent2Id}{talent(selection.talent2Id)?.name ?? 'TALENT 2'} · T{selection.talent2Tier}{/if}{#if item.exotic_talent_id}{talent(item.exotic_talent_id)?.name ?? 'EXOTIC TALENT'} · T{selection.exoticTalentTier}{/if}
{coreLine(selection)}{rollLine(selection.rolls) ? ` · ${rollLine(selection.rolls)}` : ''}{/if}
{/each}
GEAR06 SLOTS
- {#each gearSlots as slot}{@const selection=data.loadout.gear[slot]}{@const item=gear(selection.itemId)}
{slot.toUpperCase()}{item?.name ?? 'EMPTY SLOT'}{item ? `${brand(selection.brandId)?.name ?? 'NO BRAND'} · T${item.tier} · LEVEL ${selection.level}` : 'NOT CONFIGURED'}{#if item}
{number.format(selection.health)} HEALTH{#if item.base_armor_min !== null}{number.format(selection.armor)} ARMOR{/if}
{coreLine(selection)}{rollLine(selection.rolls) ? ` · ${rollLine(selection.rolls)}` : ''}{/if}
{/each} + {#each gearSlots as slot}{@const selection=data.loadout.gear[slot]}{@const item=gear(selection.itemId)}
{slot.toUpperCase()}{item?.name ?? 'EMPTY SLOT'}{item ? `${brand(selection.brandId)?.name ?? 'NO BRAND'} · T${item.tier} · LEVEL ${selection.level}` : 'NOT CONFIGURED'}{#if item}
{number.format(selection.health)} HEALTH{#if item.base_armor_min !== null}{number.format(selection.armor)} ARMOR{/if}{#if selection.talentId}{talent(selection.talentId)?.name ?? 'TALENT'} · T{selection.talentTier}{/if}
{coreLine(selection)}{rollLine(selection.rolls) ? ` · ${rollLine(selection.rolls)}` : ''}{/if}
{/each}
AGENT SYSTEMS10 SLOTS