Files
heros/assets/script/game/common/config/CardSet.ts
2025-06-18 16:31:39 +08:00

135 lines
4.5 KiB
TypeScript

/*
CardList type: 1:伙伴 2:技能 3:装备
*/
import { HeroList } from "./heroSet"
import { HeroSkillList } from "./SkillSet"
import { equip_list } from "./Equips"
//1:伙伴 2:技能 3:装备的出现概率配置
export const CardProbability={
1:0.5,
2:0.3,
3:0.2,
}
export const cardType={
HERO:1,
SKILL:2,
EQUIP:3,
}
// 获取随机卡牌UUID
export function getRandomCardUUID(
heroRate: number = 1, // 伙伴出现概率修正系数
skillRate: number = 1, // 技能出现概率修正系数
equipRate: number = 1 // 装备出现概率修正系数
): { type: number; uuid: number } {
// 计算修正后的概率
const adjustedProbability = {
1: CardProbability[1] * heroRate,
2: CardProbability[2] * skillRate,
3: CardProbability[3] * equipRate
};
// 计算总概率
const totalProbability = Object.values(adjustedProbability).reduce((sum, prob) => sum + prob, 0);
// 生成0-1之间的随机数
const random = Math.random() * totalProbability;
let cumulativeProbability = 0;
// 根据修正后的概率确定卡牌类型
let cardType = 1; // 默认类型为伙伴
for (const [type, probability] of Object.entries(adjustedProbability)) {
cumulativeProbability += probability;
if (random <= cumulativeProbability) {
cardType = parseInt(type);
break;
}
}
// 根据类型获取对应的卡牌列表
let cardList: number[] = [];
switch (cardType) {
case 1: // 伙伴
cardList = HeroList;
break;
case 2: // 技能
cardList = HeroSkillList;
break;
case 3: // 装备
cardList = equip_list;
break;
}
// 从对应类型的卡牌列表中随机选择一个
const randomIndex = Math.floor(Math.random() * cardList.length);
return {type:cardType,uuid:cardList[randomIndex]};
}
// 获取指定类型的随机卡牌UUID
export function getRandomCardUUIDByType(type: number): number {
let cardList: number[] = [];
switch (type) {
case 1: // 伙伴
cardList = HeroList;
break;
case 2: // 技能
cardList = HeroSkillList;
break;
case 3: // 装备
cardList = equip_list;
break;
default:
throw new Error(`Invalid card type: ${type}`);
}
const randomIndex = Math.floor(Math.random() * cardList.length);
return cardList[randomIndex];
}
// 获取多个不重复的指定类型卡牌
export function getRandomCardsByType(
type: number,
count: number
): { type: number; uuid: number }[] {
let cardList: number[] = [];
switch (type) {
case cardType.HERO:
cardList = HeroList;
break;
case cardType.SKILL:
cardList = HeroSkillList; // 直接使用HeroSkillList数组
break;
case cardType.EQUIP:
cardList = equip_list;
break;
default:
throw new Error(`Invalid card type: ${type}`);
}
// 确保请求数量不超过可用卡牌数量
count = Math.min(count, cardList.length);
// 打乱数组顺序
const shuffled = [...cardList].sort(() => Math.random() - 0.5);
// 返回指定数量的卡牌
return shuffled.slice(0, count).map(uuid => ({
type,
uuid
}));
}
export const SuperCardsType={
SPECIAL:1, //特殊效果
AOE:2, //伤害技能 范围伤害
BUFF:3, //buff技能 范围buff
DEBUFF:4, //debuff技能 范围debuff
}
export const SuperCards={
3001:{uuid:3001,name:"附魔宝典",path:"3001",type:SuperCardsType.SPECIAL,value1:1,value2:0,value3:0,tals:"你的提升英雄/伙伴属性的装备效果,额外添加+1攻击力"},
3002:{uuid:3002,name:"附魔宝典",path:"3002",type:SuperCardsType.SPECIAL,value1:0,value2:1,value3:0,tals:"你的提升英雄/伙伴属性的装备效果,额外添加+1生命值"},
3101:{uuid:3101,name:"火球风暴",path:"3101",type:SuperCardsType.AOE,value1:10,value2:300,value3:10,tals:"召唤大量火球攻击敌人,每个火球对敌人造成英雄攻击力的300%伤害,并造成易伤(下10次伤害)"},
3201:{uuid:3201,name:"极速充能",path:"3201",type:SuperCardsType.BUFF,value1:10,value2:100,value3:0,tals:"你的英雄/伙伴接下来的10次普通攻击速度提升100%"},
3301:{uuid:3301,name:"冰霜风暴",path:"3301",type:SuperCardsType.DEBUFF,value1:30,value2:10,value3:0,tals:"场上敌人获得30%的易伤,(下10次伤害)"},
}