后台:json上传
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
// 物品表
|
||||
import { decodeArrayListStr, readJsonFile, parseGoodStr } from '../util'
|
||||
import { decodeArrayListStr, readFileAndParse, parseGoodStr } from '../util'
|
||||
import { FILENAME, ABI_TYPE} from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
const _ = require('lodash');
|
||||
@@ -25,34 +25,36 @@ export interface DicTeraph {
|
||||
readonly assiAttrValue:Map<number, number>; // 次级属性
|
||||
readonly upGradeMaterial:Array<RewardInter>;
|
||||
}
|
||||
|
||||
const str = readJsonFile(FILENAME.DIC_TERAPH);
|
||||
let arr = JSON.parse(str);
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicTeraphKeys: KeysEnum<DicTeraph> = {
|
||||
id: true,
|
||||
index: true,
|
||||
grade: true,
|
||||
mainAttrMax: true,
|
||||
mainAttrUp: true,
|
||||
criRate: true,
|
||||
criEffect: true,
|
||||
upMaterial: true,
|
||||
assiAttrValue: true,
|
||||
upGradeMaterial: true,
|
||||
}
|
||||
export const dicTeraph = new Map<string, DicTeraph>();
|
||||
arr.forEach(o => {
|
||||
o.assiAttrValue = parseAttr(o.assiAttrValue);
|
||||
o.upGradeMaterial = parseGoodStr(o.upGradeMaterial);
|
||||
o.upMaterial = parseGoodStr(o.upMaterial);
|
||||
o.mainAttrMax = parseMainAttrMax(o);
|
||||
o.mainAttrUp = parseMainAttrUp(o);
|
||||
dicTeraph.set(o.index + '_' + o.grade, _.pick(o, Object.keys(DicTeraphKeys)));
|
||||
});
|
||||
export function loadTeraph() {
|
||||
|
||||
arr = undefined;
|
||||
let arr = readFileAndParse(FILENAME.DIC_TERAPH);
|
||||
|
||||
type KeysEnum<T> = { [P in keyof Required<T>]: true };
|
||||
const DicTeraphKeys: KeysEnum<DicTeraph> = {
|
||||
id: true,
|
||||
index: true,
|
||||
grade: true,
|
||||
mainAttrMax: true,
|
||||
mainAttrUp: true,
|
||||
criRate: true,
|
||||
criEffect: true,
|
||||
upMaterial: true,
|
||||
assiAttrValue: true,
|
||||
upGradeMaterial: true,
|
||||
}
|
||||
|
||||
arr.forEach(o => {
|
||||
o.assiAttrValue = parseAttr(o.assiAttrValue);
|
||||
o.upGradeMaterial = parseGoodStr(o.upGradeMaterial);
|
||||
o.upMaterial = parseGoodStr(o.upMaterial);
|
||||
o.mainAttrMax = parseMainAttrMax(o);
|
||||
o.mainAttrUp = parseMainAttrUp(o);
|
||||
dicTeraph.set(o.index + '_' + o.grade, _.pick(o, Object.keys(DicTeraphKeys)));
|
||||
});
|
||||
|
||||
arr = undefined;
|
||||
}
|
||||
|
||||
function parseAttr(str: string) {
|
||||
let result = new Map<number, number>();
|
||||
|
||||
Reference in New Issue
Block a user