diff --git a/shared/pubUtils/dictionary/DicGacha.ts b/shared/pubUtils/dictionary/DicGacha.ts index 397902939..ca5b7c1fe 100644 --- a/shared/pubUtils/dictionary/DicGacha.ts +++ b/shared/pubUtils/dictionary/DicGacha.ts @@ -67,7 +67,7 @@ function parsePercent(str: string) { if (isNaN(parseInt(planId)) || isNaN(parseInt(weight))) { throw new Error('data table format wrong'); } - result.push({ planId: parseInt(planId), weight: parseInt(weight) }); + result.push({ planId: parseInt(planId), weight: Math.floor(parseFloat(weight) * 10) }); } return result } diff --git a/shared/pubUtils/util.ts b/shared/pubUtils/util.ts index ad2ceb517..8a79b586f 100644 --- a/shared/pubUtils/util.ts +++ b/shared/pubUtils/util.ts @@ -206,7 +206,7 @@ export function getRandSingleIndex(len: number) { */ export function getRandEelmWithWeight(randomList: T[]): { dic: T, index: number } { let len = randomList.reduce((pre, cur) => { - return pre + cur.weight || 1; + return pre + (cur.weight||0); }, 0); let index = Math.floor(Math.random() * len); let result = { dic: null, index: -1 };