2025-12-16 02:50:10 +08:00
|
|
|
|
package controller
|
2026-01-03 01:35:32 +08:00
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/common/data/xmlres"
|
|
|
|
|
|
"blazing/common/socket/errorcode"
|
2026-03-04 02:24:25 +08:00
|
|
|
|
"blazing/logic/service/common"
|
2026-01-03 01:35:32 +08:00
|
|
|
|
"blazing/logic/service/fight"
|
|
|
|
|
|
"blazing/logic/service/fight/info"
|
2026-03-04 02:24:25 +08:00
|
|
|
|
|
2026-01-03 01:35:32 +08:00
|
|
|
|
"blazing/logic/service/player"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/jinzhu/copier"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2026-04-05 23:13:06 +08:00
|
|
|
|
// PetELV 处理控制器请求。
|
2026-03-04 02:24:25 +08:00
|
|
|
|
func (h Controller) PetELV(data *C2S_PET_EVOLVTION, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2026-01-03 01:35:32 +08:00
|
|
|
|
_, currentPet, found := c.FindPet(data.CacthTime)
|
|
|
|
|
|
if !found {
|
|
|
|
|
|
return nil, errorcode.ErrorCodes.Err10401
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-31 08:19:53 +08:00
|
|
|
|
petCfg, ok := xmlres.PetMAP[int(currentPet.ID)]
|
|
|
|
|
|
if !ok || petCfg.EvolvFlag == 0 {
|
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotEvolveReady
|
|
|
|
|
|
}
|
|
|
|
|
|
if petCfg.EvolvingLv > int(currentPet.Level) {
|
2026-01-03 01:35:32 +08:00
|
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotEvolveReady
|
|
|
|
|
|
}
|
2026-03-31 08:19:53 +08:00
|
|
|
|
|
|
|
|
|
|
evolveCfg, ok := xmlres.EVOLVMAP[petCfg.EvolvFlag]
|
|
|
|
|
|
if !ok || data.Index == 0 || int(data.Index) > len(evolveCfg.Branches) {
|
2026-03-04 02:24:25 +08:00
|
|
|
|
return nil, errorcode.ErrorCodes.ErrPokemonNotEvolveReady
|
2026-03-01 11:25:30 +08:00
|
|
|
|
}
|
2026-01-03 01:35:32 +08:00
|
|
|
|
|
2026-03-31 08:19:53 +08:00
|
|
|
|
branch := evolveCfg.Branches[data.Index-1]
|
|
|
|
|
|
if branch.EvolvItem != 0 && c.Service.Item.CheakItem(uint32(branch.EvolvItem)) < int64(branch.EvolvItemCount) {
|
2026-01-03 01:35:32 +08:00
|
|
|
|
return nil, errorcode.ErrorCodes.ErrInsufficientItemsMulti
|
|
|
|
|
|
}
|
2026-03-31 08:19:53 +08:00
|
|
|
|
if branch.EvolvItem != 0 {
|
2026-04-14 13:06:28 +08:00
|
|
|
|
if err := c.Service.Item.UPDATE(uint32(branch.EvolvItem), -branch.EvolvItemCount); err != nil {
|
|
|
|
|
|
return nil, errorcode.ErrorCodes.ErrInsufficientItemsMulti
|
|
|
|
|
|
}
|
2026-01-03 01:35:32 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
2026-03-31 08:19:53 +08:00
|
|
|
|
currentPet.ID = uint32(branch.MonTo)
|
2026-01-03 01:35:32 +08:00
|
|
|
|
currentPet.Update(true)
|
2026-03-23 22:00:05 +08:00
|
|
|
|
currentPet.CalculatePetPane(100)
|
2026-01-03 01:35:32 +08:00
|
|
|
|
|
|
|
|
|
|
updateOutbound := &info.PetUpdateOutboundInfo{}
|
|
|
|
|
|
var petUpdateInfo info.UpdatePropInfo
|
|
|
|
|
|
copier.Copy(&petUpdateInfo, currentPet)
|
|
|
|
|
|
updateOutbound.Data = append(updateOutbound.Data, petUpdateInfo)
|
|
|
|
|
|
c.SendPackCmd(2508, updateOutbound) //准备包由各自发,因为协议不一样
|
|
|
|
|
|
return nil, -1
|
|
|
|
|
|
}
|
2026-03-04 02:24:25 +08:00
|
|
|
|
|
|
|
|
|
|
// C2S_PET_EVOLVTION 精灵进化相关的客户端到服务端的消息结构
|
|
|
|
|
|
type C2S_PET_EVOLVTION struct {
|
|
|
|
|
|
Head common.TomeeHeader `cmd:"2314" struc:"skip"`
|
|
|
|
|
|
CacthTime uint32 // 精灵的捕捉时间
|
|
|
|
|
|
Index uint32 // 进化的分支索引。0代表没选择进化,1就是第一种进化形态,2就是其他分支进化形态
|
|
|
|
|
|
// 如果没有分支进化,只有一种进化形态,Index只能为1
|
|
|
|
|
|
// 后端直接判断进化条件的材料,执行进化并扣除材料
|
|
|
|
|
|
}
|