后台: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
+13 -11
View File
@@ -1,4 +1,4 @@
import { readJsonFile, parseNumberList, parseGoodStr, decodeArrayListStr } from '../util'
import { readFileAndParse, parseNumberList, parseGoodStr, decodeArrayListStr } from '../util'
import { FILENAME } from '../../consts'
import { RewardInter } from '../interface';
@@ -15,18 +15,20 @@ export interface DicGacha {
readonly percent: { id: number, weight: number }[];
}
const str = readJsonFile(FILENAME.DIC_GACHA);
let arr = JSON.parse(str);
export const dicGacha = new Map<number, DicGacha>(); // id => dic
arr.forEach(o => {
o.count = parseNumberList(o.count);
o.free = parseFree(o.free);
o.cost = parseGoodStr(o.cost);
o.percent = parsePercent(o.percent);
dicGacha.set(o.id, o);
});
export function loadGacha() {
let arr = readFileAndParse(FILENAME.DIC_GACHA);
arr.forEach(o => {
o.count = parseNumberList(o.count);
o.free = parseFree(o.free);
o.cost = parseGoodStr(o.cost);
o.percent = parsePercent(o.percent);
dicGacha.set(o.id, o);
});
arr = undefined;
}
function parseFree(str: string) {
let arr = parseNumberList(str);