refactor(属性系统): 重构英雄属性系统,将属性定义移至HeroAttrs模块
- 将Attrs和DBuff相关定义从SkillSet迁移至HeroAttrs - 新增NeAttrs枚举用于管理负面状态 - 重构HeroViewComp中的buff/debuff处理逻辑 - 优化属性分类和分组,增加新属性类型 - 移除旧的DBuff相关代码,改用统一的负面状态管理
This commit is contained in:
@@ -1,3 +1,5 @@
|
||||
// ========== 从 HeroAttrs.ts 导入属性相关定义 ==========
|
||||
import { Attrs, NeAttrs,BType, getAttrs, AttrsType, isRatioAttr } from "./HeroAttrs";
|
||||
export enum TGroup {
|
||||
Self = 0, // 自身
|
||||
Ally = 1, // 所有敌人
|
||||
@@ -70,72 +72,7 @@ export enum EType {
|
||||
}
|
||||
//debuff类型
|
||||
|
||||
export enum DBuff {
|
||||
STUN = 1, //眩晕 - 对应Attrs.CON_RES (控制抗性), BType.RATIO
|
||||
SLOW = 2, //减速 - 对应Attrs.AS (攻击速度), BType.RATIO
|
||||
FROST = 3, //冰冻 - 对应Attrs.ICE_RES (冰冻抗性), BType.RATIO
|
||||
BURN = 4, //易伤 - 对应Attrs.DEF/MDEF (防御/魔防), BType.RATIO, 默认次数是5, 技能配置的devC是额外次数
|
||||
AS = 5, //减速 - 对应Attrs.AS (攻击速度), BType.RATIO, 直接+技能cd
|
||||
HP_MAX = 6, //减hp - 对应Attrs.HP_MAX (最大生命值), BType.RATIO
|
||||
AP = 7, //减atk - 对应Attrs.AP (攻击力), BType.RATIO
|
||||
MGP = 8, //减魔法伤害 - 对应Attrs.MAP (魔法攻击力), BType.RATIO
|
||||
DEBACK = 9, //击退概率 - 对应Attrs.BACK (击退概率), BType.RATIO
|
||||
CRITICAL = 10, //-暴击率 - 对应Attrs.CRITICAL (暴击率), BType.RATIO
|
||||
CRIT_DAMAGE = 11, //-暴击伤害 - 对应Attrs.CRITICAL_DMG (暴击伤害), BType.RATIO
|
||||
DODGE = 12, //-闪避 - 对应Attrs.DODGE (闪避), BType.RATIO
|
||||
DBUFFUP = 13, //edbuff效果提升
|
||||
BUFF_DOWN = 14,// buff效果减弱
|
||||
SPEED = 15, //移动速度下降 - 对应Attrs.MOVE_SPEED (移动速度), BType.RATIO
|
||||
DEBURN = 16, //被攻击带易伤
|
||||
}
|
||||
|
||||
// ========== 从 HeroAttrs.ts 导入属性相关定义 ==========
|
||||
import { Attrs, BType, getAttrs, AttrsType, isRatioAttr } from "./HeroAttrs";
|
||||
|
||||
// ========== 为向后兼容性重新导出 ==========
|
||||
export { Attrs, BType, getAttrs, AttrsType, isRatioAttr };
|
||||
|
||||
|
||||
/**
|
||||
* DBuff 与 Attrs 的双向映射关系表
|
||||
* 格式:[DBuff, Attrs 或 -1(状态类)]
|
||||
*/
|
||||
const DEBUFF_ATTR_MAP: [DBuff, number][] = [
|
||||
[DBuff.STUN, -1], // 眩晕 - 状态类
|
||||
[DBuff.SLOW, Attrs.SPEED], // 减速 -> 速度
|
||||
[DBuff.FROST, -1], // 冰冻 - 状态类
|
||||
[DBuff.DEBURN, Attrs.DEBURN], // 被易伤 -> 被易伤
|
||||
[DBuff.BURN, Attrs.BURN], // 易伤 -> 易伤效果
|
||||
[DBuff.AS, Attrs.AS], // 减cd -> 攻击速度
|
||||
[DBuff.HP_MAX, Attrs.HP_MAX], // 减hp -> 最大生命值
|
||||
[DBuff.AP, Attrs.AP], // 减atk -> 攻击力
|
||||
[DBuff.MGP, Attrs.MAP], // 减魔法 -> 魔法攻击力
|
||||
[DBuff.DEBACK, Attrs.DEBACK], // 被击退 -> 被击退概率
|
||||
[DBuff.CRITICAL, Attrs.CRITICAL], // -暴击率 -> 暴击率
|
||||
[DBuff.CRIT_DAMAGE, Attrs.CRITICAL_DMG], // -暴击伤害 -> 暴击伤害
|
||||
[DBuff.DODGE, Attrs.DODGE], // -闪避 -> 闪避
|
||||
[DBuff.DBUFFUP, Attrs.DBUFF_UP], // debuff提升 -> debuff提升
|
||||
[DBuff.BUFF_DOWN, Attrs.BUFF_UP], // buff减弱 -> buff效果
|
||||
[DBuff.SPEED, Attrs.SPEED], // 移动速度下降 -> 移动速度
|
||||
];
|
||||
|
||||
/**
|
||||
* 双向转换:DBuff ⇄ Attrs
|
||||
* @param key DBuff 或 Attrs 枚举值
|
||||
* @param isDebuff true: key 是 DBuff, false: key 是 Attrs
|
||||
* @returns 对应的转换值,未找到则返回 -1
|
||||
*/
|
||||
export const TransformBuffs = (key: number, isDebuff: boolean): number => {
|
||||
if (isDebuff) {
|
||||
// DBuff → Attrs
|
||||
const found = DEBUFF_ATTR_MAP.find(([debuff]) => debuff === key);
|
||||
return found ? found[1] : -1;
|
||||
} else {
|
||||
// Attrs → DBuff(只返回第一个匹配)
|
||||
const found = DEBUFF_ATTR_MAP.find(([, attr]) => attr === key);
|
||||
return found ? found[0] : -1;
|
||||
}
|
||||
};
|
||||
|
||||
/*
|
||||
=== 技能配置系统使用说明 ===
|
||||
@@ -166,24 +103,15 @@ export const TransformBuffs = (key: number, isDebuff: boolean): number => {
|
||||
- hitcd: 持续伤害的伤害间隔
|
||||
- speed: 移动速度
|
||||
- cost: 消耗值
|
||||
|
||||
|
||||
*/
|
||||
export enum DType {
|
||||
ATK= 0, // 物理
|
||||
MAGE=1, // 魔法
|
||||
}
|
||||
|
||||
export const HeroSkillList = [6001,6001,6001,6001,6001,6001]
|
||||
|
||||
// Debuff配置接口
|
||||
export interface DbuffConf {
|
||||
debuff: DBuff; // debuff类型
|
||||
BType:BType //buff是数值型还是百分比型
|
||||
value: number; // 效果值
|
||||
time: number; // 持续时间
|
||||
chance: number; // 触发概率
|
||||
}
|
||||
|
||||
export interface BuffConf {
|
||||
buff:Attrs;
|
||||
BType:BType
|
||||
@@ -191,11 +119,16 @@ export interface BuffConf {
|
||||
time:number; // 持续时间
|
||||
chance:number; // 触发概率
|
||||
}
|
||||
export interface NeAttrsConf {
|
||||
neAttrs:NeAttrs;
|
||||
value:number;
|
||||
time:number;
|
||||
}
|
||||
// 技能配置接口 - 按照6001格式排列
|
||||
export interface SkillConfig {
|
||||
uuid:number,name:string,sp_name:string,AtkedName:AtkedName,path:string,TGroup:TGroup,SType:SType,act:string,DTType:DTType,DType:DType,
|
||||
ap:number,cd:number,t_num:number,hit_num:number,hit:number,hitcd:number,speed:number,cost:number,with:number,
|
||||
buffs:BuffConf[],debuffs:DbuffConf[],info:string,hero?:number
|
||||
buffs:BuffConf[],neAttrs:NeAttrsConf[],info:string,hero?:number
|
||||
}
|
||||
|
||||
|
||||
@@ -204,12 +137,12 @@ export const SkillSet: Record<number, SkillConfig> = {
|
||||
6001: {
|
||||
uuid:6001,name:"挥击",sp_name:"atk_s1",AtkedName:AtkedName.atked,path:"3036",TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,DType:DType.ATK,
|
||||
ap:100,cd:1,t_num:1,hit_num:1,hit:1,hitcd:0.2,speed:720,cost:0,with:0,
|
||||
buffs:[],debuffs:[],info:"向最前方敌人扔出石斧,造成100%攻击的伤害"
|
||||
buffs:[],neAttrs:[],info:"向最前方敌人扔出石斧,造成100%攻击的伤害"
|
||||
},
|
||||
6005: {
|
||||
uuid:6005,name:"火球术",sp_name:"atk_fires",AtkedName:AtkedName.atked,path:"3039",TGroup:TGroup.Enemy,SType:SType.damage,act:"atk",DTType:DTType.single,DType:DType.MAGE,
|
||||
ap:100,cd:5,t_num:1,hit_num:1,hit:2,hitcd:0.3,speed:720,cost:20,with:90,
|
||||
buffs:[],debuffs:[],info:"召唤大火球攻击前方所有敌人,造成300%攻击的伤害,有一定几率施加灼烧"
|
||||
buffs:[],neAttrs:[],info:"召唤大火球攻击前方所有敌人,造成300%攻击的伤害,有一定几率施加灼烧"
|
||||
},
|
||||
|
||||
};
|
||||
Reference in New Issue
Block a user