From 47b879b6b11cae1b0a7a49feaf314d4aa55d17f6 Mon Sep 17 00:00:00 2001 From: 王家文 Date: Sun, 28 Apr 2024 16:24:42 +0800 Subject: [PATCH] fix🐛:修正星星商店算法上的一个bug --- service/cardholder/logic.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/service/cardholder/logic.go b/service/cardholder/logic.go index 72a3489..32b1064 100644 --- a/service/cardholder/logic.go +++ b/service/cardholder/logic.go @@ -11,6 +11,7 @@ import ( "apigame/util/utstring" "apigame/util/zjson" "github.com/samber/lo" + "math" "sort" ) @@ -317,7 +318,7 @@ func GetStarCardList(player *Player, config *confcardholder.ActivityConfig, need } star := confCard.Star need := needStar - starAmount - needCardCount := need / star + needCardCount := int(math.Ceil(float64(need) / float64(star))) if cardCount-1 < needCardCount { needCardCount = cardCount - 1 } @@ -344,12 +345,12 @@ func GetStarCardList(player *Player, config *confcardholder.ActivityConfig, need } star := confCard.Star + 1 need := needStar - starAmount - needCardCount := need / star + needCardCount := int(math.Ceil(float64(need) / float64(star))) if cardCount-1 < needCardCount { needCardCount = cardCount - 1 } cardList[cardId] = needCardCount - starAmount += needCardCount * (star + 1) + starAmount += needCardCount * star } } if starAmount >= needStar { -- libgit2 0.21.0