refactor(hero): 优化Buff和Debuff的数据结构及处理逻辑

- 新增移动速度相关属性:DBuff.SPEED和Attrs.SPEED
- 修改BattleMoveSystem中移动速度计算,支持速度百分比加成
- Buff和Debuff由数组改为基于属性键的对象存储,方便访问和合并处理
- 持久型Buff/Debuff累加数值或百分比,临时型则累加并刷新剩余时间
- 重新计算属性时遍历键值对,跳过状态类debuff(attrField=-1)
- 更新临时型Buff/Debuff剩余时间,过期时从对象中删除
- 代码结构更清晰,访问及更新性能提升
This commit is contained in:
2025-10-17 10:27:21 +08:00
parent d8ba69aada
commit 6386d6bd80
3 changed files with 134 additions and 84 deletions

View File

@@ -111,6 +111,7 @@ export enum DBuff {
DODGE = 12, //-闪避 - 对应Attrs.DODGE (闪避), BType.RATIO
DBUFFUP=13, //edbuff效果提升
BUFF_DOWN = 14,// buff效果减弱
SPEED = 15, //移动速度下降 - 对应Attrs.MOVE_SPEED (移动速度), BType.RATIO
}
@@ -142,6 +143,7 @@ export enum Attrs {
BUFF_UP = 24, //buff效果提升
DBUFF_UP=25, //debuff效果提升
DIS=26, //攻击距离
SPEED = 27, //移动速度加成,默认都是百分比
}
export const getAttrs=()=>{
@@ -172,9 +174,7 @@ export const getAttrFieldFromDebuff = (debuffType: DBuff): number => {
// 状态类 debuff只需缓存不影响属性
const stateDebuffSet = new Set<DBuff>([
DBuff.STUN,
DBuff.SLOW,
DBuff.FROST,
DBuff.BURN,
]);
// 检查是否是状态类 debuff
@@ -200,6 +200,8 @@ export const getAttrFieldFromDebuff = (debuffType: DBuff): number => {
[DBuff.DODGE]: Attrs.DODGE, // -闪避 -> 闪避
[DBuff.DBUFFUP]: Attrs.DBUFF_UP, // debuff提升 -> debuff提升
[DBuff.BUFF_DOWN]: Attrs.BUFF_UP, // buff减弱 -> buff效果
[DBuff.SPEED]: Attrs.SPEED, // 移动速度下降 -> 移动速度
};
const attrField = debuffAttrMap[debuffType];