添加字典表解析
This commit is contained in:
@@ -0,0 +1,40 @@
|
||||
// 武将技能表
|
||||
import {decodeArrayListStr, readJsonFile} from '../util'
|
||||
import { FILENAME } from '../../consts/consts'
|
||||
|
||||
export interface DicHeroSkill {
|
||||
|
||||
// 技能id
|
||||
readonly skillid: number;
|
||||
// 技能名
|
||||
readonly name: string;
|
||||
// 星级解锁
|
||||
readonly starSeidArr: Array<{star: number, value: number}>;
|
||||
// 觉醒解锁
|
||||
readonly colorStarSeidArr: Array<{star: number, value: number}>;
|
||||
|
||||
}
|
||||
|
||||
const str = readJsonFile(FILENAME.DIC_HERO_SKILL);
|
||||
let arr = JSON.parse(str);
|
||||
|
||||
export const dicHeroSkill = new Map<number, DicHeroSkill>();
|
||||
arr.forEach(o => {
|
||||
o.starSeidArr = parseSeid(o.starSeid);
|
||||
o.colorStarSeidArr = parseSeid(o.colorStarSeid);
|
||||
dicHeroSkill.set(o.good_id, o);
|
||||
});
|
||||
|
||||
function parseSeid(str: string) {
|
||||
let arr = new Array<{star: number, value: number}>();
|
||||
if(!str) return arr;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for(let [star, value] of decodeArr) {
|
||||
if(isNaN(parseInt(star)) || isNaN(parseInt(value))) {
|
||||
continue;
|
||||
}
|
||||
|
||||
arr.push({ star: parseInt(star), value: parseInt(value)});
|
||||
}
|
||||
return arr;
|
||||
}
|
||||
Reference in New Issue
Block a user