后台:json上传
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user