/* * 肉鸽游戏玩家升级强化选项配置表 * 提供玩家升级后的属性强化选择 */ import { BuffAttr } from "./SkillSet" import { Quality } from "./CardSet" // 强化类型枚举 export const EnhancementType = { ATTACK: 1, // 攻击力强化 HEALTH: 2, // 生命值强化 ATTACK_SPEED: 3, // 攻击速度强化 DEF: 4, // 特殊效果强化 } // 玩家强化等级追踪 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 defaultEnhancementProgress } // 强化选项配置表(二维数组格式) export const EnhancementOptions: EnhancementOption[][] = [ // 攻击力强化选项 (EnhancementType.ATTACK = 1) [ { 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 } ], // 生命值强化选项 (EnhancementType.HEALTH = 2) [ { 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 } ], // 攻击速度强化选项 (EnhancementType.ATTACK_SPEED = 3) [ { 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 } ], // 特殊效果强化选项 (EnhancementType.SPECIAL = 4) [ { 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 = EnhancementOptions[type - 1]?.[nextLevel - 1]; // 数组索引从0开始 if (option) { options.push(option); } }); return options; } // 获取指定类型和等级的强化选项 export function getEnhancementOptionByTypeAndLevel(type: number, level: number): EnhancementOption | null { return EnhancementOptions[type - 1]?.[level - 1] || null; // 数组索引从0开始 } // 获取所有可用的强化类型 export function getAllEnhancementTypes(): number[] { return Object.values(EnhancementType); } // 获取指定等级的所有强化选项 export function getEnhancementOptionsByLevel(level: number): EnhancementOption[] { const options: EnhancementOption[] = []; for (const type of Object.values(EnhancementType)) { const option = EnhancementOptions[type - 1]?.[level - 1]; // 数组索引从0开始 if (option) { options.push(option); } } return options; } // 更新玩家强化进度 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 { for (const typeArray of EnhancementOptions) { for (const option of typeArray) { if (option.uuid === uuid) { return option; } } } return null; } // 获取指定类型的所有强化选项 export function getEnhancementOptionsByType(type: number): EnhancementOption[] { const typeIndex = type - 1; // 转换为数组索引 return EnhancementOptions[typeIndex] || []; } // 获取指定UUID范围的强化选项 export function getEnhancementOptionsByUuidRange(startUuid: number, endUuid: number): EnhancementOption[] { const options: EnhancementOption[] = []; for (const typeArray of EnhancementOptions) { for (const option of typeArray) { if (option.uuid >= startUuid && option.uuid <= endUuid) { options.push(option); } } } return options; }