489 lines
17 KiB
TypeScript
489 lines
17 KiB
TypeScript
import { v3 } from "cc"
|
||
|
||
/**
|
||
* kind :1:烈焰 2:寒冰 3:自然 4:暗影 5:神圣
|
||
**/
|
||
// export enum HeroKind {
|
||
// /**
|
||
// * 词条解释:
|
||
// * 烈焰:攻击带击退效果
|
||
// * 寒冰:攻击带速度效果
|
||
// * 自然:攻击偷取生命
|
||
// * 暗影:攻击偷取攻击
|
||
// * 神圣:攻击带2倍伤害
|
||
// * */
|
||
// fire = 1,
|
||
// water = 2,
|
||
// nature = 3,
|
||
// shadow = 4,
|
||
// holy = 5,
|
||
// }
|
||
/**
|
||
* 词条解释:
|
||
* 0:战士 1:远程 2:法师
|
||
* * */
|
||
export enum HType {
|
||
warrior = 0,
|
||
remote = 1,
|
||
mage = 2,
|
||
}
|
||
|
||
export const getHeroList = ()=>{
|
||
return Masters
|
||
|
||
}
|
||
|
||
export const getHeroListByCalled = (count:number,called:any[])=>{
|
||
let list=Masters
|
||
if(called.length==3){
|
||
list=called.map((item:any)=>item.uuid)
|
||
}
|
||
// 确保请求数量不超过可用卡牌数量
|
||
count = Math.min(count, list.length);
|
||
|
||
// 打乱数组顺序
|
||
const shuffled = [...list].sort(() => Math.random() - 0.5);
|
||
|
||
// 返回指定数量的卡牌
|
||
return shuffled.slice(0, count).map(uuid => ({
|
||
uuid
|
||
}));
|
||
}
|
||
|
||
export const HeroList = [5021,5022,5023,5024,5025,5026,5027,5028]
|
||
export const MonList = [5201,5202,5203,5204,5205,5206,5219,5220,5221,5222,5223,5224,5225,5226,5227]
|
||
export const Masters = [5001,5002,5005,5009,5010,5011]
|
||
|
||
export const HeroPos={
|
||
0:{pos:v3(-290,0,0)},
|
||
1:{pos:v3(0,0,0)},
|
||
2:{pos:v3(-100,0,0)},
|
||
}
|
||
export const HQuality = {
|
||
WHITE:1,
|
||
GREEN:2,
|
||
BLUE:3,
|
||
PURPLE:4,
|
||
ORANGE:5,
|
||
}
|
||
export const MonSet = {
|
||
0:{pos:v3(160,0,0)},
|
||
1:{pos:v3(220,0,0)},
|
||
2:{pos:v3(280,0,0)},
|
||
3:{pos:v3(340,0,0)},
|
||
4:{pos:v3(400,0,0)},
|
||
5:{pos:v3(460,0,0)},
|
||
6:{pos:v3(520,0,0)},
|
||
7:{pos:v3(440,0,0)},
|
||
8:{pos:v3(480,0,0)},
|
||
9:{pos:v3(520,0,0)},
|
||
10:{pos:v3(560,0,0)},
|
||
11:{pos:v3(830,0,0)},
|
||
12:{pos:v3(870,0,0)},
|
||
13:{pos:v3(910,0,0)},
|
||
14:{pos:v3(950,0,0)},
|
||
15:{pos:v3(990,0,0)},
|
||
16:{pos:v3(1030,0,0)},
|
||
17:{pos:v3(1070,0,0)},
|
||
18:{pos:v3(1110,0,0)},
|
||
19:{pos:v3(1150,0,0)},
|
||
20:{pos:v3(1190,0,0)},
|
||
21:{pos:v3(1230,0,0)},
|
||
22:{pos:v3(1270,0,0)},
|
||
23:{pos:v3(1310,0,0)},
|
||
24:{pos:v3(1350,0,0)},
|
||
25:{pos:v3(1390,0,0)},
|
||
26:{pos:v3(1430,0,0)},
|
||
27:{pos:v3(1470,0,0)},
|
||
28:{pos:v3(1510,0,0)},
|
||
29:{pos:v3(1550,0,0)},
|
||
30:{pos:v3(1590,0,0)},
|
||
31:{pos:v3(1630,0,0)},
|
||
}
|
||
|
||
// 经验值计算函数 - 复杂递增规律
|
||
// 基础经验值:100
|
||
// 递增值:每级递增10,且递增值本身也会递增
|
||
// 公式:基础经验值 + 递增值累加
|
||
// 递增值规律:第1级递增值=10,第2级递增值=20,第3级递增值=30...
|
||
export const getUpExp = (currentLevel: number): number => {
|
||
const baseExp = 100; // 基础经验值
|
||
let totalIncrement = 0;
|
||
|
||
// 计算从1级到当前等级的递增值累加
|
||
for (let level = 1; level < currentLevel; level++) {
|
||
totalIncrement += level * 10; // 每级的递增值 = 等级 * 10
|
||
}
|
||
|
||
return baseExp + totalIncrement;
|
||
};
|
||
|
||
// 获取从当前等级升级到目标等级所需的总经验值
|
||
export const getTotalUpExp = (currentLevel: number, targetLevel: number): number => {
|
||
let totalExp = 0;
|
||
for (let level = currentLevel; level < targetLevel; level++) {
|
||
totalExp += getUpExp(level);
|
||
}
|
||
return totalExp;
|
||
};
|
||
|
||
// 简化的升级属性增长计算
|
||
// 基于 HType 的攻击力增长配置
|
||
export const ApGrowthByType = {
|
||
[HType.warrior]: (baseAp: number) => Math.floor(baseAp * 0.05) + 3, // 战士:+5% + 3
|
||
[HType.remote]: (baseAp: number) => Math.floor(baseAp * 0.10) + 2, // 远程:+10% + 2
|
||
[HType.mage]: (baseAp: number) => Math.floor(baseAp * 0.15) + 1, // 法师:+15% + 1
|
||
};
|
||
|
||
// 基于 HType 的HP增长配置
|
||
export const HpGrowthByType = {
|
||
[HType.warrior]: (baseHp: number) => Math.floor(baseHp * 0.08) + 10, // 战士:+8% + 10
|
||
[HType.remote]: (baseHp: number) => Math.floor(baseHp * 0.05) + 5, // 远程:+5% + 5
|
||
[HType.mage]: (baseHp: number) => Math.floor(baseHp * 0.03) + 3, // 法师:+3% + 3
|
||
};
|
||
|
||
// 获取从1级升级到2级增加的攻击力
|
||
export const getUpAp = (heroId: number): number => {
|
||
const heroInfo = HeroInfo[heroId];
|
||
if (!heroInfo) {
|
||
console.warn(`[getUpAp] 英雄 ${heroId} 不存在`);
|
||
return 0;
|
||
}
|
||
|
||
const baseAp = heroInfo.ap;
|
||
const heroType = heroInfo.type;
|
||
const growthFunction = ApGrowthByType[heroType] || ApGrowthByType[HType.warrior];
|
||
return growthFunction(baseAp);
|
||
};
|
||
|
||
// 获取从1级升级到2级增加的HP
|
||
export const getUpHp = (heroId: number): number => {
|
||
const heroInfo = HeroInfo[heroId];
|
||
if (!heroInfo) {
|
||
console.warn(`[getUpHp] 英雄 ${heroId} 不存在`);
|
||
return 0;
|
||
}
|
||
|
||
const baseHp = heroInfo.hp;
|
||
const heroType = heroInfo.type;
|
||
const growthFunction = HpGrowthByType[heroType] || HpGrowthByType[HType.warrior];
|
||
return growthFunction(baseHp);
|
||
};
|
||
|
||
// 获取英雄在指定等级的总攻击力
|
||
export const getHeroTotalAp = (heroId: number, level: number): number => {
|
||
const heroInfo = HeroInfo[heroId];
|
||
if (!heroInfo) {
|
||
console.warn(`[getHeroTotalAp] 英雄 ${heroId} 不存在`);
|
||
return 0;
|
||
}
|
||
|
||
const baseAp = heroInfo.ap;
|
||
const heroType = heroInfo.type;
|
||
const growthFunction = ApGrowthByType[heroType] || ApGrowthByType[HType.warrior];
|
||
const levelUpAp = growthFunction(baseAp);
|
||
return baseAp + levelUpAp;
|
||
};
|
||
|
||
// 获取英雄在指定等级的总HP
|
||
export const getHeroTotalHp = (heroId: number, level: number): number => {
|
||
const heroInfo = HeroInfo[heroId];
|
||
if (!heroInfo) {
|
||
console.warn(`[getHeroTotalHp] 英雄 ${heroId} 不存在`);
|
||
return 0;
|
||
}
|
||
|
||
const baseHp = heroInfo.hp;
|
||
const heroType = heroInfo.type;
|
||
const growthFunction = HpGrowthByType[heroType] || HpGrowthByType[HType.warrior];
|
||
const levelUpHp = growthFunction(baseHp);
|
||
return baseHp + levelUpHp;
|
||
};
|
||
|
||
// 获取从当前等级升级到目标等级增加的攻击力
|
||
export const getApIncrease = (heroId: number, currentLevel: number, targetLevel: number): number => {
|
||
const heroInfo = HeroInfo[heroId];
|
||
if (!heroInfo) {
|
||
console.warn(`[getApIncrease] 英雄 ${heroId} 不存在`);
|
||
return 0;
|
||
}
|
||
|
||
const baseAp = heroInfo.ap;
|
||
const heroType = heroInfo.type;
|
||
const growthFunction = ApGrowthByType[heroType] || ApGrowthByType[HType.warrior];
|
||
return growthFunction(baseAp);
|
||
};
|
||
|
||
// 获取从当前等级升级到目标等级增加的HP
|
||
export const getHpIncrease = (heroId: number, currentLevel: number, targetLevel: number): number => {
|
||
const heroInfo = HeroInfo[heroId];
|
||
if (!heroInfo) {
|
||
console.warn(`[getHpIncrease] 英雄 ${heroId} 不存在`);
|
||
return 0;
|
||
}
|
||
|
||
const baseHp = heroInfo.hp;
|
||
const heroType = heroInfo.type;
|
||
const growthFunction = HpGrowthByType[heroType] || HpGrowthByType[HType.warrior];
|
||
return growthFunction(baseHp);
|
||
};
|
||
|
||
// 获取升级后的完整属性信息
|
||
export const getLevelUpStats = (heroId: number, currentLevel: number, targetLevel: number) => {
|
||
return {
|
||
apIncrease: getApIncrease(heroId, currentLevel, targetLevel),
|
||
hpIncrease: getHpIncrease(heroId, currentLevel, targetLevel),
|
||
newTotalAp: getHeroTotalAp(heroId, targetLevel),
|
||
newTotalHp: getHeroTotalHp(heroId, targetLevel)
|
||
};
|
||
};
|
||
|
||
// 根据英雄类型获取增长模式描述
|
||
export const getGrowthModeDescription = (heroType: HType): string => {
|
||
switch (heroType) {
|
||
case HType.warrior:
|
||
return "战士型:AP固定增长为主(每级+3,+5%),HP高增长(每级+10,+8%)";
|
||
case HType.remote:
|
||
return "远程型:AP平衡增长(每级+2,+10%),HP中等增长(每级+5,+5%)";
|
||
case HType.mage:
|
||
return "法师型:AP百分比增长为主(每级+1,+15%),HP低增长(每级+3,+3%)";
|
||
default:
|
||
return "未知类型";
|
||
}
|
||
};
|
||
|
||
export const HeroInfo = {
|
||
|
||
//主将
|
||
5001:{uuid:5001,name:"刺心.艾吉斯",path:"k2", quality:HQuality.BLUE,lv:1,kind:1,
|
||
type:HType.warrior,hp:100,ap:15,dis:400,cd:1.5,speed:50,skills:[6010,6004,6004],
|
||
buff:[],info:"剑类专精,穿刺伤害额外+10%"},
|
||
|
||
5002:{uuid:5002,name:"飓风.格罗姆",path:"k3", quality:HQuality.BLUE,lv:1,kind:1,
|
||
type:HType.warrior,hp:100,ap:15,dis:400,cd:1.5,speed:50,skills:[6010,6005,6005],
|
||
buff:[],info:"斧类专精,风怒概率增加10%"},
|
||
|
||
// 5003:{uuid:5003,name:"碎颅.赫克托",path:"k4", quality:HQuality.BLUE,lv:1,kind:1,
|
||
// type:HType.warrior,hp:100,ap:15,dis:400,cd:1.5,speed:50,skills:[6010,6021,6001],
|
||
// buff:[],info:"锤类专精,暴击概率增加10%"},
|
||
|
||
// 5004:{uuid:5004,name:"裂伤.塔米拉",path:"k3", quality:HQuality.BLUE,lv:1,kind:1,
|
||
// type:HType.warrior,hp:100,ap:15,dis:400,cd:1.5,speed:50,skills:[6010,6021,6001],
|
||
// buff:[],info:"刀类专精,易伤效果额外持续1次"},
|
||
|
||
5005:{uuid:5005,name:"幽灵射手",path:"a4", quality:HQuality.BLUE,lv:1,kind:2,
|
||
type:HType.remote,hp:100,ap:15,dis:400,cd:1.5,speed:50,skills:[6003,6003,6003],
|
||
buff:[],info:"说明"},
|
||
|
||
|
||
5007:{uuid:5007,name:"混沌法师",path:"zh1", quality:HQuality.BLUE,lv:1,kind:2,
|
||
type:HType.mage,hp:100,ap:15,dis:400,cd:1.5,speed:50,skills:[6002,6002,6002],
|
||
buff:[],info:"说明"},
|
||
|
||
5008:{uuid:5008,name:"火焰法师",path:"zh2", quality:HQuality.BLUE,lv:1,kind:2,
|
||
type:HType.mage,hp:100,ap:15,dis:400,cd:1.5,speed:50,skills:[6002,6002,6002],
|
||
buff:[],info:"说明"},
|
||
|
||
5009:{uuid:5009,name:"风暴精灵",path:"d1", quality:HQuality.BLUE,lv:1,kind:2,
|
||
type:HType.mage,hp:100,ap:15,dis:400,cd:1.5,speed:50,skills:[6002,6002,6002],
|
||
buff:[],info:"说明"},
|
||
|
||
5010:{uuid:5010,name:"战争祭祀",path:"d2", quality:HQuality.BLUE,lv:1,kind:2,
|
||
type:HType.mage,hp:100,ap:15,dis:400,cd:1.5,speed:50,skills:[6002,6002,6002],
|
||
buff:[],info:"说明"},
|
||
|
||
5011:{uuid:5011,name:"暴风射手",path:"a5", quality:HQuality.BLUE,lv:1,kind:2,
|
||
type:HType.remote,hp:100,ap:15,dis:400,cd:1.5,speed:50,skills:[6003,6003,6003],
|
||
buff:[],info:"说明"},
|
||
|
||
|
||
|
||
//怪物
|
||
5201:{uuid:5201,name:"兽人战士",path:"mor1", quality:HQuality.GREEN,lv:1,kind:1,
|
||
type:HType.warrior,hp:25,ap:5,dis:90,cd:2,speed:45,skills:[6010],
|
||
buff:[],info:"普通怪物-战士型"},
|
||
|
||
5202:{uuid:5202,name:"兽人刺客",path:"mor2", quality:HQuality.GREEN,lv:1,kind:1,
|
||
type:HType.remote,hp:20,ap:5,dis:350,cd:1.5,speed:45,skills:[6008],
|
||
buff:[],info:"普通怪物-战士型"},
|
||
|
||
5203:{uuid:5203,name:"兽人护卫",path:"mor3", quality:HQuality.GREEN,lv:1,kind:1,
|
||
type:HType.warrior,hp:25,ap:5,dis:90,cd:2,speed:45,skills:[6010],
|
||
buff:[],info:"普通怪物-战士型"},
|
||
|
||
5204:{uuid:5204,name:"石卫", path:"mgem1",quality:HQuality.GREEN,lv:1,kind:1,
|
||
type:HType.mage,hp:18,ap:5,dis:90,cd:2.5,speed:45,skills:[6010],
|
||
buff:[],info:"法师怪物-高伤害脆弱"},
|
||
|
||
5205:{uuid:5205,name:"土卫", path:"mgem2",quality:HQuality.GREEN,lv:1,kind:1,
|
||
type:HType.mage,hp:18,ap:5,dis:90,cd:2.5,speed:45,skills:[6010],
|
||
buff:[],info:"法师怪物-高伤害脆弱"},
|
||
|
||
5206:{uuid:5206,name:"树卫", path:"mgem3",quality:HQuality.GREEN,lv:1,kind:1,
|
||
type:HType.mage,hp:18,ap:5,dis:90,cd:2.5,speed:45,skills:[6010],
|
||
buff:[],info:"法师怪物-高伤害脆弱"},
|
||
|
||
|
||
|
||
5219:{uuid:5219,name:"牛头战士",path:"mn1", quality:HQuality.GREEN,lv:2,kind:1,
|
||
type:HType.warrior,hp:25,ap:5,dis:90,cd:2,speed:45,skills:[6010],
|
||
buff:[],info:"普通怪物-战士型"},
|
||
|
||
5220:{uuid:5220,name:"牛头战士",path:"mn2", quality:HQuality.GREEN,lv:1,kind:1,
|
||
type:HType.warrior,hp:25,ap:5,dis:90,cd:2,speed:45,skills:[6010],
|
||
buff:[],info:"普通怪物-战士型"},
|
||
|
||
5221:{uuid:5221,name:"牛头战士",path:"mn3", quality:HQuality.GREEN,lv:1,kind:1,
|
||
type:HType.remote,hp:20,ap:5,dis:350,cd:1.5,speed:45,skills:[6008],
|
||
buff:[],info:"普通怪物-战士型"},
|
||
|
||
5222:{uuid:5222,name:"独眼巨人",path:"md1", quality:HQuality.GREEN,lv:1,kind:1,
|
||
type:HType.warrior,hp:25,ap:5,dis:90,cd:2,speed:45,skills:[6010],
|
||
buff:[],info:"普通怪物-战士型"},
|
||
|
||
5223:{uuid:5223,name:"独眼巨人",path:"md2", quality:HQuality.GREEN,lv:1,kind:1,
|
||
type:HType.warrior,hp:25,ap:5,dis:90,cd:2,speed:45,skills:[6010],
|
||
buff:[],info:"普通怪物-战士型"},
|
||
|
||
5224:{uuid:5224,name:"独眼巨人",path:"md3", quality:HQuality.GREEN,lv:1,kind:1,
|
||
type:HType.remote,hp:20,ap:5,dis:350,cd:1.5,speed:45,skills:[6010],
|
||
buff:[],info:"普通怪物-战士型"},
|
||
|
||
5225:{uuid:5225,name:"精英独眼",path:"md4", quality:HQuality.BLUE,lv:1,kind:1,
|
||
type:HType.warrior,hp:45,ap:12,dis:300,cd:2,speed:25,skills:[6006],
|
||
buff:[],info:"精英怪物-战士型"},
|
||
|
||
5226:{uuid:5226,name:"精英牛头",path:"mn4", quality:HQuality.BLUE,lv:1,kind:1,
|
||
type:HType.warrior,hp:45,ap:12,dis:300,cd:2,speed:25,skills:[6007],
|
||
buff:[],info:"精英怪物-战士型"},
|
||
|
||
5227:{uuid:5227,name:"精英兽人",path:"mor4", quality:HQuality.BLUE,lv:1,kind:1,
|
||
type:HType.warrior,hp:45,ap:12,dis:300,cd:2,speed:25,skills:[6008],
|
||
buff:[],info:"精英怪物-战士型"},
|
||
|
||
};
|
||
|
||
// ==================== 怪物系列分类配置 ====================
|
||
|
||
// 怪物系列枚举
|
||
export enum MonsterSeriesType {
|
||
ORC = "ORC", // 兽人系列
|
||
CYCLOPS = "CYCLOPS", // 独眼系列
|
||
MINOTAUR = "MINOTAUR", // 牛头系列
|
||
NATURE = "NATURE", // 自然系列
|
||
}
|
||
|
||
// 怪物系列配置
|
||
export const MonsterSeriesConfig = {
|
||
// 兽人系列 (mor开头)
|
||
[MonsterSeriesType.ORC]: {
|
||
name: "兽人系列",
|
||
description: "来自荒野的兽人族群",
|
||
monsters: {
|
||
warrior: [5201, 5203], // 兽人战士、兽人护卫、精英兽人
|
||
remote: [5202, 5227], // 兽人刺客
|
||
mage: [] // 无法师
|
||
},
|
||
allMonsters: [5201, 5202, 5203, 5227]
|
||
},
|
||
|
||
// 独眼系列 (md开头)
|
||
[MonsterSeriesType.CYCLOPS]: {
|
||
name: "独眼系列",
|
||
description: "古老的独眼巨人族群",
|
||
monsters: {
|
||
warrior: [5222, 5223], // 独眼巨人x2、精英独眼
|
||
remote: [5224, 5225], // 独眼巨人(远程)
|
||
mage: [] // 无法师
|
||
},
|
||
allMonsters: [5222, 5223, 5224, 5225]
|
||
},
|
||
|
||
// 牛头系列 (mn开头)
|
||
[MonsterSeriesType.MINOTAUR]: {
|
||
name: "牛头系列",
|
||
description: "迷宫中的牛头怪族群",
|
||
monsters: {
|
||
warrior: [5219, 5220], // 牛头战士x2、精英牛头
|
||
remote: [5221, 5226], // 牛头战士(远程)
|
||
mage: [] // 无法师
|
||
},
|
||
allMonsters: [5219, 5220, 5221, 5226]
|
||
},
|
||
|
||
// 自然系列 (mgem开头)
|
||
[MonsterSeriesType.NATURE]: {
|
||
name: "自然系列",
|
||
description: "大地与自然的守护者",
|
||
monsters: {
|
||
warrior: [], // 无战士
|
||
remote: [], // 无远程
|
||
mage: [5204, 5205, 5206] // 石卫、土卫、树卫
|
||
},
|
||
allMonsters: [5204, 5205, 5206]
|
||
},
|
||
|
||
};
|
||
|
||
// 获取指定系列的怪物列表
|
||
export const getMonstersBySeries = (series: MonsterSeriesType, type?: keyof typeof HType): number[] => {
|
||
const seriesConfig = MonsterSeriesConfig[series];
|
||
if (!seriesConfig) {
|
||
console.warn(`[MonsterSeries]: 未找到系列 ${series}`);
|
||
return [];
|
||
}
|
||
|
||
if (type !== undefined) {
|
||
const typeKey = HType[type] === HType.warrior ? "warrior" :
|
||
HType[type] === HType.remote ? "remote" : "mage";
|
||
return seriesConfig.monsters[typeKey] || [];
|
||
}
|
||
|
||
return seriesConfig.allMonsters;
|
||
};
|
||
|
||
// 根据怪物UUID获取所属系列
|
||
export const getMonsterSeries = (uuid: number): MonsterSeriesType | null => {
|
||
for (const [seriesKey, config] of Object.entries(MonsterSeriesConfig)) {
|
||
if (config.allMonsters.includes(uuid)) {
|
||
return seriesKey as MonsterSeriesType;
|
||
}
|
||
}
|
||
return null;
|
||
};
|
||
|
||
// 获取系列信息
|
||
export const getSeriesInfo = (series: MonsterSeriesType) => {
|
||
return MonsterSeriesConfig[series] || null;
|
||
};
|
||
|
||
// 获取所有系列列表
|
||
export const getAllMonsterSeries = (): MonsterSeriesType[] => {
|
||
return Object.values(MonsterSeriesType);
|
||
};
|
||
|
||
// 按类型分组的怪物列表
|
||
export const MonstersByType = {
|
||
warrior: [5201, 5203, 5219, 5220, 5222, 5223, 5225, 5226, 5227], // 所有战士类型怪物
|
||
remote: [5202, 5221, 5224], // 所有远程类型怪物
|
||
mage: [5204, 5205, 5206,] // 所有法师类型怪物
|
||
};
|
||
|
||
// 随机从指定系列获取怪物
|
||
export const getRandomMonsterFromSeries = (series: MonsterSeriesType, type?: keyof typeof HType): number => {
|
||
const monsters = getMonstersBySeries(series, type);
|
||
if (monsters.length === 0) {
|
||
console.warn(`[MonsterSeries]: 系列 ${series} 中没有${type ? HType[type] : ''}类型怪物`);
|
||
return 5201; // 返回默认怪物
|
||
}
|
||
return monsters[Math.floor(Math.random() * monsters.length)];
|
||
};
|
||
|
||
// 随机选择一个系列
|
||
export const getRandomSeries = (): MonsterSeriesType => {
|
||
const allSeries = getAllMonsterSeries();
|
||
return allSeries[Math.floor(Math.random() * allSeries.length)];
|
||
};
|
||
|
||
|