抽卡:添加抽卡接口
This commit is contained in:
@@ -12,13 +12,13 @@ export interface DicGacha {
|
||||
// 消耗的招募券
|
||||
readonly cost: RewardInter[];
|
||||
// 概率
|
||||
readonly percent: { id: number, percent: number }[];
|
||||
readonly percent: { id: number, weight: number }[];
|
||||
}
|
||||
|
||||
const str = readJsonFile(FILENAME.DIC_GACHA);
|
||||
let arr = JSON.parse(str);
|
||||
|
||||
export const dicGacha = new Map<number, DicGacha>();
|
||||
export const dicGacha = new Map<number, DicGacha>(); // id => dic
|
||||
arr.forEach(o => {
|
||||
o.count = parseNumberList(o.count);
|
||||
o.free = parseFree(o.free);
|
||||
@@ -41,14 +41,14 @@ function parseFree(str: string) {
|
||||
}
|
||||
|
||||
function parsePercent(str: string) {
|
||||
let result = new Array<{ id: number, percent: number }>();
|
||||
let result = new Array<{ id: number, weight: number }>();
|
||||
if (!str) return result;
|
||||
let decodeArr = decodeArrayListStr(str);
|
||||
for (let [id, percent] of decodeArr) {
|
||||
if (isNaN(parseInt(id)) || isNaN(parseInt(percent))) {
|
||||
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), percent: parseInt(percent) });
|
||||
result.push({ id: parseInt(id), weight: parseInt(weight) });
|
||||
}
|
||||
return result
|
||||
}
|
||||
Reference in New Issue
Block a user