From d1d01cd79c0a0064b85102c40682cc1ff07211e3 Mon Sep 17 00:00:00 2001 From: luying Date: Tue, 15 Nov 2022 10:58:39 +0800 Subject: [PATCH] =?UTF-8?q?=E2=9C=A8=20feat(=E6=8A=BD=E5=8D=A1):=20?= =?UTF-8?q?=E4=B8=BA=E4=BA=86ur=E6=AD=A6=E5=B0=86=E6=A6=82=E7=8E=87?= =?UTF-8?q?=EF=BC=8C=E4=BF=AE=E6=94=B9=E6=8A=BD=E5=8D=A1=E5=8D=A1=E6=B1=A0?= =?UTF-8?q?=E7=B2=BE=E5=BA=A6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- shared/pubUtils/dictionary/DicGacha.ts | 2 +- shared/pubUtils/util.ts | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) 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 };