Files
bl/logic/controller/pet_ev.go
xinian d83cf365ac
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
更新说明
2026-04-05 23:13:06 +08:00

72 lines
1.8 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/socket/errorcode"
"blazing/logic/service/common"
"blazing/logic/service/fight"
"blazing/logic/service/player"
)
const (
petEVMaxTotal uint32 = 510
petEVMaxSingle uint32 = 255
)
// PetEVDiy 自定义分配宠物努力值EV
// data: 包含宠物捕获时间和EV分配数据的输入信息
// c: 当前玩家对象
// 返回: 分配结果和错误码
func (h Controller) PetEVDiy(data *PetEV, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
_, currentPet, found := c.FindPet(data.CacthTime)
if !found {
return nil, errorcode.ErrorCodes.Err10401
}
var targetTotal uint32
var currentTotal uint32
for i, evValue := range data.EVs {
currentEV := currentPet.Ev[i]
// 单项分配不能超过上限。
if evValue > petEVMaxSingle {
return nil, errorcode.ErrorCodes.Err10401
}
targetTotal += evValue
if targetTotal > petEVMaxTotal {
return nil, errorcode.ErrorCodes.Err10401
}
// 不允许回退已分配的努力值。
if evValue < currentEV {
return nil, errorcode.ErrorCodes.Err10401
}
currentTotal += currentEV
}
usedEV := targetTotal - currentTotal
if usedEV == 0 {
return result, 0
}
// 新增分配不能超过玩家累计学习力池。
if int64(usedEV) > c.Info.EVPool {
return nil, errorcode.ErrorCodes.Err10401
}
currentPet.Ev = data.EVs
currentPet.CalculatePetPane(100)
c.Info.EVPool -= int64(usedEV)
// result = &pet.S2C_50001{}
// result.UseEV = -int32(usedEV)
return result, 0
}
// PetEV 定义请求或响应数据结构。
type PetEV struct {
Head common.TomeeHeader `cmd:"50001" struc:"skip"`
CacthTime uint32 `description:"捕捉时间" codec:"cacthTime"`
EVs [6]uint32 `description:"属性" codec:"evs"`
}