Merge branch 'main' of ssh://dev.eoxnet.com:40086/pixelheros

This commit is contained in:
walkpan
2025-12-26 13:17:20 +08:00
5 changed files with 30 additions and 13 deletions

View File

@@ -1,4 +1,5 @@
import { Attrs } from "./HeroAttrs";
import { ItalConf, talConf } from "./TalSet";
export interface ITDLevelOption {
attr: Attrs;
@@ -155,7 +156,7 @@ export const LEVEL_OPTIONS_TABLE: Record<number, ITDLevelOption[]> = {
/**
* 获取指定等级的随机选项
*/
export const getRandomOptions = (level: number, count: number = 4): ITDLevelOption[] => {
export const getNormalBuffs = (level: number, count: number = 4): ITDLevelOption[] => {
const pool = LEVEL_OPTIONS_TABLE[level];
if (!pool || pool.length === 0) return [];
@@ -186,3 +187,29 @@ export const getRandomOptions = (level: number, count: number = 4): ITDLevelOpti
return result;
};
// 天赋获取等级
export const TALENT_LEVELS = [5, 10, 15, 20];
/**
* 获取天赋选项(从天赋池中随机抽取)
* @param count 选项数量默认4个
*/
export const getTalentOptions = (count: number = 4): ItalConf[] => {
// 获取所有天赋列表
const allTalents = Object.values(talConf);
if (allTalents.length === 0) return [];
const result: ItalConf[] = [];
const tempPool = [...allTalents];
// 随机抽取指定数量
while (result.length < count && tempPool.length > 0) {
const index = Math.floor(Math.random() * tempPool.length);
result.push(tempPool[index]);
tempPool.splice(index, 1);
}
return result;
};

View File

@@ -131,4 +131,3 @@ export const talConf: Record<number, ItalConf> = {
};
// ========== 工具函数 ==========