2025-11-25 12:29:50 +08:00
|
|
|
|
package controller
|
|
|
|
|
|
|
|
|
|
|
|
import (
|
|
|
|
|
|
"blazing/common/socket/errorcode"
|
|
|
|
|
|
"blazing/logic/service/pet"
|
|
|
|
|
|
"blazing/logic/service/player"
|
|
|
|
|
|
|
|
|
|
|
|
"github.com/samber/lo"
|
|
|
|
|
|
)
|
|
|
|
|
|
|
2025-12-24 19:03:11 +08:00
|
|
|
|
// PetEVDiy 自定义分配宠物努力值(EV)
|
|
|
|
|
|
// data: 包含宠物捕获时间和EV分配数据的输入信息
|
|
|
|
|
|
// c: 当前玩家对象
|
|
|
|
|
|
// 返回: 分配结果和错误码
|
|
|
|
|
|
func (h Controller) PetEVDiy(data *pet.PetEV, c *player.Player) (result *pet.S2C_50001, err errorcode.ErrorCode) {
|
|
|
|
|
|
_, 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[:])
|
|
|
|
|
|
// 加的比池子还多
|
|
|
|
|
|
if 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
|
|
|
|
|
|
currentPet.CalculatePetPane(false)
|
|
|
|
|
|
c.Info.EVPool -= usedEV
|
2025-11-25 12:29:50 +08:00
|
|
|
|
|
|
|
|
|
|
result = &pet.S2C_50001{}
|
2025-12-24 19:03:11 +08:00
|
|
|
|
result.UseEV = usedEV
|
2025-11-25 12:29:50 +08:00
|
|
|
|
return result, 0
|
|
|
|
|
|
}
|