38 lines
1.0 KiB
TypeScript
38 lines
1.0 KiB
TypeScript
// 镇念塔表
|
|
import { decodeArrayListStr, readJsonFile } from '../util'
|
|
import { FILENAME } from '../../consts';
|
|
|
|
export interface DicSuit {
|
|
// 套装id
|
|
readonly id: number;
|
|
// 包含关卡
|
|
readonly name: string;
|
|
// 总件数
|
|
readonly totalCount: number;
|
|
// 套装效果
|
|
readonly effect: Array<{ count: number, seid: number }>;
|
|
}
|
|
|
|
const str = readJsonFile(FILENAME.DIC_SUIT);
|
|
let arr = JSON.parse(str);
|
|
|
|
export const dicSuit = new Map<number, DicSuit>();
|
|
|
|
arr.forEach(o => {
|
|
o.effect = parseSuitEffect(o.effect);
|
|
dicSuit.set(o.id, o);
|
|
});
|
|
arr = undefined;
|
|
|
|
function parseSuitEffect(str: string) {
|
|
let result = new Array<{ count: number, seid: number }>();
|
|
if (!str) return result;
|
|
let decodeArr = decodeArrayListStr(str);
|
|
for (let [count, seid] of decodeArr) {
|
|
if (isNaN(parseInt(count)) || isNaN(parseFloat(seid))) {
|
|
throw new Error('data table format wrong');
|
|
}
|
|
result.push({ count: parseInt(count), seid: parseFloat(seid) });
|
|
}
|
|
return result
|
|
} |