全局:加载json方法全部改为最新

This commit is contained in:
luying
2021-05-06 20:25:05 +08:00
parent 2ef00e8179
commit 0315269387
36 changed files with 401 additions and 920 deletions
+24
View File
@@ -28,10 +28,15 @@ export interface DicWar {
readonly dailyType: number;
// 显示章节名
readonly detailUIBg: string[];
// 寻宝匹配json
readonly dispatchJsonId: number;
// 寻宝奖励
readonly jackpotReward: Array<{id: number, weight: number}>;
}
export const dicWar = new Map<number, DicWar>();
export const dicWarPvp = new Array<DicWar>();
export const dicDailyWarByType = new Map<number, DicWar[]>();
for(let filename of WAR_RELATE_TABLES) {
const str = readJsonFile(filename);
@@ -42,10 +47,16 @@ for(let filename of WAR_RELATE_TABLES) {
o.conditionReward = parseConditionReward(o.conditionReward);
o.parseRandomReward = parseRandomReward(o.parseRandomReward);
o.detailUIBg = parseDetailUIBg(o.detailUIBg);
o.jackpotReward = parseJackpotReward(o.jackpotReward);
dicWar.set(o.war_id, o);
if(o.warType == WAR_TYPE.PVP) {
dicWarPvp.push(o);
} else if (o.warType == WAR_TYPE.DAILY) {
if(!dicDailyWarByType.has(o.dailyType)) {
dicDailyWarByType.set(o.dailyType, []);
}
dicDailyWarByType.get(o.dailyType).push(o);
}
});
}
@@ -94,4 +105,17 @@ function parseDetailUIBg(str: string = '') {
if(!str) return result;
let decodeArr = decodeArrayStr(str, '_');
return decodeArr;
}
function parseJackpotReward(str: string = '') {
let result = new Array<{id: number, weight: number}>();
if(!str) return result;
let decodeArr = decodeArrayListStr(str);
for(let [id, weight] of decodeArr) {
if(isNaN(parseInt(id)) || isNaN(parseInt(weight))) {
throw new Error('data table format wrong');
}
result.push({id: parseInt(id), weight: parseInt(weight)});
}
return result
}