Files
bl/logic/controller/pet_elo.go
昔念 10af34fdad
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
```
refactor(controller): 移除独立的服务模块并将结构体定义内联到控制器中

移除了 egg、leiyi、pet 和 systemtime 独立服务包中的结构体定义,
将所有 C2S 和 S2C 结构体直接定义在相应的控制器文件中,同时更新了
导入路径和服务调用方式,统一使用 common.TomeeHeader 并优化了代码组织结构。

BREAKING CHANGE: 结构体定义从独立的服务包移动到控制器文件内部
2026-03-04 02:24:25 +08:00

62 lines
2.0 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package controller
import (
"blazing/common/data/xmlres"
"blazing/common/socket/errorcode"
"blazing/logic/service/common"
"blazing/logic/service/fight"
"blazing/logic/service/fight/info"
"blazing/logic/service/player"
"github.com/jinzhu/copier"
)
func (h Controller) PetELV(data *C2S_PET_EVOLVTION, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
_, currentPet, found := c.FindPet(data.CacthTime)
if !found {
return nil, errorcode.ErrorCodes.Err10401
}
flag := xmlres.PetMAP[int(currentPet.ID)].EvolvFlag
if flag == 0 {
return nil, errorcode.ErrorCodes.ErrPokemonNotEvolveReady
}
if xmlres.PetMAP[int(currentPet.ID)].EvolvingLv > int(currentPet.Level) {
return nil, errorcode.ErrorCodes.ErrPokemonNotEvolveReady
}
evinfo := xmlres.EVOLVMAP[flag].Branches[data.Index-1]
if c.Service.Item.CheakItem(uint32(evinfo.EvolvItem)) < int64(evinfo.EvolvItemCount) {
return nil, errorcode.ErrorCodes.ErrInsufficientItemsMulti
}
if evinfo.EvolvItem != 0 {
c.Service.Item.UPDATE(uint32(evinfo.EvolvItem), -evinfo.EvolvItemCount)
}
currentPet.ID = uint32(xmlres.EVOLVMAP[flag].Branches[data.Index-1].MonTo)
currentPet.Update(true)
currentPet.CalculatePetPane(false)
currentPet.Update(true)
updateOutbound := &info.PetUpdateOutboundInfo{}
var petUpdateInfo info.UpdatePropInfo
copier.Copy(&petUpdateInfo, currentPet)
updateOutbound.Data = append(updateOutbound.Data, petUpdateInfo)
c.SendPackCmd(2508, updateOutbound) //准备包由各自发,因为协议不一样
return nil, -1
}
// C2S_PET_EVOLVTION 精灵进化相关的客户端到服务端的消息结构
type C2S_PET_EVOLVTION struct {
Head common.TomeeHeader `cmd:"2314" struc:"skip"`
CacthTime uint32 // 精灵的捕捉时间
Index uint32 // 进化的分支索引。0代表没选择进化1就是第一种进化形态2就是其他分支进化形态
// 如果没有分支进化只有一种进化形态Index只能为1
// 后端直接判断进化条件的材料,执行进化并扣除材料
}