Commit 47b879b6b11cae1b0a7a49feaf314d4aa55d17f6
1 parent
1dd66484
Exists in
master
and in
1 other branch
fix🐛:修正星星商店算法上的一个bug
Showing
1 changed file
with
4 additions
and
3 deletions
Show diff stats
service/cardholder/logic.go
| @@ -11,6 +11,7 @@ import ( | @@ -11,6 +11,7 @@ import ( | ||
| 11 | "apigame/util/utstring" | 11 | "apigame/util/utstring" |
| 12 | "apigame/util/zjson" | 12 | "apigame/util/zjson" |
| 13 | "github.com/samber/lo" | 13 | "github.com/samber/lo" |
| 14 | + "math" | ||
| 14 | "sort" | 15 | "sort" |
| 15 | ) | 16 | ) |
| 16 | 17 | ||
| @@ -317,7 +318,7 @@ func GetStarCardList(player *Player, config *confcardholder.ActivityConfig, need | @@ -317,7 +318,7 @@ func GetStarCardList(player *Player, config *confcardholder.ActivityConfig, need | ||
| 317 | } | 318 | } |
| 318 | star := confCard.Star | 319 | star := confCard.Star |
| 319 | need := needStar - starAmount | 320 | need := needStar - starAmount |
| 320 | - needCardCount := need / star | 321 | + needCardCount := int(math.Ceil(float64(need) / float64(star))) |
| 321 | if cardCount-1 < needCardCount { | 322 | if cardCount-1 < needCardCount { |
| 322 | needCardCount = cardCount - 1 | 323 | needCardCount = cardCount - 1 |
| 323 | } | 324 | } |
| @@ -344,12 +345,12 @@ func GetStarCardList(player *Player, config *confcardholder.ActivityConfig, need | @@ -344,12 +345,12 @@ func GetStarCardList(player *Player, config *confcardholder.ActivityConfig, need | ||
| 344 | } | 345 | } |
| 345 | star := confCard.Star + 1 | 346 | star := confCard.Star + 1 |
| 346 | need := needStar - starAmount | 347 | need := needStar - starAmount |
| 347 | - needCardCount := need / star | 348 | + needCardCount := int(math.Ceil(float64(need) / float64(star))) |
| 348 | if cardCount-1 < needCardCount { | 349 | if cardCount-1 < needCardCount { |
| 349 | needCardCount = cardCount - 1 | 350 | needCardCount = cardCount - 1 |
| 350 | } | 351 | } |
| 351 | cardList[cardId] = needCardCount | 352 | cardList[cardId] = needCardCount |
| 352 | - starAmount += needCardCount * (star + 1) | 353 | + starAmount += needCardCount * star |
| 353 | } | 354 | } |
| 354 | } | 355 | } |
| 355 | if starAmount >= needStar { | 356 | if starAmount >= needStar { |