feat(tooltip/stats): 武器与防具基础属性增强显示(支持ED%/需求增减及原始底模对照展示) #123

Closed
opened 2026-09-19 07:08:01 +00:00 by troytt · 1 comment
Owner

背景与现状

目前在装备展示面板(src/boss.ts 与 src/game/item-tooltip.ts)中:

  1. 武器伤害(One-Hand Damage / Two-Hand Damage)仅直接读取装备底模基准值(base.mindam / base.maxdam),未根据词缀中的增强伤害百分比(dmg% / Enhanced Damage)及额外最小/最大伤害(dmg-min, dmg-max)动态计算武器的真实面板物理伤害。
  2. 防具防御力(Defense)未根据增强防御百分比(ac% / Enhanced Defense)与附加平面防御(ac)计算实际防御力。
  3. 装备需求(Required Strength / Required Dexterity)未考虑需求减免词缀(如 ease / Requirements -X%,如镶嵌 15 号 Hel 符文或带有 of Simplicity 词缀);需求等级未综合底模与词缀的 levelreq 进行正确取大计算。
  4. 无法对比查看底模原始属性与词条增强后的真实面板属性。

暗黑2 1.13c 原版规范 (Ground Truth)

在暗黑2 1.13c 官方引擎规范(D2Common.dll)中:

  1. 武器物理伤害:
    • 基础伤害:baseMin, baseMax
    • 增强伤害:totalEd = sum(dmg%)
    • 平面加伤:flatMin = sum(dmg-min), flatMax = sum(dmg-max)
    • 最终面板最小伤害:finalMin = Math.floor(baseMin * (1 + totalEd / 100)) + flatMin
    • 最终面板最大伤害:finalMax = Math.floor(baseMax * (1 + totalEd / 100)) + flatMax(若 finalMin >= finalMax,则 finalMax = finalMin + 1)
    • 展示格式:若存在增强,应同时显示增强后的最终面板数值以及原始底模数值,如:Two-Hand Damage: 36 to 48 (18 to 24)。
  2. 防具基础防御:
    • 若防具天然或词缀带有 ac%(Enhanced Defense),底模防御基准值取 base.maxac + 1。
    • 最终防御:finalDef = Math.floor(baseDef * (1 + totalAcPct / 100)) + flatAc。
    • 展示格式:若存在防御增强,展示为:Defense: 260 (130)。
  3. 装备需求:
    • 最终力量需求:finalReqStr = Math.max(0, Math.floor(base.reqstr * (1 - easePct / 100)))。
    • 最终敏捷需求:finalReqDex = Math.max(0, Math.floor(base.reqdex * (1 - easePct / 100)))。
    • 展示格式:若需求被调整,展示为:Required Strength: 125 (156)。

待实现功能清单 (TODOs)

  • 在 src/game/item-tooltip.ts 中实现 computeItemEnhancedStats(item: Item),解析统计 dmg%, dmg-min, dmg-max, ac%, ac, ease。
  • 按照 1.13c 公式计算武器最终 1H/2H 伤害、防具最终防御力、最终力量与敏捷需求。
  • 扩展 FormattedItemTooltip 结构,携带 isEnhanced、增强后数值与原始底模数值。
  • 在 src/boss.ts 的 renderSingleItemCard 中支持增强属性与原始属性的并列显示(如 Two-Hand Damage: 36 to 48 (18 to 24),其中增强数值用暗黑原版魔法高亮色展示)。
  • 编写专项单元测试验证武器有/无 ED%、防具带有 ED%、需求降低等情境下的计算与展示格式。
## 背景与现状 目前在装备展示面板(`src/boss.ts` 与 `src/game/item-tooltip.ts`)中: 1. 武器伤害(`One-Hand Damage` / `Two-Hand Damage`)仅直接读取装备底模基准值(`base.mindam` / `base.maxdam`),未根据词缀中的增强伤害百分比(`dmg%` / Enhanced Damage)及额外最小/最大伤害(`dmg-min`, `dmg-max`)动态计算武器的真实面板物理伤害。 2. 防具防御力(`Defense`)未根据增强防御百分比(`ac%` / Enhanced Defense)与附加平面防御(`ac`)计算实际防御力。 3. 装备需求(`Required Strength` / `Required Dexterity`)未考虑需求减免词缀(如 `ease` / `Requirements -X%`,如镶嵌 15 号 Hel 符文或带有 of Simplicity 词缀);需求等级未综合底模与词缀的 `levelreq` 进行正确取大计算。 4. 无法对比查看底模原始属性与词条增强后的真实面板属性。 ## 暗黑2 1.13c 原版规范 (Ground Truth) 在暗黑2 1.13c 官方引擎规范(`D2Common.dll`)中: 1. **武器物理伤害**: - 基础伤害:`baseMin`, `baseMax` - 增强伤害:`totalEd = sum(dmg%)` - 平面加伤:`flatMin = sum(dmg-min)`, `flatMax = sum(dmg-max)` - 最终面板最小伤害:`finalMin = Math.floor(baseMin * (1 + totalEd / 100)) + flatMin` - 最终面板最大伤害:`finalMax = Math.floor(baseMax * (1 + totalEd / 100)) + flatMax`(若 `finalMin >= finalMax`,则 `finalMax = finalMin + 1`) - 展示格式:若存在增强,应同时显示增强后的最终面板数值以及原始底模数值,如:`Two-Hand Damage: 36 to 48 (18 to 24)`。 2. **防具基础防御**: - 若防具天然或词缀带有 `ac%`(Enhanced Defense),底模防御基准值取 `base.maxac + 1`。 - 最终防御:`finalDef = Math.floor(baseDef * (1 + totalAcPct / 100)) + flatAc`。 - 展示格式:若存在防御增强,展示为:`Defense: 260 (130)`。 3. **装备需求**: - 最终力量需求:`finalReqStr = Math.max(0, Math.floor(base.reqstr * (1 - easePct / 100)))`。 - 最终敏捷需求:`finalReqDex = Math.max(0, Math.floor(base.reqdex * (1 - easePct / 100)))`。 - 展示格式:若需求被调整,展示为:`Required Strength: 125 (156)`。 ## 待实现功能清单 (TODOs) - [ ] 在 `src/game/item-tooltip.ts` 中实现 `computeItemEnhancedStats(item: Item)`,解析统计 `dmg%`, `dmg-min`, `dmg-max`, `ac%`, `ac`, `ease`。 - [ ] 按照 1.13c 公式计算武器最终 1H/2H 伤害、防具最终防御力、最终力量与敏捷需求。 - [ ] 扩展 `FormattedItemTooltip` 结构,携带 `isEnhanced`、增强后数值与原始底模数值。 - [ ] 在 `src/boss.ts` 的 `renderSingleItemCard` 中支持增强属性与原始属性的并列显示(如 `Two-Hand Damage: 36 to 48 (18 to 24)`,其中增强数值用暗黑原版魔法高亮色展示)。 - [ ] 编写专项单元测试验证武器有/无 ED%、防具带有 ED%、需求降低等情境下的计算与展示格式。
Author
Owner

修复完成并验证通过 (Commit f68b1de)

  1. 武器 1H/2H 伤害、防具防御、力量/敏捷/等级需求与耐久度增强计算:
    • 武器伤害:finalMin = Math.floor(baseMin * (100 + totalEdPct) / 100) + flatMin,finalMax = Math.floor(baseMax * (100 + totalEdPct) / 100) + flatMax,展示为 Two-Hand Damage: 36 to 48 (18 to 24)。
    • 防具防御:finalDef = Math.floor(baseDef * (100 + totalAcPct) / 100) + flatAc,展示为 Defense: 260 (130)。
    • 装备需求:finalReq = Math.max(0, Math.floor(baseReq * (100 + easeSigned) / 100)),展示为 Required Strength: 124 (156)。
    • 装备耐久度:支持 3x/2x 降级与 dur/dur% 增强对照,展示为 Durability: 258 of 258 (86)。
  2. 专项单测 tests/item-tooltip-123-125.test.ts 与生产构建验证通过。
### 修复完成并验证通过 (Commit `f68b1de`) 1. **武器 1H/2H 伤害、防具防御、力量/敏捷/等级需求与耐久度增强计算**: - 武器伤害:`finalMin = Math.floor(baseMin * (100 + totalEdPct) / 100) + flatMin`,`finalMax = Math.floor(baseMax * (100 + totalEdPct) / 100) + flatMax`,展示为 `Two-Hand Damage: 36 to 48 (18 to 24)`。 - 防具防御:`finalDef = Math.floor(baseDef * (100 + totalAcPct) / 100) + flatAc`,展示为 `Defense: 260 (130)`。 - 装备需求:`finalReq = Math.max(0, Math.floor(baseReq * (100 + easeSigned) / 100))`,展示为 `Required Strength: 124 (156)`。 - 装备耐久度:支持 3x/2x 降级与 `dur`/`dur%` 增强对照,展示为 `Durability: 258 of 258 (86)`。 2. **专项单测 `tests/item-tooltip-123-125.test.ts` 与生产构建验证通过**。
Sign in to join this conversation.
No Label
No Milestone
No project
No Assignees
1 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: troytt/diablo2-web#123
No description provided.