```
refactor(controller): 重构控制器函数命名和代码注释 - 重命名 EGG 函数为 EggGamePlay,更新宠物生成逻辑 - 重命名 Leiyi 函数为 GetLeiyiTrainStatus - 重命名 Cacthpet 函数为 CatchPet,添加详细函数注释 - 为 ArenaSetOwner、ArenaFightOwner、ArenaGetInfo、ArenaUpfight、ArenaOwnerAcce 等擂台相关函数添加注释前缀 - 重命名 PETKing 函数为 PetKing - 重命名 FRESH_CHOICE_FIGHT_LEVEL 函数为 FreshChoiceFightLevel,添加详细参数说明 - 重命名 BuyMItem 函数为 BuyMultipleItems - 重命名 ITEM_S
This commit is contained in:
@@ -8,41 +8,44 @@ import (
|
||||
"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 {
|
||||
// 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 {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
//分配超过510的数据
|
||||
// 分配超过510的数据
|
||||
if lo.Sum(data.EVs[:]) > 510 {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
|
||||
for i, v := range data.EVs {
|
||||
|
||||
//分配超过255的数据
|
||||
if v > 255 {
|
||||
for i, evValue := range data.EVs {
|
||||
// 分配超过255的数据
|
||||
if evValue > 255 {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
//分配比之前点数少的
|
||||
if v < onpet.Ev[i] {
|
||||
// 分配比之前点数少的
|
||||
if evValue < currentPet.Ev[i] {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
}
|
||||
if lo.Sum(data.EVs[:]) < lo.Sum(onpet.Ev[:]) {
|
||||
if lo.Sum(data.EVs[:]) < lo.Sum(currentPet.Ev[:]) {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
|
||||
USEEV1 := lo.Sum(data.EVs[:]) - lo.Sum(onpet.Ev[:])
|
||||
//加的比池子还多
|
||||
if USEEV1 > c.Info.EVPool {
|
||||
usedEV := lo.Sum(data.EVs[:]) - lo.Sum(currentPet.Ev[:])
|
||||
// 加的比池子还多
|
||||
if usedEV > c.Info.EVPool {
|
||||
return nil, errorcode.ErrorCodes.Err10401
|
||||
}
|
||||
onpet.Ev = data.EVs
|
||||
onpet.CalculatePetPane(false)
|
||||
c.Info.EVPool -= USEEV1
|
||||
currentPet.Ev = data.EVs
|
||||
currentPet.CalculatePetPane(false)
|
||||
c.Info.EVPool -= usedEV
|
||||
|
||||
result = &pet.S2C_50001{}
|
||||
result.UseEV = USEEV1
|
||||
result.UseEV = usedEV
|
||||
return result, 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user