From 70386fbbe869a50abf40449d7d65bd5aae25748c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=98=94=E5=BF=B5?= <1@72wo.cn> Date: Fri, 12 Sep 2025 19:21:39 +0800 Subject: [PATCH] =?UTF-8?q?feat(pet):=20=E5=AE=9E=E7=8E=B0=E7=B2=BE?= =?UTF-8?q?=E7=81=B5=E9=A6=96=E5=8F=91=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - 新增 PetFirst 方法用于设置精灵为首发 - 添加 PetDefaultInboundInfo 和 PetDefaultOutboundInfo 结构体用于处理精灵首发请求和响应 - 实现了将指定精灵移动到宠物列表首位的逻辑 - 返回结果中包含首发设置成功或失败的标志 --- logic/controller/pet.go | 21 +++++++++++++++++++++ logic/service/pet/pet.go | 13 +++++++++++++ 2 files changed, 34 insertions(+) diff --git a/logic/controller/pet.go b/logic/controller/pet.go index 78c1aa1f..591e6079 100644 --- a/logic/controller/pet.go +++ b/logic/controller/pet.go @@ -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 + +} diff --git a/logic/service/pet/pet.go b/logic/service/pet/pet.go index 3a18f9e3..96566a5b 100644 --- a/logic/service/pet/pet.go +++ b/logic/service/pet/pet.go @@ -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"` +}