49 lines
1.1 KiB
Go
49 lines
1.1 KiB
Go
package controller
|
|
|
|
import (
|
|
"blazing/common/socket/errorcode"
|
|
"blazing/logic/service/pet"
|
|
"blazing/logic/service/player"
|
|
|
|
"github.com/samber/lo"
|
|
)
|
|
|
|
func (h Controller) PetEVdiy(data *pet.PetEV, c *player.Player) (result *pet.S2C_50001, err errorcode.ErrorCode) {
|
|
_, onpet, ok := c.FindPet(data.CacthTime)
|
|
if !ok {
|
|
return nil, errorcode.ErrorCodes.Err10401
|
|
}
|
|
//分配超过510的数据
|
|
if lo.Sum(data.EVs[:]) > 510 {
|
|
return nil, errorcode.ErrorCodes.Err10401
|
|
}
|
|
|
|
for i, v := range data.EVs {
|
|
|
|
//分配超过255的数据
|
|
if v > 255 {
|
|
return nil, errorcode.ErrorCodes.Err10401
|
|
}
|
|
//分配比之前点数少的
|
|
if v < onpet.Ev[i] {
|
|
return nil, errorcode.ErrorCodes.Err10401
|
|
}
|
|
}
|
|
if lo.Sum(data.EVs[:]) < lo.Sum(onpet.Ev[:]) {
|
|
return nil, errorcode.ErrorCodes.Err10401
|
|
}
|
|
|
|
USEEV1 := lo.Sum(data.EVs[:]) - lo.Sum(onpet.Ev[:])
|
|
//加的比池子还多
|
|
if USEEV1 > c.Info.EVPool {
|
|
return nil, errorcode.ErrorCodes.Err10401
|
|
}
|
|
onpet.Ev = data.EVs
|
|
onpet.CalculatePetPane(false)
|
|
c.Info.EVPool -= USEEV1
|
|
|
|
result = &pet.S2C_50001{}
|
|
result.UseEV = USEEV1
|
|
return result, 0
|
|
}
|