名将擂台:刷新对手
This commit is contained in:
59
shared/pubUtils/dictionary/DicLadderDifficultRatio.ts
Normal file
59
shared/pubUtils/dictionary/DicLadderDifficultRatio.ts
Normal file
@@ -0,0 +1,59 @@
|
||||
// 邮件内容
|
||||
import {decodeArrayListStr, parseGoodStr, readFileAndParse} from '../util'
|
||||
import { FILENAME } from '../../consts'
|
||||
import { RewardInter } from '../interface';
|
||||
|
||||
export interface DicLadderDifficultRatio {
|
||||
// id
|
||||
readonly id: number;
|
||||
// 排名
|
||||
readonly rank: number;
|
||||
// 强度倍率
|
||||
readonly value: number;
|
||||
// 次级属性
|
||||
readonly secondAttrLevel: number;
|
||||
// 等级
|
||||
readonly level: number;
|
||||
// 关卡id
|
||||
readonly gkId: number;
|
||||
// 头像
|
||||
readonly head: number;
|
||||
// 形象
|
||||
readonly spine: number;
|
||||
// 胜利奖励
|
||||
readonly randomWinReward: { id: number, count: number, weight: number }[];
|
||||
// 失败奖励
|
||||
readonly randomFailReward: { id: number, count: number, weight: number }[];
|
||||
// 突破奖励
|
||||
readonly onceReward: RewardInter[];
|
||||
// 战力
|
||||
readonly ce: number;
|
||||
}
|
||||
|
||||
export const dicLadderDifficultRatio = new Map<number, DicLadderDifficultRatio>();
|
||||
export function loadLadderDifficultRatio() {
|
||||
dicLadderDifficultRatio.clear();
|
||||
|
||||
let arr = readFileAndParse(FILENAME.DIC_LADDER_DIFFICULTRATIO);
|
||||
arr.forEach(o => {
|
||||
o.gkId = parseInt(o.gkId);
|
||||
o.randomWinReward = parseRewardWithWeight(o.randomWinReward);
|
||||
o.randomFailReward = parseRewardWithWeight(o.randomFailReward);
|
||||
o.onceReward = parseGoodStr(o.onceReward)
|
||||
dicLadderDifficultRatio.set(o.id, o);
|
||||
});
|
||||
arr = undefined;
|
||||
}
|
||||
|
||||
function parseRewardWithWeight(str: string) {
|
||||
let result = new Array<{ id: number, count: number, weight: number }>();
|
||||
if (!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for (let [id, count, weight] of decodeArr) {
|
||||
if (isNaN(parseInt(id)) || isNaN(parseInt(count)) || isNaN(parseInt(weight))) {
|
||||
throw new Error('data table format wrong');
|
||||
}
|
||||
result.push({ id: parseInt(id), count: parseInt(count), weight: parseInt(weight) });
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user