Files
heros/assets/script/game/common/config/LevelUp.ts
2025-07-16 20:58:34 +08:00

221 lines
10 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 { BuffAttr } from "./SkillSet"
import { Quality } from "./CardSet"
// 强化类型枚举
export const EnhancementType = {
ATTACK: 0, // 攻击力强化
HEALTH: 1, // 生命值强化
ATTACK_SPEED: 2, // 攻击速度强化
DEF: 3, // 特殊效果强化
}
// 玩家强化等级追踪
export interface PlayerEnhancementProgress {
[EnhancementType.ATTACK]: number;
[EnhancementType.HEALTH]: number;
[EnhancementType.ATTACK_SPEED]: number;
[EnhancementType.DEF]: number;
}
// 默认强化进度所有强化都从0级开始
export const defaultEnhancementProgress: PlayerEnhancementProgress = {
[EnhancementType.ATTACK]: 0,
[EnhancementType.HEALTH]: 0,
[EnhancementType.ATTACK_SPEED]: 0,
[EnhancementType.DEF]: 0,
};
export const defaultEnhancements=()=>{
return {
[EnhancementType.ATTACK]: 0,
[EnhancementType.HEALTH]: 0,
[EnhancementType.ATTACK_SPEED]: 0,
[EnhancementType.DEF]: 0,
}
}
// 强化选项配置表(一维数组格式)
export const EnhancementOptions: EnhancementOption[] = [
// 攻击力强化选项
{ uuid: 1001, type: EnhancementType.ATTACK, lv: 1, name: "力量训练 I", description: "攻击力 +5", buffType: BuffAttr.ATK, value: 5, icon: "3058", rarity: Quality.GREEN },
{ uuid: 1002, type: EnhancementType.ATTACK, lv: 2, name: "力量训练 II", description: "攻击力 +12", buffType: BuffAttr.ATK, value: 12, icon: "3058", rarity: Quality.GREEN },
{ uuid: 1003, type: EnhancementType.ATTACK, lv: 3, name: "力量训练 III", description: "攻击力 +20", buffType: BuffAttr.ATK, value: 20, icon: "3058", rarity: Quality.BLUE },
{ uuid: 1004, type: EnhancementType.ATTACK, lv: 4, name: "力量训练 IV", description: "攻击力 +35", buffType: BuffAttr.ATK, value: 35, icon: "3058", rarity: Quality.BLUE },
{ uuid: 1005, type: EnhancementType.ATTACK, lv: 5, name: "力量训练 V", description: "攻击力 +50", buffType: BuffAttr.ATK, value: 50, icon: "3058", rarity: Quality.PURPLE },
// 生命值强化选项
{ uuid: 2001, type: EnhancementType.HEALTH, lv: 1, name: "体质增强 I", description: "生命值 +10", buffType: BuffAttr.HP, value: 10, icon: "3058", rarity: Quality.GREEN },
{ uuid: 2002, type: EnhancementType.HEALTH, lv: 2, name: "体质增强 II", description: "生命值 +25", buffType: BuffAttr.HP, value: 25, icon: "3058", rarity: Quality.GREEN },
{ uuid: 2003, type: EnhancementType.HEALTH, lv: 3, name: "体质增强 III", description: "生命值 +40", buffType: BuffAttr.HP, value: 40, icon: "3058", rarity: Quality.BLUE },
{ uuid: 2004, type: EnhancementType.HEALTH, lv: 4, name: "体质增强 IV", description: "生命值 +65", buffType: BuffAttr.HP, value: 65, icon: "3058", rarity: Quality.BLUE },
{ uuid: 2005, type: EnhancementType.HEALTH, lv: 5, name: "体质增强 V", description: "生命值 +100", buffType: BuffAttr.HP, value: 100, icon: "3058", rarity: Quality.PURPLE },
// 攻击速度强化选项
{ uuid: 3001, type: EnhancementType.ATTACK_SPEED, lv: 1, name: "快速出手 I", description: "攻击速度 +1%", buffType: BuffAttr.ATK_CD, value: 1, icon: "3058", rarity: Quality.GREEN },
{ uuid: 3002, type: EnhancementType.ATTACK_SPEED, lv: 2, name: "快速出手 II", description: "攻击速度 +2%", buffType: BuffAttr.ATK_CD, value: 2, icon: "3058", rarity: Quality.GREEN },
{ uuid: 3003, type: EnhancementType.ATTACK_SPEED, lv: 3, name: "快速出手 III", description: "攻击速度 +3%", buffType: BuffAttr.ATK_CD, value: 3, icon: "3058", rarity: Quality.BLUE },
{ uuid: 3004, type: EnhancementType.ATTACK_SPEED, lv: 4, name: "快速出手 IV", description: "攻击速度 +4%", buffType: BuffAttr.ATK_CD, value: 4, icon: "3058", rarity: Quality.BLUE },
{ uuid: 3005, type: EnhancementType.ATTACK_SPEED, lv: 5, name: "快速出手 V", description: "攻击速度 +5%", buffType: BuffAttr.ATK_CD, value: 5, icon: "3058", rarity: Quality.PURPLE },
// 特殊效果强化选项
{ uuid: 4001, type: EnhancementType.DEF, lv: 1, name: "绝对防御 I", description: "免伤 +1%", buffType: BuffAttr.DEF, value: 1, icon: "3058", rarity: Quality.GREEN },
{ uuid: 4002, type: EnhancementType.DEF, lv: 2, name: "绝对防御 II", description: "免伤 +2%", buffType: BuffAttr.DEF, value: 2, icon: "3058", rarity: Quality.GREEN },
{ uuid: 4003, type: EnhancementType.DEF, lv: 3, name: "绝对防御 III", description: "免伤 +3%", buffType: BuffAttr.DEF, value: 3, icon: "3058", rarity: Quality.BLUE },
{ uuid: 4004, type: EnhancementType.DEF, lv: 4, name: "绝对防御 IV", description: "免伤 +4%", buffType: BuffAttr.DEF, value: 4, icon: "3058", rarity: Quality.BLUE },
{ uuid: 4005, type: EnhancementType.DEF, lv: 5, name: "绝对防御 V", description: "免伤 +5%", buffType: BuffAttr.DEF, value: 5, icon: "3058", rarity: Quality.PURPLE },
];
// 强化选项接口定义
export interface EnhancementOption {
uuid: number; // 强化选项唯一ID
type: number; // 强化类型 (EnhancementType)
lv: number; // 强化等级
name: string; // 强化名称
description: string; // 强化描述
buffType: number; // 属性类型 (BuffAttr)
value: number; // 属性值
icon: string; // 图标ID
rarity: number; // 稀有度 (Quality)
}
// 获取随机强化选项(基于玩家当前强化进度)
export function getEnhancement(playerProgress: PlayerEnhancementProgress, count: number = 3): EnhancementOption[] {
const options: EnhancementOption[] = [];
const enhancementTypes = Object.values(EnhancementType);
// 随机选择强化类型
const selectedTypes = [];
const shuffledTypes = [...enhancementTypes];
// 随机打乱数组
for (let i = shuffledTypes.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[shuffledTypes[i], shuffledTypes[j]] = [shuffledTypes[j], shuffledTypes[i]];
}
// 选择指定数量的强化类型
for (let i = 0; i < count && i < shuffledTypes.length; i++) {
selectedTypes.push(shuffledTypes[i]);
}
// 为每个类型生成对应等级的选项
selectedTypes.forEach(type => {
const currentLevel = playerProgress[type] || 0;
const nextLevel = Math.min(currentLevel + 1, 5); // 最大等级为5
const option = getEnhancementOptionByTypeAndLevel(type, nextLevel);
if (option) {
options.push(option);
}
});
return options;
}
// 获取指定类型和等级的强化选项
export function getEnhancementOptionByTypeAndLevel(type: number, level: number): EnhancementOption | null {
return EnhancementOptions.find(opt => opt.type === type && opt.lv === level) || null;
}
// 获取所有可用的强化类型
export function getAllEnhancementTypes(): number[] {
return Object.values(EnhancementType);
}
// 获取指定等级的所有强化选项
export function getEnhancementOptionsByLevel(level: number): EnhancementOption[] {
return EnhancementOptions.filter(opt => opt.lv === level);
}
// 更新玩家强化进度
export function updatePlayerEnhancementProgress(
progress: PlayerEnhancementProgress,
type: number,
levelIncrease: number = 1
): PlayerEnhancementProgress {
const newProgress = { ...progress };
const currentLevel = newProgress[type] || 0;
newProgress[type] = Math.min(currentLevel + levelIncrease, 5); // 最大等级为5
return newProgress;
}
// 检查某个强化类型是否还能继续升级
export function canEnhancementUpgrade(progress: PlayerEnhancementProgress, type: number): boolean {
const currentLevel = progress[type] || 0;
return currentLevel < 5; // 最大等级为5
}
// 获取某个强化类型的下一级选项
export function getNextLevelOption(progress: PlayerEnhancementProgress, type: number): EnhancementOption | null {
if (!canEnhancementUpgrade(progress, type)) {
return null;
}
const currentLevel = progress[type] || 0;
const nextLevel = currentLevel + 1;
return getEnhancementOptionByTypeAndLevel(type, nextLevel);
}
// 获取可升级的强化选项(排除已满级的)
export function getUpgradeableEnhancementOptions(progress: PlayerEnhancementProgress, count: number = 3): EnhancementOption[] {
const options: EnhancementOption[] = [];
const enhancementTypes = Object.values(EnhancementType);
// 筛选出可以升级的强化类型
const upgradeableTypes = enhancementTypes.filter(type => canEnhancementUpgrade(progress, type));
if (upgradeableTypes.length === 0) {
return options; // 没有可升级的选项
}
// 随机打乱可升级的类型
const shuffledTypes = [...upgradeableTypes];
for (let i = shuffledTypes.length - 1; i > 0; i--) {
const j = Math.floor(Math.random() * (i + 1));
[shuffledTypes[i], shuffledTypes[j]] = [shuffledTypes[j], shuffledTypes[i]];
}
// 选择指定数量的强化类型
const selectedTypes = shuffledTypes.slice(0, Math.min(count, shuffledTypes.length));
// 为每个类型生成下一级选项
selectedTypes.forEach(type => {
const option = getNextLevelOption(progress, type);
if (option) {
options.push(option);
}
});
return options;
}
// 获取玩家某个强化类型的当前等级
export function getEnhancementLevel(progress: PlayerEnhancementProgress, type: number): number {
return progress[type] || 0;
}
// 获取玩家所有强化的总等级
export function getTotalEnhancementLevel(progress: PlayerEnhancementProgress): number {
return Object.values(progress).reduce((total, level) => total + level, 0);
}
// 通过UUID获取强化选项
export function getEnhancementOptionByUuid(uuid: number): EnhancementOption | null {
return EnhancementOptions.find(opt => opt.uuid === uuid) || null;
}
// 获取指定类型的所有强化选项
export function getEnhancementOptionsByType(type: number): EnhancementOption[] {
return EnhancementOptions.filter(opt => opt.type === type);
}
// 获取指定UUID范围的强化选项
export function getEnhancementOptionsByUuidRange(startUuid: number, endUuid: number): EnhancementOption[] {
const options: EnhancementOption[] = [];
EnhancementOptions.forEach(option => {
if (option.uuid >= startUuid && option.uuid <= endUuid) {
options.push(option);
}
});
return options;
}