604 lines
18 KiB
TypeScript
604 lines
18 KiB
TypeScript
/*
|
||
* 肉鸽游戏玩家升级强化选项配置表
|
||
* 提供玩家升级后的属性强化选择
|
||
*/
|
||
|
||
import { BuffAttr } from "./SkillSet"
|
||
import { Quality } from "./CardSet"
|
||
|
||
// 强化类型枚举
|
||
export const EnhancementType = {
|
||
ATTACK: 1, // 攻击力强化
|
||
HEALTH: 2, // 生命值强化
|
||
ATTACK_SPEED: 3, // 攻击速度强化
|
||
CRITICAL: 4, // 暴击率强化
|
||
CRITICAL_DMG: 5, // 暴击伤害强化
|
||
DODGE: 6, // 闪避率强化
|
||
DEFENSE: 7, // 防御力强化
|
||
SKILL_CD: 8, // 技能冷却强化
|
||
SKILL_DMG: 9, // 技能伤害强化
|
||
SPECIAL: 10, // 特殊效果强化
|
||
}
|
||
|
||
// 强化品质权重配置
|
||
export const EnhancementQualityWeight = {
|
||
[Quality.WHITE]: 0.4, // 白色品质 40%概率
|
||
[Quality.GREEN]: 0.3, // 绿色品质 30%概率
|
||
[Quality.BLUE]: 0.2, // 蓝色品质 20%概率
|
||
[Quality.PURPLE]: 0.08, // 紫色品质 8%概率
|
||
[Quality.ORANGE]: 0.02, // 橙色品质 2%概率
|
||
}
|
||
|
||
// 强化选项配置表
|
||
export const EnhancementOptions = {
|
||
// 攻击力强化选项
|
||
[EnhancementType.ATTACK]: {
|
||
[Quality.WHITE]: {
|
||
name: "力量训练",
|
||
description: "攻击力 +5",
|
||
buffType: BuffAttr.ATK,
|
||
value: 5,
|
||
icon: "attack_white",
|
||
rarity: "common"
|
||
},
|
||
[Quality.GREEN]: {
|
||
name: "武器精通",
|
||
description: "攻击力 +12",
|
||
buffType: BuffAttr.ATK,
|
||
value: 12,
|
||
icon: "attack_green",
|
||
rarity: "uncommon"
|
||
},
|
||
[Quality.BLUE]: {
|
||
name: "战斗大师",
|
||
description: "攻击力 +20",
|
||
buffType: BuffAttr.ATK,
|
||
value: 20,
|
||
icon: "attack_blue",
|
||
rarity: "rare"
|
||
},
|
||
[Quality.PURPLE]: {
|
||
name: "战神附体",
|
||
description: "攻击力 +35",
|
||
buffType: BuffAttr.ATK,
|
||
value: 35,
|
||
icon: "attack_purple",
|
||
rarity: "epic"
|
||
},
|
||
[Quality.ORANGE]: {
|
||
name: "毁灭之力",
|
||
description: "攻击力 +50",
|
||
buffType: BuffAttr.ATK,
|
||
value: 50,
|
||
icon: "attack_orange",
|
||
rarity: "legendary"
|
||
}
|
||
},
|
||
|
||
// 生命值强化选项
|
||
[EnhancementType.HEALTH]: {
|
||
[Quality.WHITE]: {
|
||
name: "体质增强",
|
||
description: "生命值 +10",
|
||
buffType: BuffAttr.HP,
|
||
value: 10,
|
||
icon: "health_white",
|
||
rarity: "common"
|
||
},
|
||
[Quality.GREEN]: {
|
||
name: "生命源泉",
|
||
description: "生命值 +25",
|
||
buffType: BuffAttr.HP,
|
||
value: 25,
|
||
icon: "health_green",
|
||
rarity: "uncommon"
|
||
},
|
||
[Quality.BLUE]: {
|
||
name: "不朽之躯",
|
||
description: "生命值 +40",
|
||
buffType: BuffAttr.HP,
|
||
value: 40,
|
||
icon: "health_blue",
|
||
rarity: "rare"
|
||
},
|
||
[Quality.PURPLE]: {
|
||
name: "永恒生命",
|
||
description: "生命值 +65",
|
||
buffType: BuffAttr.HP,
|
||
value: 65,
|
||
icon: "health_purple",
|
||
rarity: "epic"
|
||
},
|
||
[Quality.ORANGE]: {
|
||
name: "不死之身",
|
||
description: "生命值 +100",
|
||
buffType: BuffAttr.HP,
|
||
value: 100,
|
||
icon: "health_orange",
|
||
rarity: "legendary"
|
||
}
|
||
},
|
||
|
||
// 攻击速度强化选项
|
||
[EnhancementType.ATTACK_SPEED]: {
|
||
[Quality.WHITE]: {
|
||
name: "快速出手",
|
||
description: "攻击速度 +8%",
|
||
buffType: BuffAttr.ATK_CD,
|
||
value: -8, // 负值表示减少CD,即提升攻击速度
|
||
icon: "speed_white",
|
||
rarity: "common"
|
||
},
|
||
[Quality.GREEN]: {
|
||
name: "疾风连击",
|
||
description: "攻击速度 +15%",
|
||
buffType: BuffAttr.ATK_CD,
|
||
value: -15,
|
||
icon: "speed_green",
|
||
rarity: "uncommon"
|
||
},
|
||
[Quality.BLUE]: {
|
||
name: "闪电打击",
|
||
description: "攻击速度 +25%",
|
||
buffType: BuffAttr.ATK_CD,
|
||
value: -25,
|
||
icon: "speed_blue",
|
||
rarity: "rare"
|
||
},
|
||
[Quality.PURPLE]: {
|
||
name: "时间加速",
|
||
description: "攻击速度 +40%",
|
||
buffType: BuffAttr.ATK_CD,
|
||
value: -40,
|
||
icon: "speed_purple",
|
||
rarity: "epic"
|
||
},
|
||
[Quality.ORANGE]: {
|
||
name: "无限连击",
|
||
description: "攻击速度 +60%",
|
||
buffType: BuffAttr.ATK_CD,
|
||
value: -60,
|
||
icon: "speed_orange",
|
||
rarity: "legendary"
|
||
}
|
||
},
|
||
|
||
// 暴击率强化选项
|
||
[EnhancementType.CRITICAL]: {
|
||
[Quality.WHITE]: {
|
||
name: "精准打击",
|
||
description: "暴击率 +5%",
|
||
buffType: BuffAttr.CRITICAL,
|
||
value: 5,
|
||
icon: "crit_white",
|
||
rarity: "common"
|
||
},
|
||
[Quality.GREEN]: {
|
||
name: "致命瞄准",
|
||
description: "暴击率 +12%",
|
||
buffType: BuffAttr.CRITICAL,
|
||
value: 12,
|
||
icon: "crit_green",
|
||
rarity: "uncommon"
|
||
},
|
||
[Quality.BLUE]: {
|
||
name: "弱点洞察",
|
||
description: "暴击率 +20%",
|
||
buffType: BuffAttr.CRITICAL,
|
||
value: 20,
|
||
icon: "crit_blue",
|
||
rarity: "rare"
|
||
},
|
||
[Quality.PURPLE]: {
|
||
name: "必杀一击",
|
||
description: "暴击率 +30%",
|
||
buffType: BuffAttr.CRITICAL,
|
||
value: 30,
|
||
icon: "crit_purple",
|
||
rarity: "epic"
|
||
},
|
||
[Quality.ORANGE]: {
|
||
name: "绝对暴击",
|
||
description: "暴击率 +45%",
|
||
buffType: BuffAttr.CRITICAL,
|
||
value: 45,
|
||
icon: "crit_orange",
|
||
rarity: "legendary"
|
||
}
|
||
},
|
||
|
||
// 暴击伤害强化选项
|
||
[EnhancementType.CRITICAL_DMG]: {
|
||
[Quality.WHITE]: {
|
||
name: "重击训练",
|
||
description: "暴击伤害 +15%",
|
||
buffType: BuffAttr.CRITICAL_DMG,
|
||
value: 15,
|
||
icon: "critdmg_white",
|
||
rarity: "common"
|
||
},
|
||
[Quality.GREEN]: {
|
||
name: "致命一击",
|
||
description: "暴击伤害 +25%",
|
||
buffType: BuffAttr.CRITICAL_DMG,
|
||
value: 25,
|
||
icon: "critdmg_green",
|
||
rarity: "uncommon"
|
||
},
|
||
[Quality.BLUE]: {
|
||
name: "毁灭打击",
|
||
description: "暴击伤害 +40%",
|
||
buffType: BuffAttr.CRITICAL_DMG,
|
||
value: 40,
|
||
icon: "critdmg_blue",
|
||
rarity: "rare"
|
||
},
|
||
[Quality.PURPLE]: {
|
||
name: "死亡之舞",
|
||
description: "暴击伤害 +60%",
|
||
buffType: BuffAttr.CRITICAL_DMG,
|
||
value: 60,
|
||
icon: "critdmg_purple",
|
||
rarity: "epic"
|
||
},
|
||
[Quality.ORANGE]: {
|
||
name: "终结一击",
|
||
description: "暴击伤害 +100%",
|
||
buffType: BuffAttr.CRITICAL_DMG,
|
||
value: 100,
|
||
icon: "critdmg_orange",
|
||
rarity: "legendary"
|
||
}
|
||
},
|
||
|
||
// 闪避率强化选项
|
||
[EnhancementType.DODGE]: {
|
||
[Quality.WHITE]: {
|
||
name: "灵活身法",
|
||
description: "闪避率 +5%",
|
||
buffType: BuffAttr.DODGE,
|
||
value: 5,
|
||
icon: "dodge_white",
|
||
rarity: "common"
|
||
},
|
||
[Quality.GREEN]: {
|
||
name: "鬼魅步法",
|
||
description: "闪避率 +12%",
|
||
buffType: BuffAttr.DODGE,
|
||
value: 12,
|
||
icon: "dodge_green",
|
||
rarity: "uncommon"
|
||
},
|
||
[Quality.BLUE]: {
|
||
name: "幻影迷踪",
|
||
description: "闪避率 +20%",
|
||
buffType: BuffAttr.DODGE,
|
||
value: 20,
|
||
icon: "dodge_blue",
|
||
rarity: "rare"
|
||
},
|
||
[Quality.PURPLE]: {
|
||
name: "时空闪避",
|
||
description: "闪避率 +30%",
|
||
buffType: BuffAttr.DODGE,
|
||
value: 30,
|
||
icon: "dodge_purple",
|
||
rarity: "epic"
|
||
},
|
||
[Quality.ORANGE]: {
|
||
name: "绝对闪避",
|
||
description: "闪避率 +45%",
|
||
buffType: BuffAttr.DODGE,
|
||
value: 45,
|
||
icon: "dodge_orange",
|
||
rarity: "legendary"
|
||
}
|
||
},
|
||
|
||
// 防御力强化选项
|
||
[EnhancementType.DEFENSE]: {
|
||
[Quality.WHITE]: {
|
||
name: "铁布衫",
|
||
description: "防御力 +8%",
|
||
buffType: BuffAttr.DEF,
|
||
value: 8,
|
||
icon: "def_white",
|
||
rarity: "common"
|
||
},
|
||
[Quality.GREEN]: {
|
||
name: "金刚不坏",
|
||
description: "防御力 +15%",
|
||
buffType: BuffAttr.DEF,
|
||
value: 15,
|
||
icon: "def_green",
|
||
rarity: "uncommon"
|
||
},
|
||
[Quality.BLUE]: {
|
||
name: "护体神功",
|
||
description: "防御力 +25%",
|
||
buffType: BuffAttr.DEF,
|
||
value: 25,
|
||
icon: "def_blue",
|
||
rarity: "rare"
|
||
},
|
||
[Quality.PURPLE]: {
|
||
name: "无敌金身",
|
||
description: "防御力 +40%",
|
||
buffType: BuffAttr.DEF,
|
||
value: 40,
|
||
icon: "def_purple",
|
||
rarity: "epic"
|
||
},
|
||
[Quality.ORANGE]: {
|
||
name: "绝对防御",
|
||
description: "防御力 +60%",
|
||
buffType: BuffAttr.DEF,
|
||
value: 60,
|
||
icon: "def_orange",
|
||
rarity: "legendary"
|
||
}
|
||
},
|
||
|
||
// 技能冷却强化选项
|
||
[EnhancementType.SKILL_CD]: {
|
||
[Quality.WHITE]: {
|
||
name: "快速施法",
|
||
description: "技能冷却 -8%",
|
||
buffType: BuffAttr.SKILL_CD,
|
||
value: -8,
|
||
icon: "skillcd_white",
|
||
rarity: "common"
|
||
},
|
||
[Quality.GREEN]: {
|
||
name: "法术精通",
|
||
description: "技能冷却 -15%",
|
||
buffType: BuffAttr.SKILL_CD,
|
||
value: -15,
|
||
icon: "skillcd_green",
|
||
rarity: "uncommon"
|
||
},
|
||
[Quality.BLUE]: {
|
||
name: "瞬发法术",
|
||
description: "技能冷却 -25%",
|
||
buffType: BuffAttr.SKILL_CD,
|
||
value: -25,
|
||
icon: "skillcd_blue",
|
||
rarity: "rare"
|
||
},
|
||
[Quality.PURPLE]: {
|
||
name: "无限法术",
|
||
description: "技能冷却 -40%",
|
||
buffType: BuffAttr.SKILL_CD,
|
||
value: -40,
|
||
icon: "skillcd_purple",
|
||
rarity: "epic"
|
||
},
|
||
[Quality.ORANGE]: {
|
||
name: "法术永动",
|
||
description: "技能冷却 -60%",
|
||
buffType: BuffAttr.SKILL_CD,
|
||
value: -60,
|
||
icon: "skillcd_orange",
|
||
rarity: "legendary"
|
||
}
|
||
},
|
||
|
||
// 技能伤害强化选项
|
||
[EnhancementType.SKILL_DMG]: {
|
||
[Quality.WHITE]: {
|
||
name: "法术强化",
|
||
description: "技能伤害 +10%",
|
||
buffType: BuffAttr.SKILL_DMG,
|
||
value: 10,
|
||
icon: "skilldmg_white",
|
||
rarity: "common"
|
||
},
|
||
[Quality.GREEN]: {
|
||
name: "法术增幅",
|
||
description: "技能伤害 +20%",
|
||
buffType: BuffAttr.SKILL_DMG,
|
||
value: 20,
|
||
icon: "skilldmg_green",
|
||
rarity: "uncommon"
|
||
},
|
||
[Quality.BLUE]: {
|
||
name: "法术爆发",
|
||
description: "技能伤害 +35%",
|
||
buffType: BuffAttr.SKILL_DMG,
|
||
value: 35,
|
||
icon: "skilldmg_blue",
|
||
rarity: "rare"
|
||
},
|
||
[Quality.PURPLE]: {
|
||
name: "法术毁灭",
|
||
description: "技能伤害 +55%",
|
||
buffType: BuffAttr.SKILL_DMG,
|
||
value: 55,
|
||
icon: "skilldmg_purple",
|
||
rarity: "epic"
|
||
},
|
||
[Quality.ORANGE]: {
|
||
name: "法术终结",
|
||
description: "技能伤害 +80%",
|
||
buffType: BuffAttr.SKILL_DMG,
|
||
value: 80,
|
||
icon: "skilldmg_orange",
|
||
rarity: "legendary"
|
||
}
|
||
},
|
||
|
||
// 特殊效果强化选项
|
||
[EnhancementType.SPECIAL]: {
|
||
[Quality.WHITE]: {
|
||
name: "风怒之力",
|
||
description: "攻击时有10%概率触发风怒",
|
||
buffType: BuffAttr.WFUNY,
|
||
value: 10,
|
||
icon: "special_white",
|
||
rarity: "common"
|
||
},
|
||
[Quality.GREEN]: {
|
||
name: "穿刺箭矢",
|
||
description: "攻击穿透1个额外目标",
|
||
buffType: BuffAttr.PUNCTURE,
|
||
value: 1,
|
||
icon: "special_green",
|
||
rarity: "uncommon"
|
||
},
|
||
[Quality.BLUE]: {
|
||
name: "冰冻打击",
|
||
description: "攻击有15%概率冰冻敌人",
|
||
buffType: BuffAttr.FROST_RATIO,
|
||
value: 15,
|
||
icon: "special_blue",
|
||
rarity: "rare"
|
||
},
|
||
[Quality.PURPLE]: {
|
||
name: "眩晕重击",
|
||
description: "攻击有20%概率眩晕敌人",
|
||
buffType: BuffAttr.STUN_RATTO,
|
||
value: 20,
|
||
icon: "special_purple",
|
||
rarity: "epic"
|
||
},
|
||
[Quality.ORANGE]: {
|
||
name: "多重打击",
|
||
description: "攻击穿透2个额外目标,伤害提升30%",
|
||
buffType: BuffAttr.PUNCTURE,
|
||
value: 2,
|
||
icon: "special_orange",
|
||
rarity: "legendary"
|
||
}
|
||
}
|
||
}
|
||
|
||
// 强化选项接口定义
|
||
export interface EnhancementOption {
|
||
name: string;
|
||
description: string;
|
||
buffType: number;
|
||
value: number;
|
||
icon: string;
|
||
rarity: string;
|
||
}
|
||
|
||
// 获取随机强化选项
|
||
export function getRandomEnhancementOptions(count: number = 3): EnhancementOption[] {
|
||
const options: EnhancementOption[] = [];
|
||
const enhancementTypes = Object.values(EnhancementType);
|
||
|
||
// 随机选择强化类型
|
||
const selectedTypes = [];
|
||
while (selectedTypes.length < count && enhancementTypes.length > 0) {
|
||
const randomIndex = Math.floor(Math.random() * enhancementTypes.length);
|
||
const type = enhancementTypes.splice(randomIndex, 1)[0];
|
||
selectedTypes.push(type);
|
||
}
|
||
|
||
// 为每个类型生成随机品质的选项
|
||
selectedTypes.forEach(type => {
|
||
const quality = getRandomQuality();
|
||
const option = EnhancementOptions[type]?.[quality];
|
||
if (option) {
|
||
options.push(option);
|
||
}
|
||
});
|
||
|
||
return options;
|
||
}
|
||
|
||
// 根据权重获取随机品质
|
||
export function getRandomQuality(): number {
|
||
const random = Math.random();
|
||
let cumulativeWeight = 0;
|
||
|
||
for (const [quality, weight] of Object.entries(EnhancementQualityWeight)) {
|
||
cumulativeWeight += weight;
|
||
if (random <= cumulativeWeight) {
|
||
return parseInt(quality);
|
||
}
|
||
}
|
||
|
||
return Quality.WHITE; // 默认返回白色品质
|
||
}
|
||
|
||
// 获取指定类型的强化选项(用于测试或特定需求)
|
||
export function getEnhancementOptionByType(type: number, quality: number): EnhancementOption | null {
|
||
return EnhancementOptions[type]?.[quality] || null;
|
||
}
|
||
|
||
// 获取所有可用的强化类型
|
||
export function getAllEnhancementTypes(): number[] {
|
||
return Object.values(EnhancementType);
|
||
}
|
||
|
||
// 获取指定品质的所有强化选项
|
||
export function getEnhancementOptionsByQuality(quality: number): EnhancementOption[] {
|
||
const options: EnhancementOption[] = [];
|
||
|
||
for (const type of Object.values(EnhancementType)) {
|
||
const option = EnhancementOptions[type]?.[quality];
|
||
if (option) {
|
||
options.push(option);
|
||
}
|
||
}
|
||
|
||
return options;
|
||
}
|
||
|
||
// 根据玩家等级调整强化选项(可选功能)
|
||
export function getLevelAdjustedEnhancementOptions(playerLevel: number, count: number = 3): EnhancementOption[] {
|
||
// 根据等级调整品质权重
|
||
const levelAdjustedWeights = { ...EnhancementQualityWeight };
|
||
|
||
if (playerLevel >= 20) {
|
||
// 高等级玩家有更高概率获得稀有品质
|
||
levelAdjustedWeights[Quality.WHITE] *= 0.8;
|
||
levelAdjustedWeights[Quality.GREEN] *= 1.1;
|
||
levelAdjustedWeights[Quality.BLUE] *= 1.2;
|
||
levelAdjustedWeights[Quality.PURPLE] *= 1.3;
|
||
levelAdjustedWeights[Quality.ORANGE] *= 1.5;
|
||
}
|
||
|
||
// 重新归一化权重
|
||
const totalWeight = Object.values(levelAdjustedWeights).reduce((sum, weight) => sum + weight, 0);
|
||
for (const quality in levelAdjustedWeights) {
|
||
levelAdjustedWeights[quality] /= totalWeight;
|
||
}
|
||
|
||
// 使用调整后的权重生成选项
|
||
const options: EnhancementOption[] = [];
|
||
const enhancementTypes = Object.values(EnhancementType);
|
||
|
||
const selectedTypes = [];
|
||
while (selectedTypes.length < count && enhancementTypes.length > 0) {
|
||
const randomIndex = Math.floor(Math.random() * enhancementTypes.length);
|
||
const type = enhancementTypes.splice(randomIndex, 1)[0];
|
||
selectedTypes.push(type);
|
||
}
|
||
|
||
selectedTypes.forEach(type => {
|
||
const quality = getRandomQualityWithWeights(levelAdjustedWeights);
|
||
const option = EnhancementOptions[type]?.[quality];
|
||
if (option) {
|
||
options.push(option);
|
||
}
|
||
});
|
||
|
||
return options;
|
||
}
|
||
|
||
// 使用自定义权重获取随机品质
|
||
function getRandomQualityWithWeights(weights: { [key: number]: number }): number {
|
||
const random = Math.random();
|
||
let cumulativeWeight = 0;
|
||
|
||
for (const [quality, weight] of Object.entries(weights)) {
|
||
cumulativeWeight += weight;
|
||
if (random <= cumulativeWeight) {
|
||
return parseInt(quality);
|
||
}
|
||
}
|
||
|
||
return Quality.WHITE;
|
||
}
|