/* * 肉鸽游戏玩家升级强化选项配置表 * 提供玩家升级后的属性强化选择 */ import { BuffAttr } from "./SkillSet" import { Quality } from "./CardSet" // 强化类型枚举 export const EnhancementType = { ATTACK: 1, // 攻击力强化 HEALTH: 2, // 生命值强化 ATTACK_SPEED: 3, // 攻击速度强化 SPECIAL: 4, // 特殊效果强化 } // 玩家强化等级追踪 export interface PlayerEnhancementProgress { [EnhancementType.ATTACK]: number; [EnhancementType.HEALTH]: number; [EnhancementType.ATTACK_SPEED]: number; [EnhancementType.SPECIAL]: number; } // 默认强化进度(所有强化都从0级开始) export const defaultEnhancementProgress: PlayerEnhancementProgress = { [EnhancementType.ATTACK]: 0, [EnhancementType.HEALTH]: 0, [EnhancementType.ATTACK_SPEED]: 0, [EnhancementType.SPECIAL]: 0, }; // 强化选项配置表(按等级分类) export const EnhancementOptions = { // 攻击力强化选项 [EnhancementType.ATTACK]: { 1: { name: "力量训练 I", description: "攻击力 +5", buffType: BuffAttr.ATK, value: 5, icon: "attack_1", rarity: "common" }, 2: { name: "力量训练 II", description: "攻击力 +12", buffType: BuffAttr.ATK, value: 12, icon: "attack_2", rarity: "uncommon" }, 3: { name: "力量训练 III", description: "攻击力 +20", buffType: BuffAttr.ATK, value: 20, icon: "attack_3", rarity: "rare" }, 4: { name: "力量训练 IV", description: "攻击力 +35", buffType: BuffAttr.ATK, value: 35, icon: "attack_4", rarity: "epic" }, 5: { name: "力量训练 V", description: "攻击力 +50", buffType: BuffAttr.ATK, value: 50, icon: "attack_5", rarity: "legendary" } }, // 生命值强化选项 [EnhancementType.HEALTH]: { 1: { name: "体质增强 I", description: "生命值 +10", buffType: BuffAttr.HP, value: 10, icon: "health_1", rarity: "common" }, 2: { name: "体质增强 II", description: "生命值 +25", buffType: BuffAttr.HP, value: 25, icon: "health_2", rarity: "uncommon" }, 3: { name: "体质增强 III", description: "生命值 +40", buffType: BuffAttr.HP, value: 40, icon: "health_3", rarity: "rare" }, 4: { name: "体质增强 IV", description: "生命值 +65", buffType: BuffAttr.HP, value: 65, icon: "health_4", rarity: "epic" }, 5: { name: "体质增强 V", description: "生命值 +100", buffType: BuffAttr.HP, value: 100, icon: "health_5", rarity: "legendary" } }, // 攻击速度强化选项 [EnhancementType.ATTACK_SPEED]: { 1: { name: "快速出手 I", description: "攻击速度 +8%", buffType: BuffAttr.ATK_CD, value: -8, // 负值表示减少CD,即提升攻击速度 icon: "speed_1", rarity: "common" }, 2: { name: "快速出手 II", description: "攻击速度 +15%", buffType: BuffAttr.ATK_CD, value: -15, icon: "speed_2", rarity: "uncommon" }, 3: { name: "快速出手 III", description: "攻击速度 +25%", buffType: BuffAttr.ATK_CD, value: -25, icon: "speed_3", rarity: "rare" }, 4: { name: "快速出手 IV", description: "攻击速度 +40%", buffType: BuffAttr.ATK_CD, value: -40, icon: "speed_4", rarity: "epic" }, 5: { name: "快速出手 V", description: "攻击速度 +60%", buffType: BuffAttr.ATK_CD, value: -60, icon: "speed_5", rarity: "legendary" } }, } // 强化选项接口定义 export interface EnhancementOption { name: string; description: string; buffType: number; value: number; icon: string; rarity: string; } // 获取随机强化选项(基于玩家当前强化进度) 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]?.[nextLevel]; if (option) { options.push(option); } }); return options; } // 获取指定类型和等级的强化选项 export function getEnhancementOptionByTypeAndLevel(type: number, level: number): EnhancementOption | null { return EnhancementOptions[type]?.[level] || null; } // 获取所有可用的强化类型 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]?.[level]; 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); }