feat(pet): 宠物治疗逻辑重构并新增治愈方法

将原有的宠物治疗逻辑提取为 PetInfo.Cure() 方法,统一处理血量和技能PP恢复。
同时优化经验分配逻辑,确保升级后正确扣除经验池并处理满级情况。

```
This commit is contained in:
2025-10-13 19:46:19 +08:00
parent 79213c67d6
commit 5e53b9caaa
5 changed files with 45 additions and 30 deletions

View File

@@ -2,10 +2,8 @@ package admin
import (
"blazing/cool"
"blazing/modules/blazing/model"
"blazing/modules/blazing/service"
"context"
"fmt"
"github.com/gogf/gf/v2/frame/g"
)
@@ -37,14 +35,14 @@ func init() {
}
func (c *PetBagController) GetSession(ctx context.Context, req *PetGetReq) (res *cool.BaseRes, err error) {
fmt.Println(req)
var (
admin = cool.GetAdmin(ctx)
//r = g.RequestFromCtx(ctx)
)
t := model.GenPetInfo(
req.PetTypeId, req.IndividualValue, req.NatureId, req.AbilityTypeEnum, req.IsShiny, req.Level)
service.NewUserService(uint32(admin.UserId)).PetAdd(*t)
// fmt.Println(req)
// var (
// admin = cool.GetAdmin(ctx)
// //r = g.RequestFromCtx(ctx)
// )
// t := model.GenPetInfo(
// req.PetTypeId, req.IndividualValue, req.NatureId, req.AbilityTypeEnum, req.IsShiny, req.Level)
// service.NewUserService(uint32(admin.UserId)).PetAdd(*t)
return
}

View File

@@ -1,6 +1,7 @@
package model
import (
"blazing/common/data/xmlres"
"blazing/cool"
)
@@ -121,6 +122,18 @@ type PetInfo struct {
// AbilityType uint32 `struc:"skip"` //特性
}
func (pet *PetInfo) Cure() {
pet.Hp = pet.MaxHp
for i := 0; i < 4; i++ {
maxPP, ok := xmlres.SkillMap[int(pet.SkillList[i].ID)]
// 恢复至最大PP值从配置表获取
if pet.SkillList[i].ID != 0 && ok {
pet.SkillList[i].PP = uint32(maxPP.MaxPP)
}
}
}
// PetEffectInfo 精灵特性信息结构
// <!-- NewSeIdx: 精灵特效索引 (默认0: 无效) -->
// <!-- Type: 0 - 仅单人战斗; 1 - 仅组队战斗; 2 - both; (默认0: 仅单人) -->