修改部分代码

This commit is contained in:
1
2025-08-31 06:53:42 +00:00
parent 9ef6b7b8bc
commit ab7df82bae
10 changed files with 115 additions and 33 deletions

View File

@@ -4,6 +4,7 @@ import (
"blazing/common/data/socket"
"blazing/common/socket/errorcode"
"blazing/logic/service/pet"
"blazing/modules/blazing/model"
"blazing/modules/blazing/service"
)
@@ -25,6 +26,33 @@ func (h *Controller) PetRelease(
c *socket.Player) (
result *pet.PetReleaseOutboundInfo,
err errorcode.ErrorCode) { //这个时候player应该是空的
//放入背包=数据库置1+添加到背包+pet release发包 仓库=数据库置0+移除背包 设置首发等于取到首发精灵后重新排序
//这里只修改,因为添加和移除背包在宠物获取时已经做了
result = &pet.PetReleaseOutboundInfo{}
result.PetInfo = make([]model.PetInfo, 0)
t := service.NewUserService(c.Info.UserID).PetM(int(data.CatchTime), int(data.Flag))
switch data.Flag {
case 0:
//todo 仓库
removeIndex := -1
for i, v := range c.Info.PetList {
if v.CatchTime == uint32(data.CatchTime) {
removeIndex = i
break // 只移除第一个匹配值,若需移除所有,可省略 break 继续循环
}
return nil, 0
}
if removeIndex != -1 {
c.Info.PetList = append(c.Info.PetList[:removeIndex], c.Info.PetList[removeIndex+1:]...)
}
result.FirstPetTime = c.Info.PetList[0].CatchTime //设置首发
case 1:
//todo 背包
PetAdd(c, t)
result.PetInfo = append(result.PetInfo, t)
}
//service.NewUserService(c.Info.UserID).PetAdd( *r)
return result, 0
}