军团:改表
This commit is contained in:
@@ -1,7 +1,8 @@
|
||||
// 关卡表
|
||||
import {decodeArrayListStr, decodeArrayStr, parseNumberList, readFileAndParse} from '../util'
|
||||
import { WAR_RELATE_TABLES, WAR_TYPE } from '../../consts';
|
||||
import { TRAIN_REWARD_TYPE, WAR_RELATE_TABLES, WAR_TYPE } from '../../consts';
|
||||
import { isString } from 'underscore'
|
||||
import { RewardInter } from '../interface';
|
||||
export interface DicWar {
|
||||
|
||||
// 关卡id
|
||||
@@ -44,6 +45,10 @@ export interface DicWar {
|
||||
readonly scriptBefore: string;
|
||||
// 战后剧本
|
||||
readonly scriptAfter: string;
|
||||
// 练兵场胜利奖励
|
||||
readonly winReward: Map<number, number|RewardInter[]>;
|
||||
// 练兵场失败奖励
|
||||
readonly failReward: Map<number, number|RewardInter[]>;
|
||||
}
|
||||
|
||||
export const dicWar = new Map<number, DicWar>();
|
||||
@@ -76,7 +81,6 @@ export function loadWar() {
|
||||
}
|
||||
}
|
||||
|
||||
dicWar.set(o.war_id, o);
|
||||
if(o.warType == WAR_TYPE.PVP) {
|
||||
dicWarPvp.push(o);
|
||||
} else if (o.warType == WAR_TYPE.DAILY) {
|
||||
@@ -84,7 +88,11 @@ export function loadWar() {
|
||||
dicDailyWarByType.set(o.dailyType, []);
|
||||
}
|
||||
dicDailyWarByType.get(o.dailyType).push(o);
|
||||
} else if (o.warType == WAR_TYPE.GUILD_TRAIN) {
|
||||
o.winReward = parseTrainReward(o.winReward);
|
||||
o.failReward = parseTrainReward(o.failReward);
|
||||
}
|
||||
dicWar.set(o.war_id, o);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -159,4 +167,29 @@ function parseForbiddenChara(str: string = '') {
|
||||
result.push({type: parseInt(type), id: parseInt(id)});
|
||||
}
|
||||
return result
|
||||
}
|
||||
|
||||
function parseTrainReward(str: string) {
|
||||
let result = new Map<number, number|RewardInter[]>();
|
||||
if(!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for(let [type, str1, str2] of decodeArr) {
|
||||
if(parseInt(type) == TRAIN_REWARD_TYPE.SCORE) {
|
||||
if(isNaN(parseInt(str1))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
if(!result.has(parseInt(type))) {
|
||||
result.set(parseInt(type), parseInt(str1));
|
||||
}
|
||||
} else if (parseInt(type) == TRAIN_REWARD_TYPE.ITEM) {
|
||||
if(isNaN(parseInt(str1)) || isNaN(parseInt(str2))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
if(!result.has(parseInt(type))) {
|
||||
result.set(parseInt(type), []);
|
||||
}
|
||||
(<RewardInter[]>result.get(parseInt(type))).push({ id: parseInt(str1), count: parseInt(str2) });
|
||||
}
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user