```
feat: 添加ItemInfo结构体并重构抽蛋和任务系统 - 在common/data/color.go中添加ItemInfo结构体用于表示发放物品的信息 - 在common/utils/tomap.go中添加RandomSlice泛型函数用于从切片中随机选取元素 - 重构action_egg.go中的EggGamePlay功能,实现抽蛋逻辑和物品发放 - 更新fight_boss.go中使用新的ItemInfo结构体替换旧的model.ItemInfo - 修改user_talk.go中获取物品数量的逻辑 - 更新user_task.go中任务完成逻辑使用新的ItemInfo结构体 - 在egg.go中更新抽蛋结果结构体使用ItemInfo - 更新战斗奖励结构体使用ItemInfo - 在player.go中添加学习力道具处理逻辑 - 重构任务系统使用新的ItemInfo结构体 - 移除旧的model.ItemInfo定义 - 更新宠物奖励配置模型添加成长值等字段 - 实现GetEgg方法用于获取扭蛋奖励 - 修复宠物融合材料服务中的道具验证逻辑 ```
This commit is contained in:
@@ -16,3 +16,10 @@ func NewPetRewardService() *PetRewardService {
|
||||
},
|
||||
}
|
||||
}
|
||||
func (s *PetRewardService) GetEgg() model.PetReward {
|
||||
var item model.PetReward
|
||||
cool.DBM(s.Model).Where("is_egg", 1).Where("is_enabled", 1).OrderRandom().Limit(1).Scan(&item)
|
||||
|
||||
return item
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/common/data"
|
||||
"blazing/common/utils"
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
|
||||
@@ -14,24 +16,50 @@ type ItemService struct {
|
||||
|
||||
//实现物品数量的获取
|
||||
|
||||
func (s *ItemService) GetItemCount(id uint32) uint32 {
|
||||
func (s *ItemService) GetItemCount(id uint32) data.ItemInfo {
|
||||
var item model.ItemGift
|
||||
cool.DBM(s.Model).Where("id", id).Cache(gdb.CacheOption{
|
||||
var res data.ItemInfo
|
||||
cool.DBM(s.Model).Where("id", id).Where("is_enabled", 1).Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&item)
|
||||
|
||||
if item.ItemID == 0 {
|
||||
return 0
|
||||
|
||||
return res
|
||||
}
|
||||
res.ItemId = item.ItemID
|
||||
res.ItemCnt = item.ItemMinCount
|
||||
|
||||
if item.ItemMaxCount != 0 {
|
||||
return uint32(grand.N(int(item.ItemMinCount), int(item.ItemMaxCount)))
|
||||
}
|
||||
return item.ItemMinCount
|
||||
}
|
||||
res.ItemCnt = uint32(grand.N(int(item.ItemMinCount), int(item.ItemMaxCount)))
|
||||
|
||||
}
|
||||
return res
|
||||
}
|
||||
func (s *ItemService) GetEgg(count uint32) []data.ItemInfo {
|
||||
var item []model.ItemGift
|
||||
cool.DBM(s.Model).Where("is_egg", 1).Where("is_enabled", 1).Cache(gdb.CacheOption{
|
||||
// Duration: time.Hour,
|
||||
|
||||
Force: false,
|
||||
}).Scan(&item)
|
||||
|
||||
rr := utils.RandomSlice(item, int(count))
|
||||
var res = make([]data.ItemInfo, len(rr))
|
||||
for _, v := range rr {
|
||||
if v.ItemMaxCount != 0 {
|
||||
v.ItemMinCount = uint32(grand.N(int(v.ItemMinCount), int(v.ItemMaxCount)))
|
||||
|
||||
}
|
||||
res = append(res, data.ItemInfo{ItemId: v.ItemID, ItemCnt: v.ItemMinCount})
|
||||
|
||||
}
|
||||
|
||||
return res
|
||||
|
||||
}
|
||||
func NewItemService() *ItemService {
|
||||
return &ItemService{
|
||||
&cool.Service{
|
||||
|
||||
@@ -18,8 +18,6 @@ type PetFusionMaterialService struct {
|
||||
*cool.Service // 嵌入通用Service(继承基础CRUD方法)
|
||||
}
|
||||
|
||||
|
||||
|
||||
// NewPetFusionMaterialService 创建PetFusionMaterialService实例
|
||||
func NewPetFusionMaterialService() *PetFusionMaterialService {
|
||||
return &PetFusionMaterialService{
|
||||
@@ -39,10 +37,10 @@ func (s *PetFusionMaterialService) Data(Material1 [4]uint32) uint32 {
|
||||
fusions := service.DictInfoServiceS.GetData("fusion")
|
||||
|
||||
for _, v := range Material1 {
|
||||
if v < 10000 {
|
||||
//使用过小的道具
|
||||
return 0
|
||||
}
|
||||
// if v < 10000 {
|
||||
// //使用过小的道具
|
||||
// return 0
|
||||
// }
|
||||
_, ok := fusions[v]
|
||||
if !ok {
|
||||
//todo使用了非法材料
|
||||
|
||||
@@ -3,6 +3,9 @@ package service
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type ShinyService struct {
|
||||
@@ -13,6 +16,13 @@ func NewShinyService() *ShinyService {
|
||||
return &ShinyService{
|
||||
&cool.Service{
|
||||
Model: model.NewColorfulSkin(),
|
||||
InsertParam: func(ctx context.Context) g.MapStrAny {
|
||||
admin := cool.GetAdmin(ctx)
|
||||
userId := admin.UserId
|
||||
return g.MapStrAny{
|
||||
"author": userId,
|
||||
}
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user