fix(game): 修复属性卡Buff类型错误,统一使用VALUE类型

属性卡(AttrCards)配置的值始终代表绝对数值增量,无论属性本身是数值型还是百分比型。之前存在混淆,通过添加AttrsType引入并移除冗余注释,明确使用BType.VALUE确保计算正确。
This commit is contained in:
panw
2026-02-03 16:21:47 +08:00
parent 0ce80dd42a
commit b4bf2b2904

View File

@@ -13,6 +13,7 @@ import { HeroAttrsComp } from "../hero/HeroAttrsComp";
import { BuffConf } from "../common/config/SkillSet";
import { BType } from "../common/config/HeroAttrs";
import { AttrCards, PotionCards } from "../common/config/AttrSet";
import { AttrsType } from "../common/config/HeroAttrs";
import { HeroMasterComp } from "../hero/HeroMasterComp";
@@ -510,48 +511,20 @@ export class MissionCardComp extends CCComp {
// 记录变更前状态
const roleBefore = attrsComp.Attrs[attrCard.attr] || 0;
// 根据属性类型决定 Buff 类型
// 如果属性本身是 RATIO 型如暴击率AttrCards 中的值如2应该作为 VALUE 添加(因为 recalculateSingleAttr 会把 VALUE 和 RATIO 相加)
// 但如果属性本身是 VALUE 型如攻击力AttrCards 中的值是直接加数值,也应该作为 VALUE 添加
// 结论无论属性类型如何AttrCards 中的配置都是"增加的点数",所以统一使用 BType.VALUE
// 修正:虽然 AttrsType 定义了属性本身的类型,但在 addBuff 中BType.VALUE 表示"加法叠加"BType.RATIO 表示"乘法叠加"
// 对于数值型属性如攻击力BType.VALUE 是 +10BType.RATIO 是 +10%
// 对于百分比型属性如暴击率BType.VALUE 是 +2(%)BType.RATIO 是 +2%(即 *1.02,通常不这么用)
// 所以AttrCards 配置的值应当被视为"绝对值增量",对应 BType.VALUE
// 构造永久 Buff (time: 0)
const buffConf: BuffConf = {
buff: attrCard.attr,
value: attrCard.value,
// 注意:这里需要根据属性类型决定是 VALUE 还是 RATIO
// 通常 AttrCards 里的 value 如果是百分比属性(如暴击率),配置值可能是 2 (代表2%)
// HeroAttrsComp.addBuff 会根据 BType 累加
// 为了安全,我们可以查一下 AttrsType或者默认属性卡都是 VALUE (直接加数值) 或 RATIO (百分比)
// 根据 AttrSet.tsAttrCards 的 value 是直接数值。
// 而 HeroAttrsComp.recalculateSingleAttr 中RATIO 类型的属性也是直接加 totalRatio
// 所以这里关键是 buffConf.BType。
// 如果我们希望属性卡是"基础值加成"(VALUE) 还是 "百分比加成"(RATIO)
// 查看 AttrSet.ts: 2003 DEF value: 2 desc: "防御力 +2%" -> 看起来是百分比
// 2001 AP value: 10 desc: "攻击力 +10" -> 看起来是数值
// 所以需要根据 attrCard.attr 的类型来决定 BType或者在 AttrCards 配置中增加 BType 字段
// 目前 AttrInfo 接口没有 BType。
// 我们可以引入 AttrsType 来判断默认类型,或者全部作为 VALUE (如果是百分比属性VALUE也是加到数值上的)
// 修正HeroAttrsComp.recalculateSingleAttr 中:
// isRatioAttr = AttrsType[attrIndex] === BType.RATIO
// 如果是 RATIO 属性totalValue + totalRatio
// 如果是 VALUE 属性totalValue * (1 + totalRatio/100)
// 策略:
// 如果是数值型属性如HP, AP属性卡通常是加固定值 -> BType.VALUE
// 如果是百分比型属性(如暴击率),属性卡加的是点数 -> BType.VALUE (因为最终计算是 totalValue + totalRatio对于百分比属性 totalValue 就是基础点数)
// 等等recalculateSingleAttr 对 RATIO 属性是 totalValue + totalRatio
// 如果暴击率基础是 0加 2%暴击率。
// 如果用 BType.VALUE, totalValue += 2。 结果 = 2 + 0 = 2。正确。
// 如果用 BType.RATIO, totalRatio += 2。 结果 = 0 + 2 = 2。也正确。
// 但是对于数值型属性如AP
// 攻击力 +10。
// 用 BType.VALUE, totalValue += 10。 结果 = (Base+10) * (1+Ratio)。正确。
// 用 BType.RATIO, totalRatio += 10。 结果 = Base * (1+10/100) = Base * 1.1。这是加10%不是加10点。
// 结论AttrCards 中的 value 看起来都是"点数"或"绝对值",所以应该统一使用 BType.VALUE。
// 即使是 "防御力 +2%" (2003),如果 DEF 是 RATIO 类型AttrSet.ts里定义为RATIO? 不DEF通常是混合但这里AttrsType定义DEF是RATIO? 让我们查一下)
// 查 AttrsType: [Attrs.DEF]: BType.RATIO
// 如果 DEF 是 RATIO那 +2% 就是 +2 数值。
// 所以统一用 BType.VALUE 是安全的,代表"增加属性面板数值"。
BType: BType.VALUE,
BType: BType.VALUE, // 始终使用 VALUE 类型,代表数值/点数叠加
time: 0,
chance: 1,
};