添加藏宝图按体力掉落

This commit is contained in:
luying
2020-11-24 15:44:10 +08:00
parent f362c5505f
commit 991d193eab
5 changed files with 170 additions and 19 deletions
+10
View File
@@ -98,6 +98,12 @@ const moment = require('moment');
result = { type: parseInt(type), param: parseInt(param), cnt: parseInt(cnt) };
break;
}
case 'possibility': {
let [id, weight] = arr;
if(isNaN(id) || isNaN(weight)) throw new Error('data table format wrong');
result = { id: parseInt(id), weight: parseInt(weight) };
break;
}
}
return result;
};
@@ -163,6 +169,10 @@ export function decodeIdCntArrayStr(str: string, multi: number) {
return ce;
}
export function getRandomByLen(arr: Array<any>) {
let len = arr.length;
return arr[Math.floor(Math.random() * len)]
}
export function getRandomWithWeight(randomList: any) {
let len = randomList.reduce((pre, cur) => {