/* 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={ EQUIP:1, //装备加成 强化 SKILL:2, //技能加成 强化 AOE:3, //伤害技能 范围伤害 DEBUFF:4, //debuff技能 范围debuff BUFF:5, //buff技能 范围buff } export const SuperCards={ 3001:{uuid:3001,name:"附魔宝典",path:"3001",type:SuperCardsType.EQUIP,value:1,tals:"你的提升英雄/伙伴生命/攻击力装备效果,额外添加+1"}, }