refactor: 优化蛋卡抽奖逻辑
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
This commit is contained in:
@@ -24,10 +24,8 @@ func init() {
|
||||
count = 10
|
||||
}
|
||||
var rets []string
|
||||
for _, v := range service.NewItemService().GetEgg(int64(count)) {
|
||||
if v.ItemId == 0 {
|
||||
continue
|
||||
}
|
||||
for _, v := range service.NewItemService().GetEgg(count) {
|
||||
|
||||
var buf strings.Builder
|
||||
buf.WriteString(xmlres.ItemsMAP[int(v.ItemId)].Name)
|
||||
buf.WriteString(": " + gconv.String(v.ItemCnt))
|
||||
|
||||
@@ -2,7 +2,6 @@ package service
|
||||
|
||||
import (
|
||||
"blazing/common/data"
|
||||
"blazing/common/utils"
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
@@ -39,13 +38,13 @@ func (s *ItemService) GetItemCount(id uint32) data.ItemInfo {
|
||||
}
|
||||
return res
|
||||
}
|
||||
func (s *ItemService) GetEgg(count int64) []data.ItemInfo {
|
||||
func (s *ItemService) GetEgg(count int) []data.ItemInfo {
|
||||
var item []model.ItemGift
|
||||
dbm_notenable(s.Model).Where("is_egg", 1).Scan(&item)
|
||||
|
||||
rr := utils.RandomSlice(item, int(count))
|
||||
var res = make([]data.ItemInfo, len(rr))
|
||||
for _, v := range rr {
|
||||
var res []data.ItemInfo
|
||||
for i := 0; i < count; i++ {
|
||||
v := item[grand.Intn(len(item))]
|
||||
if v.ItemMaxCount != 0 {
|
||||
v.ItemMinCount = int64(grand.N(int(v.ItemMinCount), int(v.ItemMaxCount)))
|
||||
res = append(res, data.ItemInfo{ItemId: v.ItemID, ItemCnt: v.ItemMinCount})
|
||||
|
||||
Reference in New Issue
Block a user