73 lines
2.2 KiB
TypeScript
73 lines
2.2 KiB
TypeScript
// 天晶石表
|
|
import { readFileAndParse, parseGoodStr, parseNumberList, decodeArrayListStr } from '../util'
|
|
import { FILENAME } from '../../consts';
|
|
import { RewardInter } from '../interface';
|
|
|
|
export interface DicJewel {
|
|
// 物品id
|
|
readonly good_id: number;
|
|
// 天晶石名
|
|
readonly name: string;
|
|
// 装备栏id
|
|
readonly eplaceId: number;
|
|
// itid
|
|
readonly itid: number;
|
|
// 天晶石阶
|
|
readonly lv: number;
|
|
// 天晶石品质
|
|
readonly quality: number;
|
|
// 天晶石属性条数
|
|
readonly effectCount: number;
|
|
// 套装效果
|
|
readonly randomEffect: number[];
|
|
// 稀有属性
|
|
readonly rareEffect: number[];
|
|
// 基础属性
|
|
readonly rareEffectBaseAttr: {id: number, num: number}[];
|
|
// 对应藏宝图id
|
|
readonly mapGoodId: number;
|
|
// 淬炼消耗
|
|
readonly quenchConsume: RewardInter[];
|
|
// 寻宝关卡id
|
|
readonly gkId: number;
|
|
// 继承消耗
|
|
readonly inheritConsume: RewardInter[];
|
|
}
|
|
|
|
export const dicJewel = new Map<number, DicJewel>();
|
|
export const dicBlueprt = new Map<number, number>();
|
|
export const dicBlueprtByLv = new Map<number, number[]>();
|
|
export function loadJewel() {
|
|
dicJewel.clear();
|
|
|
|
let arr = readFileAndParse(FILENAME.DIC_JEWEL);
|
|
|
|
arr.forEach(o => {
|
|
o.randomEffect = parseNumberList(o.randomEffect);
|
|
o.rareEffect = parseNumberList(o.rareEffect);
|
|
o.rareEffectBaseAttr = parseAttr(o.rareEffectBaseAttr);
|
|
o.quenchConsume = parseGoodStr(o.quenchConsume);
|
|
o.inheritConsume = parseGoodStr(o.inheritConsume);
|
|
|
|
dicJewel.set(o.good_id, o);
|
|
dicBlueprt.set(o.mapGoodId, o.good_id);
|
|
if(!dicBlueprtByLv.has(o.lv)) {
|
|
dicBlueprtByLv.set(o.lv, []);
|
|
}
|
|
dicBlueprtByLv.get(o.lv).push(o.mapGoodId);
|
|
});
|
|
arr = undefined;
|
|
}
|
|
|
|
function parseAttr(str: string) {
|
|
let result = new Array<{id: number, num: number}>();
|
|
if(!str) return result;
|
|
let decodeArr = decodeArrayListStr(str);
|
|
for(let [id, num] of decodeArr) {
|
|
if(isNaN(parseInt(id)) || isNaN(parseInt(num))) {
|
|
throw new Error('data table format wrong');
|
|
}
|
|
result.push({id: parseInt(id), num: parseInt(num)});
|
|
}
|
|
return result
|
|
} |