2025-11-25 12:29:50 +08:00
|
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/common/socket/errorcode"
|
2026-03-04 02:24:25 +08:00
|
|
|
|
"blazing/logic/service/common"
|
2026-02-18 22:07:50 +08:00
|
|
|
|
"blazing/logic/service/fight"
|
2025-11-25 12:29:50 +08:00
|
|
|
|
"blazing/logic/service/player"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/samber/lo"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2025-12-24 19:03:11 +08:00
|
|
|
|
// PetEVDiy 自定义分配宠物努力值(EV)
|
|
|
|
|
|
// data: 包含宠物捕获时间和EV分配数据的输入信息
|
|
|
|
|
|
// c: 当前玩家对象
|
|
|
|
|
|
// 返回: 分配结果和错误码
|
2026-03-04 02:24:25 +08:00
|
|
|
|
func (h Controller) PetEVDiy(data *PetEV, c *player.Player) (result *fight.NullOutboundInfo, err errorcode.ErrorCode) {
|
2025-12-24 19:03:11 +08:00
|
|
|
|
_, currentPet, found := c.FindPet(data.CacthTime)
|
|
|
|
|
|
if !found {
|
2025-11-25 12:29:50 +08:00
|
|
|
|
return nil, errorcode.ErrorCodes.Err10401
|
|
|
|
|
|
}
|
2025-12-24 19:03:11 +08:00
|
|
|
|
// 分配超过510的数据
|
2025-11-25 12:29:50 +08:00
|
|
|
|
if lo.Sum(data.EVs[:]) > 510 {
|
|
|
|
|
|
return nil, errorcode.ErrorCodes.Err10401
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-24 19:03:11 +08:00
|
|
|
|
for i, evValue := range data.EVs {
|
|
|
|
|
|
// 分配超过255的数据
|
|
|
|
|
|
if evValue > 255 {
|
2025-11-25 12:29:50 +08:00
|
|
|
|
return nil, errorcode.ErrorCodes.Err10401
|
|
|
|
|
|
}
|
2025-12-24 19:03:11 +08:00
|
|
|
|
// 分配比之前点数少的
|
|
|
|
|
|
if evValue < currentPet.Ev[i] {
|
2025-11-25 12:29:50 +08:00
|
|
|
|
return nil, errorcode.ErrorCodes.Err10401
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
2025-12-24 19:03:11 +08:00
|
|
|
|
if lo.Sum(data.EVs[:]) < lo.Sum(currentPet.Ev[:]) {
|
2025-11-25 12:29:50 +08:00
|
|
|
|
return nil, errorcode.ErrorCodes.Err10401
|
|
|
|
|
|
}
|
|
|
|
|
|
|
2025-12-24 19:03:11 +08:00
|
|
|
|
usedEV := lo.Sum(data.EVs[:]) - lo.Sum(currentPet.Ev[:])
|
|
|
|
|
|
// 加的比池子还多
|
2026-02-12 04:28:20 +08:00
|
|
|
|
if int64(usedEV) > c.Info.EVPool {
|
2025-11-25 12:29:50 +08:00
|
|
|
|
return nil, errorcode.ErrorCodes.Err10401
|
|
|
|
|
|
}
|
2025-12-24 19:03:11 +08:00
|
|
|
|
currentPet.Ev = data.EVs
|
2026-03-23 22:00:05 +08:00
|
|
|
|
currentPet.CalculatePetPane(100)
|
2026-02-12 04:28:20 +08:00
|
|
|
|
c.Info.EVPool -= int64(usedEV)
|
2025-11-25 12:29:50 +08:00
|
|
|
|
|
2026-02-18 22:07:50 +08:00
|
|
|
|
// result = &pet.S2C_50001{}
|
|
|
|
|
|
// result.UseEV = -int32(usedEV)
|
2025-11-25 12:29:50 +08:00
|
|
|
|
return result, 0
|
|
|
|
|
|
}
|
2026-03-04 02:24:25 +08:00
|
|
|
|
|
|
|
|
|
|
type PetEV struct {
|
|
|
|
|
|
Head common.TomeeHeader `cmd:"50001" struc:"skip"`
|
|
|
|
|
|
CacthTime uint32 `description:"捕捉时间" codec:"cacthTime"`
|
|
|
|
|
|
EVs [6]uint32 `description:"属性" codec:"evs"`
|
|
|
|
|
|
}
|