feat(pet): 添加学习力分配功能并优化相关逻辑

- 新增 PetEVdiy 接口用于自定义宠物学习力分配
- 限制单次学习力分配不超过510,单项不超过255
- 学习力池 EVPool 字段添加到 PlayerInfo 结构体
- 使用 github.com/samber/lo 简化数组求和操作
- 更新 fight_boss 逻辑以正确处理 BOSS 战斗后经验与学习力奖励发放
- 调整任务列表中部分
This commit is contained in:
2025-11-25 00:55:10 +08:00
parent 50232339d9
commit 28e0addda0
8 changed files with 73 additions and 27 deletions

View File

@@ -11,6 +11,7 @@ import (
"time"
"github.com/gogf/gf/v2/util/gconv"
"github.com/samber/lo"
)
const TableNamePet = "pet"
@@ -130,10 +131,7 @@ func (pet *PetInfo) AddEV(evadd []uint32) (bool, error) {
}
// 3. 计算增量后的总和检查是否超过510
totalTemp := uint32(0)
for _, v := range tempEV {
totalTemp += v
}
totalTemp := lo.Sum(tempEV[:])
// 4. 若总和超额按索引顺序0→5削减优先削减前面的字段
hasCut := false

View File

@@ -83,6 +83,7 @@ type PlayerInfo struct {
Texture uint32 `struc:"uint32" json:"texture"` // 固定0
Energy uint32 `struc:"uint32" default:"3000" json:"energy"` // 固定3000
Coins uint32 `struc:"uint32" json:"coins"` // 赛尔豆
EVPool uint32 `struc:"uint32" json:"ev_pool"` //累计学习力
FightBadge uint32 `struc:"uint32" json:"fight_badge"` // 固定0
MapID uint32 `struc:"uint32" default:"1" json:"map_id"` // 上线地图ID
Pos Pos `json:"pos"` // 坐标