装备添加
This commit is contained in:
@@ -1,32 +1,122 @@
|
||||
/*
|
||||
CardList type: 1:精灵 2:技能 3:装备
|
||||
CardList type: 1:伙伴 2:技能 3:装备
|
||||
*/
|
||||
|
||||
export const CardList={
|
||||
1:[
|
||||
{uuid:9001,type:1},{uuid:9002,type:1},{uuid:9011,type:1},{uuid:9021,type:1},{uuid:9031,type:1},{uuid:9041,type:1}
|
||||
// {uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},{uuid:9010,type:1},{uuid:9011,type:1},{uuid:9012,type:1},
|
||||
],
|
||||
2:[
|
||||
{uuid:9001,type:1},{uuid:9002,type:1},{uuid:9011,type:1},{uuid:9021,type:1},{uuid:9031,type:1},{uuid:9041,type:1}
|
||||
],
|
||||
3:[
|
||||
{uuid:9001,type:1},{uuid:9002,type:1},{uuid:9011,type:1},{uuid:9021,type:1},{uuid:9031,type:1},{uuid:9041,type:1}
|
||||
],
|
||||
4:[
|
||||
{uuid:9001,type:1},{uuid:9002,type:1},{uuid:9011,type:1},{uuid:9021,type:1},{uuid:9031,type:1},{uuid:9041,type:1}
|
||||
],
|
||||
5:[
|
||||
{uuid:1001,type:2},{uuid:1002,type:2},{uuid:4011,type:2},{uuid:4012,type:2},
|
||||
{uuid:6001,type:3},{uuid:6004,type:3},{uuid:6101,type:3},{uuid:6002,type:3},{uuid:6003,type:3},{uuid:6005,type:3},{uuid:6006,type:3},
|
||||
{uuid:6102,type:3},{uuid:6103,type:3}, {uuid:6210,type:3},{uuid:6213,type:3},{uuid:6216,type:3},{uuid:6211,type:3},{uuid:6212,type:3},
|
||||
{uuid:6214,type:3},{uuid:6215,type:3},{uuid:6217,type:3},{uuid:6218,type:3},
|
||||
// {uuid:9007,type:1},{uuid:9008,type:1},{uuid:9009,type:1},{uuid:9010,type:1},{uuid:9011,type:1},{uuid:9012,type:1},
|
||||
],
|
||||
6:[
|
||||
{uuid:1001,type:2},{uuid:1002,type:2},{uuid:4011,type:2},{uuid:4012,type:2},
|
||||
{uuid:6001,type:3},{uuid:6004,type:3},{uuid:6101,type:3},{uuid:6002,type:3},{uuid:6003,type:3},{uuid:6005,type:3},{uuid:6006,type:3},
|
||||
{uuid:6102,type:3},{uuid:6103,type:3}, {uuid:6210,type:3},{uuid:6213,type:3},{uuid:6216,type:3},{uuid:6211,type:3},{uuid:6212,type:3},
|
||||
{uuid:6214,type:3},{uuid:6215,type:3},{uuid:6217,type:3},{uuid:6218,type: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
|
||||
}));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user