43 lines
1.2 KiB
TypeScript
43 lines
1.2 KiB
TypeScript
import { readFileAndParse } from '../util'
|
|
import { ABI_TYPE, FILENAME, HERO_ATTR } from '../../consts'
|
|
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
|
const _ = require('lodash');
|
|
|
|
export interface DicExpeditionSubAttr {
|
|
// 等级
|
|
readonly lv: number;
|
|
// 属性
|
|
readonly attribute: {id: number, val: number}[];
|
|
}
|
|
|
|
const DicExpeditionSubAttrKeys: KeysEnum<DicExpeditionSubAttr> = {
|
|
lv: true,
|
|
attribute: true,
|
|
};
|
|
|
|
export const dicExpeditionSubAttr = new Map<number, DicExpeditionSubAttr>();
|
|
export function loadExpeditionSubAttr() {
|
|
dicExpeditionSubAttr.clear();
|
|
let l = 1;
|
|
let arr = readFileAndParse(FILENAME.DIC_EXPEDITION_SUB_ATTR);
|
|
arr.forEach(o => {
|
|
o.attribute = parseAttribute(o);
|
|
o.lv = o.level;
|
|
for(let i = l; i <= o.lv; i++) {
|
|
dicExpeditionSubAttr.set(l, _.pick(o, Object.keys(DicExpeditionSubAttrKeys)));
|
|
l++;
|
|
}
|
|
});
|
|
arr = undefined;
|
|
}
|
|
|
|
function parseAttribute(o) {
|
|
let attribute: {id: number, val: number}[] = [];
|
|
for(let i = ABI_TYPE.ABI_HP; i < ABI_TYPE.ABI_MAX; i++) {
|
|
let field = HERO_ATTR[i];
|
|
if(o[field] != undefined) {
|
|
attribute.push({ id: i, val: o[field] });
|
|
}
|
|
}
|
|
return attribute;
|
|
} |