feat(pet): 实现精灵首发功能
- 新增 PetFirst 方法用于设置精灵为首发 - 添加 PetDefaultInboundInfo 和 PetDefaultOutboundInfo 结构体用于处理精灵首发请求和响应 - 实现了将指定精灵移动到宠物列表首位的逻辑 - 返回结果中包含首发设置成功或失败的标志
This commit is contained in:
@@ -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
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user