feat(物品系统): 重构药水系统并移除旧物品配置
将药水物品从ItemSet迁移到AttrSet作为PotionCards,并实现新的药水使用逻辑 移除已废弃的ItemSet.ts文件
This commit is contained in:
@@ -27,7 +27,25 @@ import { Attrs } from "./HeroAttrs";
|
|||||||
2014:{uuid:2014, icon:"1020", attr: Attrs.MANASTEAL, value: 10, showValue: 10, desc: "吸蓝比例 +10%", isSpecial: true, note: "上限50%" },
|
2014:{uuid:2014, icon:"1020", attr: Attrs.MANASTEAL, value: 10, showValue: 10, desc: "吸蓝比例 +10%", isSpecial: true, note: "上限50%" },
|
||||||
}
|
}
|
||||||
|
|
||||||
export const CanSelectAttrs: Record<number, number[]> = {
|
export interface PotionInfo extends AttrInfo {
|
||||||
|
duration: number; // 持续时间
|
||||||
|
}
|
||||||
|
|
||||||
|
export const PotionCards: Record<number, PotionInfo> = {
|
||||||
|
// 持续时间20秒的强力药水
|
||||||
|
3001: { uuid: 3001, icon: "1020", attr: Attrs.AP, value: 50, showValue: 50, desc: "20秒内攻击力 +50%", isSpecial: false, note: "狂暴药水", duration: 20 },
|
||||||
|
3002: { uuid: 3002, icon: "1020", attr: Attrs.AS, value: 50, showValue: 50, desc: "20秒内攻速 +50%", isSpecial: false, note: "急速药水", duration: 20 },
|
||||||
|
3003: { uuid: 3003, icon: "1020", attr: Attrs.DEF, value: 50, showValue: 50, desc: "20秒内防御 +50%", isSpecial: false, note: "金钟罩", duration: 20 },
|
||||||
|
3004: { uuid: 3004, icon: "1020", attr: Attrs.SPEED, value: 50, showValue: 50, desc: "20秒内移速 +50%", isSpecial: false, note: "神行药水", duration: 20 },
|
||||||
|
|
||||||
|
// 持续时间60秒的普通药水
|
||||||
|
3005: { uuid: 3005, icon: "1020", attr: Attrs.AP, value: 20, showValue: 20, desc: "60秒内攻击力 +20%", isSpecial: false, note: "力量药剂", duration: 60 },
|
||||||
|
3006: { uuid: 3006, icon: "1020", attr: Attrs.AS, value: 20, showValue: 20, desc: "60秒内攻速 +20%", isSpecial: false, note: "敏捷药剂", duration: 60 },
|
||||||
|
3007: { uuid: 3007, icon: "1020", attr: Attrs.DEF, value: 20, showValue: 20, desc: "60秒内防御 +20%", isSpecial: false, note: "护甲药剂", duration: 60 },
|
||||||
|
3008: { uuid: 3008, icon: "1020", attr: Attrs.SPEED, value: 20, showValue: 20, desc: "60秒内移速 +20%", isSpecial: false, note: "轻灵药剂", duration: 60 },
|
||||||
|
};
|
||||||
|
|
||||||
|
export const CanSelectAttrs: Record<number, number[]> = {
|
||||||
// 基础属性
|
// 基础属性
|
||||||
2: [2001, 2002, 2003, 2004],
|
2: [2001, 2002, 2003, 2004],
|
||||||
// 混合
|
// 混合
|
||||||
|
|||||||
@@ -1,105 +0,0 @@
|
|||||||
import { Attrs, BType } from "./HeroAttrs";
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 物品配置接口
|
|
||||||
*/
|
|
||||||
export interface ItemConf {
|
|
||||||
id: number;
|
|
||||||
name: string;
|
|
||||||
desc: string;
|
|
||||||
price: number;
|
|
||||||
duration: number; // 持续时间(秒)
|
|
||||||
attr: Attrs; // 提升的属性
|
|
||||||
value: number; // 提升的值
|
|
||||||
bType: BType; // 值类型(数值/百分比)
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 物品配置表
|
|
||||||
* 20秒强效果,60秒弱效果
|
|
||||||
*/
|
|
||||||
export const ItemSet: Record<number, ItemConf> = {
|
|
||||||
// ==================== 20秒强效果 (价格: 100) ====================
|
|
||||||
1001: {
|
|
||||||
id: 1001,
|
|
||||||
name: "狂暴药水",
|
|
||||||
desc: "20秒内攻击力+50%",
|
|
||||||
price: 100,
|
|
||||||
duration: 20,
|
|
||||||
attr: Attrs.AP,
|
|
||||||
value: 50,
|
|
||||||
bType: BType.RATIO
|
|
||||||
},
|
|
||||||
1002: {
|
|
||||||
id: 1002,
|
|
||||||
name: "急速药水",
|
|
||||||
desc: "20秒内攻速+50%",
|
|
||||||
price: 100,
|
|
||||||
duration: 20,
|
|
||||||
attr: Attrs.AS,
|
|
||||||
value: 50,
|
|
||||||
bType: BType.RATIO
|
|
||||||
},
|
|
||||||
1003: {
|
|
||||||
id: 1003,
|
|
||||||
name: "金钟罩",
|
|
||||||
desc: "20秒内防御+50%",
|
|
||||||
price: 100,
|
|
||||||
duration: 20,
|
|
||||||
attr: Attrs.DEF,
|
|
||||||
value: 50,
|
|
||||||
bType: BType.RATIO
|
|
||||||
},
|
|
||||||
1004: {
|
|
||||||
id: 1004,
|
|
||||||
name: "神行药水",
|
|
||||||
desc: "20秒内移速+50%",
|
|
||||||
price: 100,
|
|
||||||
duration: 20,
|
|
||||||
attr: Attrs.SPEED,
|
|
||||||
value: 50,
|
|
||||||
bType: BType.RATIO
|
|
||||||
},
|
|
||||||
|
|
||||||
// ==================== 60秒弱效果 (价格: 50) ====================
|
|
||||||
2001: {
|
|
||||||
id: 2001,
|
|
||||||
name: "力量药剂",
|
|
||||||
desc: "60秒内攻击力+20%",
|
|
||||||
price: 50,
|
|
||||||
duration: 60,
|
|
||||||
attr: Attrs.AP,
|
|
||||||
value: 20,
|
|
||||||
bType: BType.RATIO
|
|
||||||
},
|
|
||||||
2002: {
|
|
||||||
id: 2002,
|
|
||||||
name: "敏捷药剂",
|
|
||||||
desc: "60秒内攻速+20%",
|
|
||||||
price: 50,
|
|
||||||
duration: 60,
|
|
||||||
attr: Attrs.AS,
|
|
||||||
value: 20,
|
|
||||||
bType: BType.RATIO
|
|
||||||
},
|
|
||||||
2003: {
|
|
||||||
id: 2003,
|
|
||||||
name: "护甲药剂",
|
|
||||||
desc: "60秒内防御+20%",
|
|
||||||
price: 50,
|
|
||||||
duration: 60,
|
|
||||||
attr: Attrs.DEF,
|
|
||||||
value: 20,
|
|
||||||
bType: BType.RATIO
|
|
||||||
},
|
|
||||||
2004: {
|
|
||||||
id: 2004,
|
|
||||||
name: "轻灵药剂",
|
|
||||||
desc: "60秒内移速+20%",
|
|
||||||
price: 50,
|
|
||||||
duration: 60,
|
|
||||||
attr: Attrs.SPEED,
|
|
||||||
value: 20,
|
|
||||||
bType: BType.RATIO
|
|
||||||
},
|
|
||||||
};
|
|
||||||
@@ -6,8 +6,7 @@ import { BuffConf, SkillRange } from "../common/config/SkillSet";
|
|||||||
import { HeroInfo, AttrSet } from "../common/config/heroSet";
|
import { HeroInfo, AttrSet } from "../common/config/heroSet";
|
||||||
import { HeroSkillsComp } from "./HeroSkills";
|
import { HeroSkillsComp } from "./HeroSkills";
|
||||||
import { smc } from "../common/SingletonModuleComp";
|
import { smc } from "../common/SingletonModuleComp";
|
||||||
import { ItemSet } from "../common/config/ItemSet";
|
import { AttrCards, PotionCards } from "../common/config/AttrSet";
|
||||||
import { AttrCards } from "../common/config/AttrSet";
|
|
||||||
|
|
||||||
|
|
||||||
interface talTrigger{
|
interface talTrigger{
|
||||||
@@ -111,7 +110,23 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
|
|
||||||
onUseItemCard(event: string, args: any) {
|
onUseItemCard(event: string, args: any) {
|
||||||
if (!this.is_master) return;
|
if (!this.is_master) return;
|
||||||
this.useItem(args);
|
const itemId = args;
|
||||||
|
|
||||||
|
// 1. 尝试从 PotionCards 获取 (新版药水)
|
||||||
|
const potion = PotionCards[itemId];
|
||||||
|
if (potion) {
|
||||||
|
console.log(`[HeroAttrs] 使用药水: ${potion.desc}`);
|
||||||
|
const buffConf: BuffConf = {
|
||||||
|
buff: potion.attr,
|
||||||
|
value: potion.value,
|
||||||
|
BType: BType.RATIO, // 药水默认是百分比加成
|
||||||
|
time: potion.duration,
|
||||||
|
chance: 1,
|
||||||
|
};
|
||||||
|
this.addBuff(buffConf);
|
||||||
|
oops.gui.toast(potion.desc);
|
||||||
|
return;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -613,35 +628,7 @@ export class HeroAttrsComp extends ecs.Comp {
|
|||||||
this.recalculateSingleAttr(buff.attrIndex);
|
this.recalculateSingleAttr(buff.attrIndex);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* 使用物品
|
|
||||||
* @param itemId 物品ID
|
|
||||||
*/
|
|
||||||
useItem(itemId: number) {
|
|
||||||
const item = ItemSet[itemId];
|
|
||||||
if (!item) return;
|
|
||||||
|
|
||||||
console.log(`[HeroAttrs] 使用物品: ${item.name} (${item.desc})`);
|
|
||||||
|
|
||||||
// 直接添加到 BUFFS_TEMP
|
|
||||||
const attrIndex = item.attr;
|
|
||||||
|
|
||||||
if (!this.BUFFS_TEMP[attrIndex]) {
|
|
||||||
this.BUFFS_TEMP[attrIndex] = [];
|
|
||||||
}
|
|
||||||
|
|
||||||
this.BUFFS_TEMP[attrIndex].push({
|
|
||||||
value: item.value,
|
|
||||||
BType: item.bType,
|
|
||||||
remainTime: item.duration
|
|
||||||
});
|
|
||||||
|
|
||||||
// 重新计算受影响的属性
|
|
||||||
this.recalculateSingleAttr(attrIndex);
|
|
||||||
|
|
||||||
oops.gui.toast(`使用了 ${item.name}`);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 根据属性索引移除数值型天赋buff
|
* 根据属性索引移除数值型天赋buff
|
||||||
* @param attrIndex 属性索引
|
* @param attrIndex 属性索引
|
||||||
|
|||||||
Reference in New Issue
Block a user