Files
pixelheros/assets/script/game/common/config/TDLevelOptions.ts
walkpan 8eedc2b4dd feat(塔防): 添加属性配置和等级成长系统
添加塔防生效属性配置文件 TDEnabledAttrs.ts,集中管理游戏属性
实现塔防等级成长系统 TDLevelOptions.ts,包含1-20级强化配置
调整数值平衡,除AP/HP_MAX外所有属性强度减半
2025-12-25 20:55:49 +08:00

189 lines
14 KiB
TypeScript
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import { Attrs } from "./HeroAttrs";
export interface ITDLevelOption {
attr: Attrs;
value: number;
showValue: number;
weight: number;
desc: string;
isSpecial: boolean;
note?: string;
}
// 静态生成的 1-20 级强化池配置表
export const LEVEL_OPTIONS_TABLE: Record<number, ITDLevelOption[]> = {
1: [
{ attr: Attrs.AP, value: 15, showValue: 15, weight: 100, desc: "攻击力 +15", isSpecial: false, note: "常规强化" },
{ attr: Attrs.HP_MAX, value: 100, showValue: 100, weight: 100, desc: "生命上限 +100", isSpecial: false, note: "常规强化" },
{ attr: Attrs.DEF, value: 5, showValue: 5, weight: 100, desc: "防御力 +5", isSpecial: false, note: "常规强化" },
{ attr: Attrs.AS, value: 0.05, showValue: 5, weight: 100, desc: "攻击速度 +5%", isSpecial: false, note: "常规强化" },
],
2: [
{ attr: Attrs.AP, value: 16.5, showValue: 16.5, weight: 100, desc: "攻击力 +16.5", isSpecial: false, note: "常规强化" },
{ attr: Attrs.HP_MAX, value: 110, showValue: 110, weight: 100, desc: "生命上限 +110", isSpecial: false, note: "常规强化" },
{ attr: Attrs.DEF, value: 5.5, showValue: 5.5, weight: 100, desc: "防御力 +5.5", isSpecial: false, note: "常规强化" },
{ attr: Attrs.AS, value: 0.05, showValue: 5.25, weight: 100, desc: "攻击速度 +5.25%", isSpecial: false, note: "常规强化" },
],
3: [
{ attr: Attrs.PIERCE, value: 1, showValue: 1, weight: 50, desc: "穿透数量 +1", isSpecial: true, note: "上限5层" },
{ attr: Attrs.CRITICAL, value: 0.14, showValue: 14, weight: 50, desc: "暴击率 +14%", isSpecial: true, note: "上限70%" },
{ attr: Attrs.CRITICAL_DMG, value: 0.4, showValue: 40, weight: 50, desc: "暴击伤害 +40%", isSpecial: true, note: "上限200%" },
{ attr: Attrs.STUN_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "眩晕概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.FREEZE_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "冰冻概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.BURN_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "燃烧概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.BACK_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "击退概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.SLOW_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "减速概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.LIFESTEAL, value: 0.1, showValue: 10, weight: 30, desc: "吸血比例 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.MANASTEAL, value: 0.1, showValue: 10, weight: 30, desc: "吸蓝比例 +10%", isSpecial: true, note: "上限50%" },
],
4: [
{ attr: Attrs.AP, value: 19.5, showValue: 19.5, weight: 100, desc: "攻击力 +19.5", isSpecial: false, note: "常规强化" },
{ attr: Attrs.HP_MAX, value: 130, showValue: 130, weight: 100, desc: "生命上限 +130", isSpecial: false, note: "常规强化" },
{ attr: Attrs.DEF, value: 6.5, showValue: 6.5, weight: 100, desc: "防御力 +6.5", isSpecial: false, note: "常规强化" },
{ attr: Attrs.AS, value: 0.06, showValue: 5.75, weight: 100, desc: "攻击速度 +5.75%", isSpecial: false, note: "常规强化" },
],
5: [
// 无强化等级
],
6: [
{ attr: Attrs.PIERCE, value: 1, showValue: 1, weight: 50, desc: "穿透数量 +1", isSpecial: true, note: "上限5层" },
{ attr: Attrs.CRITICAL, value: 0.14, showValue: 14, weight: 50, desc: "暴击率 +14%", isSpecial: true, note: "上限70%" },
{ attr: Attrs.CRITICAL_DMG, value: 0.4, showValue: 40, weight: 50, desc: "暴击伤害 +40%", isSpecial: true, note: "上限200%" },
{ attr: Attrs.STUN_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "眩晕概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.FREEZE_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "冰冻概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.BURN_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "燃烧概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.BACK_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "击退概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.SLOW_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "减速概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.LIFESTEAL, value: 0.1, showValue: 10, weight: 30, desc: "吸血比例 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.MANASTEAL, value: 0.1, showValue: 10, weight: 30, desc: "吸蓝比例 +10%", isSpecial: true, note: "上限50%" },
],
7: [
{ attr: Attrs.AP, value: 24, showValue: 24, weight: 100, desc: "攻击力 +24", isSpecial: false, note: "常规强化" },
{ attr: Attrs.HP_MAX, value: 160, showValue: 160, weight: 100, desc: "生命上限 +160", isSpecial: false, note: "常规强化" },
{ attr: Attrs.DEF, value: 8, showValue: 8, weight: 100, desc: "防御力 +8", isSpecial: false, note: "常规强化" },
{ attr: Attrs.AS, value: 0.07, showValue: 6.5, weight: 100, desc: "攻击速度 +6.5%", isSpecial: false, note: "常规强化" },
],
8: [
{ attr: Attrs.AP, value: 25.5, showValue: 25.5, weight: 100, desc: "攻击力 +25.5", isSpecial: false, note: "常规强化" },
{ attr: Attrs.HP_MAX, value: 170, showValue: 170, weight: 100, desc: "生命上限 +170", isSpecial: false, note: "常规强化" },
{ attr: Attrs.DEF, value: 8.5, showValue: 8.5, weight: 100, desc: "防御力 +8.5", isSpecial: false, note: "常规强化" },
{ attr: Attrs.AS, value: 0.07, showValue: 6.75, weight: 100, desc: "攻击速度 +6.75%", isSpecial: false, note: "常规强化" },
],
9: [
{ attr: Attrs.PIERCE, value: 1, showValue: 1, weight: 50, desc: "穿透数量 +1", isSpecial: true, note: "上限5层" },
{ attr: Attrs.CRITICAL, value: 0.14, showValue: 14, weight: 50, desc: "暴击率 +14%", isSpecial: true, note: "上限70%" },
{ attr: Attrs.CRITICAL_DMG, value: 0.4, showValue: 40, weight: 50, desc: "暴击伤害 +40%", isSpecial: true, note: "上限200%" },
{ attr: Attrs.STUN_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "眩晕概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.FREEZE_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "冰冻概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.BURN_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "燃烧概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.BACK_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "击退概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.SLOW_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "减速概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.LIFESTEAL, value: 0.1, showValue: 10, weight: 30, desc: "吸血比例 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.MANASTEAL, value: 0.1, showValue: 10, weight: 30, desc: "吸蓝比例 +10%", isSpecial: true, note: "上限50%" },
],
10: [
// 无强化等级
],
11: [
{ attr: Attrs.AP, value: 30, showValue: 30, weight: 100, desc: "攻击力 +30", isSpecial: false, note: "常规强化" },
{ attr: Attrs.HP_MAX, value: 200, showValue: 200, weight: 100, desc: "生命上限 +200", isSpecial: false, note: "常规强化" },
{ attr: Attrs.DEF, value: 10, showValue: 10, weight: 100, desc: "防御力 +10", isSpecial: false, note: "常规强化" },
{ attr: Attrs.AS, value: 0.08, showValue: 7.5, weight: 100, desc: "攻击速度 +7.5%", isSpecial: false, note: "常规强化" },
],
12: [
{ attr: Attrs.PIERCE, value: 1, showValue: 1, weight: 50, desc: "穿透数量 +1", isSpecial: true, note: "上限5层" },
{ attr: Attrs.CRITICAL, value: 0.14, showValue: 14, weight: 50, desc: "暴击率 +14%", isSpecial: true, note: "上限70%" },
{ attr: Attrs.CRITICAL_DMG, value: 0.4, showValue: 40, weight: 50, desc: "暴击伤害 +40%", isSpecial: true, note: "上限200%" },
{ attr: Attrs.STUN_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "眩晕概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.FREEZE_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "冰冻概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.BURN_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "燃烧概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.BACK_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "击退概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.SLOW_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "减速概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.LIFESTEAL, value: 0.1, showValue: 10, weight: 30, desc: "吸血比例 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.MANASTEAL, value: 0.1, showValue: 10, weight: 30, desc: "吸蓝比例 +10%", isSpecial: true, note: "上限50%" },
],
13: [
{ attr: Attrs.AP, value: 33, showValue: 33, weight: 100, desc: "攻击力 +33", isSpecial: false, note: "常规强化" },
{ attr: Attrs.HP_MAX, value: 220, showValue: 220, weight: 100, desc: "生命上限 +220", isSpecial: false, note: "常规强化" },
{ attr: Attrs.DEF, value: 11, showValue: 11, weight: 100, desc: "防御力 +11", isSpecial: false, note: "常规强化" },
{ attr: Attrs.AS, value: 0.08, showValue: 8, weight: 100, desc: "攻击速度 +8%", isSpecial: false, note: "常规强化" },
],
14: [
{ attr: Attrs.AP, value: 34.5, showValue: 34.5, weight: 100, desc: "攻击力 +34.5", isSpecial: false, note: "常规强化" },
{ attr: Attrs.HP_MAX, value: 230, showValue: 230, weight: 100, desc: "生命上限 +230", isSpecial: false, note: "常规强化" },
{ attr: Attrs.DEF, value: 11.5, showValue: 11.5, weight: 100, desc: "防御力 +11.5", isSpecial: false, note: "常规强化" },
{ attr: Attrs.AS, value: 0.08, showValue: 8.25, weight: 100, desc: "攻击速度 +8.25%", isSpecial: false, note: "常规强化" },
],
15: [
// 无强化等级
],
16: [
{ attr: Attrs.AP, value: 37.5, showValue: 37.5, weight: 100, desc: "攻击力 +37.5", isSpecial: false, note: "常规强化" },
{ attr: Attrs.HP_MAX, value: 250, showValue: 250, weight: 100, desc: "生命上限 +250", isSpecial: false, note: "常规强化" },
{ attr: Attrs.DEF, value: 12.5, showValue: 12.5, weight: 100, desc: "防御力 +12.5", isSpecial: false, note: "常规强化" },
{ attr: Attrs.AS, value: 0.09, showValue: 8.75, weight: 100, desc: "攻击速度 +8.75%", isSpecial: false, note: "常规强化" },
],
17: [
{ attr: Attrs.AP, value: 39, showValue: 39, weight: 100, desc: "攻击力 +39", isSpecial: false, note: "常规强化" },
{ attr: Attrs.HP_MAX, value: 260, showValue: 260, weight: 100, desc: "生命上限 +260", isSpecial: false, note: "常规强化" },
{ attr: Attrs.DEF, value: 13, showValue: 13, weight: 100, desc: "防御力 +13", isSpecial: false, note: "常规强化" },
{ attr: Attrs.AS, value: 0.09, showValue: 9, weight: 100, desc: "攻击速度 +9%", isSpecial: false, note: "常规强化" },
],
18: [
{ attr: Attrs.PIERCE, value: 1, showValue: 1, weight: 50, desc: "穿透数量 +1", isSpecial: true, note: "上限5层" },
{ attr: Attrs.CRITICAL, value: 0.14, showValue: 14, weight: 50, desc: "暴击率 +14%", isSpecial: true, note: "上限70%" },
{ attr: Attrs.CRITICAL_DMG, value: 0.4, showValue: 40, weight: 50, desc: "暴击伤害 +40%", isSpecial: true, note: "上限200%" },
{ attr: Attrs.STUN_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "眩晕概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.FREEZE_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "冰冻概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.BURN_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "燃烧概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.BACK_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "击退概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.SLOW_CHANCE, value: 0.1, showValue: 10, weight: 30, desc: "减速概率 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.LIFESTEAL, value: 0.1, showValue: 10, weight: 30, desc: "吸血比例 +10%", isSpecial: true, note: "上限50%" },
{ attr: Attrs.MANASTEAL, value: 0.1, showValue: 10, weight: 30, desc: "吸蓝比例 +10%", isSpecial: true, note: "上限50%" },
],
19: [
{ attr: Attrs.AP, value: 42, showValue: 42, weight: 100, desc: "攻击力 +42", isSpecial: false, note: "常规强化" },
{ attr: Attrs.HP_MAX, value: 280, showValue: 280, weight: 100, desc: "生命上限 +280", isSpecial: false, note: "常规强化" },
{ attr: Attrs.DEF, value: 14, showValue: 14, weight: 100, desc: "防御力 +14", isSpecial: false, note: "常规强化" },
{ attr: Attrs.AS, value: 0.1, showValue: 9.5, weight: 100, desc: "攻击速度 +9.5%", isSpecial: false, note: "常规强化" },
],
20: [
// 无强化等级
],
};
/**
* 获取指定等级的随机选项
*/
export const getRandomOptions = (level: number, count: number = 4): ITDLevelOption[] => {
const pool = LEVEL_OPTIONS_TABLE[level];
if (!pool || pool.length === 0) return [];
const result: ITDLevelOption[] = [];
const tempPool = [...pool];
// 1. 根据权重进行随机抽样,直到选满 count 个或池子抽空
while (result.length < count && tempPool.length > 0) {
const totalWeight = tempPool.reduce((sum, item) => sum + item.weight, 0);
let randomVal = Math.random() * totalWeight;
for (let j = 0; j < tempPool.length; j++) {
randomVal -= tempPool[j].weight;
if (randomVal <= 0) {
result.push(tempPool[j]);
tempPool.splice(j, 1);
break;
}
}
}
// 2. 即使选出的数量正好是4个比如常规等级也必须进行最后的随机排序
// 使用 Fisher-Yates 洗牌算法
for (let i = result.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[result[i], result[j]] = [result[j], result[i]];
}
return result;
};