后台:json上传

This commit is contained in:
luying
2021-05-12 18:56:47 +08:00
parent 2fc5017af8
commit 148a11edab
102 changed files with 1675 additions and 1117 deletions
+14 -13
View File
@@ -1,7 +1,7 @@
// 武将表
import { ABI_TYPE, FILENAME } from '../../consts'
import { readJsonFile } from '../util'
import { readFileAndParse } from '../util'
const _ = require('lodash');
export interface DicHero {
@@ -31,22 +31,23 @@ export interface DicHero {
readonly recruit: boolean;
}
const str = readJsonFile(FILENAME.DIC_HERO);
let arr = JSON.parse(str);
type KeysEnum<T> = { [P in keyof Required<T>]: true };
const DicHeroKeys: KeysEnum<DicHero> = {heroId: true, name: true, quality: true, camp: true, jobid: true, skill: true, pieceId: true, initialStars: true, pieceCount: true, baseAbilityArr: true, baseAbilityUpArr: true, initialSkin: true, recruit: true};
export const dicMyHeroes = new Array<number>();
export const dicHero = new Map<number, DicHero>();
arr.forEach(o => {
if(o.heroId > 0 && o.heroId <= 300) {
dicMyHeroes.push(o.heroId);
}
o.baseAbilityArr = parseBaseAbilityArr(o);
o.baseAbilityUpArr = parseBaseAbilityUpArr(o);
o.recruit = parseInt(o.recruit) == 1;
dicHero.set(o.heroId, _.pick(o, Object.keys(DicHeroKeys)));
});
export function loadHero() {
let arr = readFileAndParse(FILENAME.DIC_HERO);
arr.forEach(o => {
if(o.heroId > 0 && o.heroId <= 300) {
dicMyHeroes.push(o.heroId);
}
o.baseAbilityArr = parseBaseAbilityArr(o);
o.baseAbilityUpArr = parseBaseAbilityUpArr(o);
o.recruit = parseInt(o.recruit) == 1;
dicHero.set(o.heroId, _.pick(o, Object.keys(DicHeroKeys)));
});
arr = undefined;
}
function parseBaseAbilityArr(json) {
let map = new Map<number, number>();