fix(game): 修复属性卡Buff类型错误,统一使用VALUE类型
属性卡(AttrCards)配置的值始终代表绝对数值增量,无论属性本身是数值型还是百分比型。之前存在混淆,通过添加AttrsType引入并移除冗余注释,明确使用BType.VALUE确保计算正确。
This commit is contained in:
@@ -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 是 +10,BType.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.ts,AttrCards 的 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,
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user