```
feat(pet): 添加学习力分配功能并优化相关逻辑 - 新增 PetEVdiy 接口用于自定义宠物学习力分配 - 限制单次学习力分配不超过510,单项不超过255 - 学习力池 EVPool 字段添加到 PlayerInfo 结构体 - 使用 github.com/samber/lo 简化数组求和操作 - 更新 fight_boss 逻辑以正确处理 BOSS 战斗后经验与学习力奖励发放 - 调整任务列表中部分
This commit is contained in:
@@ -11,6 +11,7 @@ import (
|
||||
"blazing/modules/blazing/model"
|
||||
|
||||
"github.com/jinzhu/copier"
|
||||
"github.com/samber/lo"
|
||||
)
|
||||
|
||||
// 获取精灵信息
|
||||
@@ -80,7 +81,7 @@ func (h *Controller) PET_ROWEI(
|
||||
_, _, ok := c.FindPet(data.CatchTime)
|
||||
|
||||
//如果背包没找到,再放入背包
|
||||
if !ok && t.CatchTime != 0 {
|
||||
if !ok && t.CatchTime != 0 && xmlres.PetMAP[int(data.ID)].FreeForbidden == 0 {
|
||||
t.Free = 1
|
||||
}
|
||||
|
||||
@@ -252,3 +253,37 @@ func (h Controller) PetBargeList(data *pet.PetBargeListInboundInfo, c *player.Pl
|
||||
PetBargeList: make([]pet.PetBargeListInfo, 0),
|
||||
}, 0
|
||||
}
|
||||
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 _, v := range data.EVs {
|
||||
|
||||
//分配超过255的数据
|
||||
if v > 255 {
|
||||
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
|
||||
c.Info.EVPool -= USEEV1
|
||||
|
||||
result = &pet.S2C_50001{}
|
||||
result.UseEV = USEEV1
|
||||
return result, 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user