feat: 添加批量检查物品数量的方法并优化宠物融合逻辑
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
在物品服务中添加CheakItemM方法用于批量检查物品数量 修改宠物融合逻辑使用新方法进行物品检查
This commit is contained in:
@@ -47,12 +47,14 @@ func (h Controller) PetFusion(data *pet.C2S_PetFusion, c *player.Player) (result
|
||||
if Auxpetinfo.Nature == Mcatchpetinfo.Nature {
|
||||
natureId = int32(Auxpetinfo.Nature)
|
||||
}
|
||||
for _, v := range data.Item1 {
|
||||
if c.Service.Item.CheakItem(v) == 0 {
|
||||
|
||||
for _, v := range c.Service.Item.CheakItemM(data.Item1[:]...) {
|
||||
|
||||
if v.ItemCnt <= 0 {
|
||||
return result, errorcode.ErrorCodes.ErrInsufficientItems
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
resid := int(service.NewPetFusionService().Data(Mcatchpetinfo.ID, Auxpetinfo.ID, Mcatchpetinfo.Level+Auxpetinfo.Level))
|
||||
effect := int(service.NewPetFusionMaterialService().Data(data.Item1))
|
||||
|
||||
|
||||
@@ -67,6 +67,13 @@ func (s *ItemService) CheakItem(id uint32) int64 {
|
||||
m.Where("item_id", id).Scan(&ttt)
|
||||
return ttt.ItemCnt
|
||||
}
|
||||
func (s *ItemService) CheakItemM(id ...uint32) []model.Item {
|
||||
var ttt []model.Item
|
||||
m := s.dbm(s.Model)
|
||||
|
||||
m.WhereIn("item_id", id).Scan(&ttt)
|
||||
return ttt
|
||||
}
|
||||
|
||||
// /添加进来的物品一定是保证存在的
|
||||
type ItemService struct {
|
||||
|
||||
Reference in New Issue
Block a user