All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
fix(fight): 移除调试打印语句并修复宠物类型验证逻辑 移除了PetKing函数中的调试打印语句,确保不再输出调试信息到控制台。 同时保持了宠物类型验证的核心逻辑不变。 fix(fight): 修正boss技能伤害计算公式 修改了NewSel323的OnSkill方法中伤害计算的公式, 将原来的百分比计算方式调整为正确的血量差值计算方式。 feat(space): 调整空间定时器间隔时间 将Space.Next方法的时间间隔从6-30秒大幅增加到10-30分钟, 以适应实际的游戏节奏需求。 refactor(config): 更新宠物基础配置模型结构 移除了PetBaseConfig中Hp字段的not null约束, 使配置更加灵活。 feat(config): 扩展地图坑位配置支持新功能 为map_pit配置添加了MustTask必做任务字段和DropItemIds掉落物ID列表, 同时为item和pet服务增加了列表查询操作的等值过滤支持。 ```
74 lines
1.5 KiB
Go
74 lines
1.5 KiB
Go
package service
|
|
|
|
import (
|
|
"blazing/common/data"
|
|
"blazing/common/utils"
|
|
"blazing/cool"
|
|
"blazing/modules/config/model"
|
|
|
|
"github.com/gogf/gf/v2/util/grand"
|
|
)
|
|
|
|
type ItemService struct {
|
|
*cool.Service
|
|
}
|
|
|
|
// 实现物品数量的获取
|
|
func (s *ItemService) GetItem(id uint32) *model.ItemGift {
|
|
var item *model.ItemGift
|
|
|
|
dbm_notenable(s.Model).Where("id", id).Scan(&item)
|
|
|
|
return item
|
|
}
|
|
func (s *ItemService) GetItemCount(id uint32) data.ItemInfo {
|
|
var item model.ItemGift
|
|
var res data.ItemInfo
|
|
dbm_notenable(s.Model).Where("id", id).Scan(&item)
|
|
|
|
if item.ItemID == 0 {
|
|
|
|
return res
|
|
}
|
|
res.ItemId = item.ItemID
|
|
res.ItemCnt = item.ItemMinCount
|
|
|
|
if item.ItemMaxCount != 0 {
|
|
res.ItemCnt = int64(grand.N(int(item.ItemMinCount), int(item.ItemMaxCount)))
|
|
|
|
}
|
|
return res
|
|
}
|
|
func (s *ItemService) GetEgg(count int64) []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 {
|
|
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})
|
|
}
|
|
|
|
}
|
|
|
|
return res
|
|
|
|
}
|
|
func NewItemService() *ItemService {
|
|
return &ItemService{
|
|
&cool.Service{
|
|
|
|
Model: model.NewItemGift(),
|
|
ListQueryOp: &cool.QueryOp{
|
|
FieldEQ: []string{"is_egg", "is_light"},
|
|
},
|
|
PageQueryOp: &cool.QueryOp{
|
|
KeyWordField: []string{"remark"},
|
|
FieldEQ: []string{"is_egg"},
|
|
},
|
|
},
|
|
}
|
|
}
|