后台: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
+51 -50
View File
@@ -1,5 +1,5 @@
// 物品表
import {decodeArrayListStr, readJsonFile, parseGoodStr, parseNumberList, decodeArrayStr} from '../util'
import {decodeArrayListStr, readFileAndParse, parseGoodStr, parseNumberList, decodeArrayStr} from '../util'
import { FILENAME, IT_TYPE, ABI_TYPE , GOOD_TYPE} from '../../consts'
import { RewardInter } from '../interface';
const _ = require('lodash');
@@ -64,9 +64,6 @@ export interface DicGoods {
readonly timeLimit: number;
}
const str = readJsonFile(FILENAME.DIC_GOODS);
let arr = JSON.parse(str);
type KeysEnum<T> = { [P in keyof Required<T>]: true };
const DicGoodsKeys: KeysEnum<DicGoods> = {
good_id: true,
@@ -101,53 +98,57 @@ export const dicGoods = new Map<number, DicGoods>();
export const blueprt = new Map<number, Array<number>>();
export const figureCondition = new Map<number, {params: number[], id: number, gid: number}[]>(); // type => {params, id, gid}
arr.forEach(o => {
o.goodsAbility = parseAbility(o);
o.goodsAbilityUp = parseAbilityUp(o);
o.composeMaterial = parseGoodStr(o.composeMaterial);
o.decomposeItem = parseGoodStr(o.decomposeItem);
o.specialAttr = parseSpecialAttr(o.specialAttr);
o.specialMaterial = parseSpecialMaterial(o.specialMaterial);
o.randomEffect = parseNumberList(o.randomEffect);
o.timeLimit = o.timelimit;
if (o.goodType == IT_TYPE.EQUIP_PIECE) {
let good = findWhere(arr, { pieceId: o.good_id });
if (!!good)
o.equipId = good.good_id;
}
let condition = parseConditionStr(o.condition);
for(let {id, type, params} of condition) {
let mapArr = figureCondition.get(type)||new Array<{params: number[], id: number, gid: number}>();
mapArr.push({ params, id: id, gid: o.good_id});
figureCondition.set(type, mapArr);
}
o.condition = condition;
dicGoods.set(o.good_id, _.pick(o, Object.keys(DicGoodsKeys)));
if (o.itid == IT_TYPE.BLUEPRT) {
let arr = blueprt.get(o.quality)||new Array<number>();
arr.push(o.good_id);
blueprt.set(o.quality, arr);
} else if (o.goodType == GOOD_TYPE.JEWEL) {
let material = o.composeMaterial[0];
if (!!material && !!material.id) {
let lastJewel = findWhere(arr,{good_id:material.id});
if (!!lastJewel) {
lastJewel.count = material.count;
lastJewel.nextJewelId = o.good_id;
if (!!o.specialMaterial.ids[0]) {
lastJewel.specialCount = o.specialMaterial.count;
lastJewel.nextSpecialId = o.specialMaterial.ids[0];
}
dicJewel.set(lastJewel.good_id, _.pick(lastJewel, Object.keys(DicGoodsKeys)));
}
} else {
dicJewel.set(o.good_id, _.pick(o, Object.keys(DicGoodsKeys)));
export function loadGoods() {
let arr = readFileAndParse(FILENAME.DIC_GOODS);
arr.forEach(o => {
o.goodsAbility = parseAbility(o);
o.goodsAbilityUp = parseAbilityUp(o);
o.composeMaterial = parseGoodStr(o.composeMaterial);
o.decomposeItem = parseGoodStr(o.decomposeItem);
o.specialAttr = parseSpecialAttr(o.specialAttr);
o.specialMaterial = parseSpecialMaterial(o.specialMaterial);
o.randomEffect = parseNumberList(o.randomEffect);
o.timeLimit = o.timelimit;
if (o.goodType == IT_TYPE.EQUIP_PIECE) {
let good = findWhere(arr, { pieceId: o.good_id });
if (!!good)
o.equipId = good.good_id;
}
}
});
arr = undefined;
let condition = parseConditionStr(o.condition);
for(let {id, type, params} of condition) {
let mapArr = figureCondition.get(type)||new Array<{params: number[], id: number, gid: number}>();
mapArr.push({ params, id: id, gid: o.good_id});
figureCondition.set(type, mapArr);
}
o.condition = condition;
dicGoods.set(o.good_id, _.pick(o, Object.keys(DicGoodsKeys)));
if (o.itid == IT_TYPE.BLUEPRT) {
let arr = blueprt.get(o.quality)||new Array<number>();
arr.push(o.good_id);
blueprt.set(o.quality, arr);
} else if (o.goodType == GOOD_TYPE.JEWEL) {
let material = o.composeMaterial[0];
if (!!material && !!material.id) {
let lastJewel = findWhere(arr,{good_id:material.id});
if (!!lastJewel) {
lastJewel.count = material.count;
lastJewel.nextJewelId = o.good_id;
if (!!o.specialMaterial.ids[0]) {
lastJewel.specialCount = o.specialMaterial.count;
lastJewel.nextSpecialId = o.specialMaterial.ids[0];
}
dicJewel.set(lastJewel.good_id, _.pick(lastJewel, Object.keys(DicGoodsKeys)));
}
} else {
dicJewel.set(o.good_id, _.pick(o, Object.keys(DicGoodsKeys)));
}
}
});
arr = undefined;
}
function parseSpecialAttr(str: string) {
let specialAttr = new Map<number, number>();