// 武将特技表 import { readFileAndParse, decodeArrayListStr, parseNumberList } from '../util' import { FILENAME } from '../../consts' export interface DicRandomEffectPool { // 特技id readonly id: number; // 类型 readonly type: number; // 包含的值 readonly gainValueArr: Array; // 随机值位置 readonly index: number; // 随机最小值 readonly Min: number; // 随机最大值 readonly Max: number; // 分割 readonly gap: number; // 分割 readonly rate: {min: number, max: number, weight: number}[]; // 组别 readonly group: number; // 等级 readonly level: number; } export const dicRandomEffectPool = new Map(); export const dicRandomEffectPoolByGroupAndLv = new Map(); export function loadRandomEffectPool() { dicRandomEffectPool.clear(); let arr = readFileAndParse(FILENAME.DIC_RANDOM_EFFECT_POOL); arr.forEach(o => { o.rate = parseRate(o.count); o.gainValueArr = parseNumberList(o.gainvalue); dicRandomEffectPool.set(o.id, o); dicRandomEffectPoolByGroupAndLv.set(`${o.group}_${o.level}`, o.id); }); arr = undefined; } function parseRate(str: string) { let result: {min: number, max: number, weight: number}[] = []; if(!str) return result; let decodeArr = decodeArrayListStr(str); for(let [min, max, weight] of decodeArr) { if(isNaN(parseInt(min)) || isNaN(parseInt(max)) || isNaN(parseInt(weight))) { throw new Error('data table format wrong'); } result.push({min: parseInt(min), max: parseInt(max), weight: parseInt(weight) }); } return result }