feat(技能系统): 添加buff技能支持并增强属性变更日志

添加buff技能类型支持,包括目标选择、施放逻辑和效果应用
在HeroAttrsComp中增加属性变更的详细日志输出
为治疗和护盾技能添加执行日志
This commit is contained in:
walkpan
2026-01-01 14:40:13 +08:00
parent a5e6426296
commit a156ddfc2f
2 changed files with 101 additions and 1 deletions

View File

@@ -122,6 +122,7 @@ export class HeroAttrsComp extends ecs.Comp {
/*******************基础属性管理********************/
add_hp(value:number,isValue:boolean){
const oldHp = this.hp;
let addValue = value;
if(!isValue){
addValue = value * this.Attrs[Attrs.HP_MAX] / 100;
@@ -136,8 +137,10 @@ export class HeroAttrsComp extends ecs.Comp {
this.hp += addValue;
this.hp = Math.max(0, Math.min(this.hp, this.Attrs[Attrs.HP_MAX]));
this.dirty_hp = true; // ✅ 仅标记需要更新
console.log(`[HeroAttrs] HP变更: ${this.hero_name}, 变化=${addValue.toFixed(1)}, ${oldHp.toFixed(1)} -> ${this.hp.toFixed(1)}`);
}
add_mp(value:number,isValue:boolean){
const oldMp = this.mp;
let addValue = value;
if(!isValue){
addValue = value * this.Attrs[Attrs.MP_MAX] / 100;
@@ -152,14 +155,17 @@ export class HeroAttrsComp extends ecs.Comp {
this.mp += addValue;
this.mp = Math.max(0, Math.min(this.mp, this.Attrs[Attrs.MP_MAX]));
this.dirty_mp = true; // ✅ 仅标记需要更新
console.log(`[HeroAttrs] MP变更: ${this.hero_name}, 变化=${addValue.toFixed(1)}, ${oldMp.toFixed(1)} -> ${this.mp.toFixed(1)}`);
}
add_shield(value:number,isValue:boolean){
const oldShield = this.shield;
let addValue = value;
if(!isValue){
addValue = value * this.Attrs[Attrs.HP_MAX] / 100;
}
this.shield += addValue;
this.dirty_shield = true; // 标记护盾需要更新
console.log(`[HeroAttrs] 护盾变更: ${this.hero_name}, 变化=${addValue.toFixed(1)}, ${oldShield.toFixed(1)} -> ${this.shield.toFixed(1)}`);
}
// ==================== BUFF 管理 ====================
/**
@@ -213,6 +219,7 @@ export class HeroAttrsComp extends ecs.Comp {
* @param attrIndex 属性索引
*/
recalculateSingleAttr(attrIndex: number) {
const oldVal = this.Attrs[attrIndex] || 0;
const baseVal = this.getBaseValue(attrIndex);
// 2. 收集所有数值型 buff/debuff
@@ -281,6 +288,10 @@ export class HeroAttrsComp extends ecs.Comp {
// 5. 确保属性值合理
this.clampSingleAttr(attrIndex);
if (oldVal !== this.Attrs[attrIndex]) {
console.log(`[HeroAttrs] 属性重算: ${this.hero_name}, 属性ID=${attrIndex}, ${oldVal} -> ${this.Attrs[attrIndex]} (Base=${baseVal}, Add=${totalValue-baseVal}, Ratio=${totalRatio}%)`);
}
}
/**