远征:修改机器人模板计算
This commit is contained in:
@@ -0,0 +1,43 @@
|
||||
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;
|
||||
}
|
||||
Reference in New Issue
Block a user