feat(pet): 实现精灵首发功能

- 新增 PetFirst 方法用于设置精灵为首发
- 添加 PetDefaultInboundInfo 和 PetDefaultOutboundInfo 结构体用于处理精灵首发请求和响应
- 实现了将指定精灵移动到宠物列表首位的逻辑
- 返回结果中包含首发设置成功或失败的标志
This commit is contained in:
2025-09-12 19:21:39 +08:00
parent 4ab4f04a97
commit 70386fbbe8
2 changed files with 34 additions and 0 deletions

View File

@@ -143,3 +143,24 @@ func (h *Controller) PetOneCure(
return result, 0
}
// 精灵首发
func (h *Controller) PetFirst(
data *pet.PetDefaultInboundInfo, c *service.Player) (result *pet.PetDefaultOutboundInfo, err errorcode.ErrorCode) { //这个时候player应该是空的
result = &pet.PetDefaultOutboundInfo{}
var ttt []model.PetInfo
for index, pi := range c.Info.PetList {
if pi.CatchTime == data.CatchTime {
ttt = append(ttt, pi)
ttt = append(ttt, c.Info.PetList[:index]...)
ttt = append(ttt, c.Info.PetList[index+1:]...)
result.IsDefault = 1
break
}
}
c.Info.PetList = ttt
return result, 0
}

View File

@@ -65,3 +65,16 @@ type PetOneCureInboundInfo struct {
type PetOneCureOutboundInfo struct {
CatchTime uint32 `json:"catchTime" fieldDescription:"精灵捕捉时间" uint:"true"`
}
// PetDefaultInboundInfo 对应Java的PetDefaultInboundInfo类
// 实现了InboundMessage接口
type PetDefaultInboundInfo struct {
Head service.TomeeHeader `cmd:"2308" struc:"[0]pad"`
CatchTime uint32 `json:"catchTime" fieldDescription:"精灵捕捉时间" uint:"true" autoCodec:"true" inboundMessageType:"Pet_Default"`
}
// PetDefaultOutboundInfo 对应Java的PetDefaultOutboundInfo类
// 实现了OutboundMessage接口
type PetDefaultOutboundInfo struct {
IsDefault uint32 `json:"isDefault" fieldDescription:"0: 首发设置失败1: 首发设置成功" uint:"true" autoCodec:"true" outboundMessageType:"Pet_Default"`
}