装备加成错误解决
This commit is contained in:
@@ -111,20 +111,49 @@ export class EquipsComp extends Component {
|
||||
count_attrs(){
|
||||
// 重置所有属性
|
||||
this.reset_attrs();
|
||||
console.log("重置后的属性", this.attrs);
|
||||
|
||||
// 获取所有装备的属性
|
||||
let weapon_attrs = this.weapon.uuid ? EquipInfo[this.weapon.uuid]?.attributes || [] : [];
|
||||
let armor_attrs = this.armor.uuid ? EquipInfo[this.armor.uuid]?.attributes || [] : [];
|
||||
let accessory_attrs = this.accessory.uuid ? EquipInfo[this.accessory.uuid]?.attributes || [] : [];
|
||||
|
||||
console.log("武器属性", weapon_attrs);
|
||||
console.log("防具属性", armor_attrs);
|
||||
console.log("饰品属性", accessory_attrs);
|
||||
|
||||
// 合并所有装备属性
|
||||
const allAttrs = [...weapon_attrs, ...armor_attrs, ...accessory_attrs];
|
||||
console.log("合并后的所有属性", allAttrs);
|
||||
|
||||
// 计算每个目标的属性加成
|
||||
allAttrs.forEach(attr => {
|
||||
const target = attr.target || EquipAttrTarget.ALL;
|
||||
const targetKey = this.getTargetKey(target);
|
||||
let targetKey = null;
|
||||
|
||||
// 根据目标类型获取对应的key
|
||||
switch (target) {
|
||||
case EquipAttrTarget.ALL:
|
||||
targetKey = 'ally';
|
||||
break;
|
||||
case EquipAttrTarget.HERO:
|
||||
targetKey = 'hero';
|
||||
break;
|
||||
case EquipAttrTarget.FRIEND:
|
||||
targetKey = 'friend';
|
||||
break;
|
||||
case EquipAttrTarget.ENEMY:
|
||||
targetKey = 'enemy';
|
||||
break;
|
||||
}
|
||||
|
||||
console.log("处理属性加成", {
|
||||
target: target,
|
||||
targetKey: targetKey,
|
||||
attr: attr,
|
||||
beforeValue: targetKey ? this.attrs[targetKey][BuffAttr[attr.type]] : null
|
||||
});
|
||||
|
||||
if (targetKey) {
|
||||
switch (attr.type) {
|
||||
case BuffAttr.ATK:
|
||||
@@ -155,32 +184,39 @@ export class EquipsComp extends Component {
|
||||
this.attrs[targetKey].CARD_COUNT += attr.value;
|
||||
break;
|
||||
}
|
||||
|
||||
console.log("属性加成后", {
|
||||
targetKey: targetKey,
|
||||
attrType: BuffAttr[attr.type],
|
||||
afterValue: this.attrs[targetKey][BuffAttr[attr.type]]
|
||||
});
|
||||
}
|
||||
});
|
||||
console.log("count_attrs",this.attrs)
|
||||
oops.message.dispatchEvent(GameEvent.EquipChange,this.attrs)
|
||||
console.log("最终属性加成", this.attrs);
|
||||
oops.message.dispatchEvent(GameEvent.EquipChange, this.attrs);
|
||||
}
|
||||
|
||||
// 重置所有属性为0
|
||||
private reset_attrs() {
|
||||
this.attrs.hero=this.attrs.ally=this.attrs.enemy=this.attrs.friend=getBuffNum()
|
||||
// 创建新的属性对象
|
||||
const newAttrs = {
|
||||
hero: getBuffNum(),
|
||||
ally: getBuffNum(),
|
||||
enemy: getBuffNum(),
|
||||
friend: getBuffNum()
|
||||
};
|
||||
|
||||
// 替换整个 attrs 对象
|
||||
this.attrs = newAttrs;
|
||||
|
||||
console.log("重置属性", {
|
||||
hero: this.attrs.hero,
|
||||
ally: this.attrs.ally,
|
||||
enemy: this.attrs.enemy,
|
||||
friend: this.attrs.friend
|
||||
});
|
||||
}
|
||||
|
||||
// 根据目标类型获取对应的key
|
||||
private getTargetKey(target: EquipAttrTarget): string | null {
|
||||
switch (target) {
|
||||
case EquipAttrTarget.ALL:
|
||||
return 'hero'; // 默认作用于英雄
|
||||
case EquipAttrTarget.HERO:
|
||||
return 'hero';
|
||||
case EquipAttrTarget.FRIEND:
|
||||
return 'friend';
|
||||
case EquipAttrTarget.ENEMY:
|
||||
return 'enemy';
|
||||
default:
|
||||
return null;
|
||||
}
|
||||
}
|
||||
equip_remove(e:GameEvent,data:any){
|
||||
console.log("equip_remove",data)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user