feat(pet): 宠物治疗逻辑重构并新增治愈方法 将原有的宠物治疗逻辑提取为 PetInfo.Cure() 方法,统一处理血量和技能PP恢复。 同时优化经验分配逻辑,确保升级后正确扣除经验池并处理满级情况。 ```
49 lines
2.2 KiB
Go
49 lines
2.2 KiB
Go
package admin
|
||
|
||
import (
|
||
"blazing/cool"
|
||
"blazing/modules/blazing/service"
|
||
"context"
|
||
|
||
"github.com/gogf/gf/v2/frame/g"
|
||
)
|
||
|
||
type PetBagController struct {
|
||
*cool.Controller
|
||
}
|
||
type PetGetReq struct {
|
||
g.Meta `path:"/genpet" method:"POST"`
|
||
// 新增:精灵相关参数(完全对齐自定义表单配置)
|
||
PetTypeId int `json:"petTypeId" v:"required|min:1" comment:"精灵类型ID,必填,正整数(最小1,无0或负数类型),对应GenPetInfo的id参数"`
|
||
IndividualValue int `json:"individualValue" v:"required|between:-1,31" comment:"精灵个体值,必填,范围-1~31(-1表示随机生成满个体,0~31为固定值,决定基础属性上限)"`
|
||
NatureId int `json:"natureId" v:"required|between:-1,24" comment:"精灵性格ID,必填,范围-1~24(-1表示随机,0~24对应25种固定性格,影响属性加成)"`
|
||
AbilityTypeEnum int `json:"abilityTypeEnum" v:"required|min:-1" comment:"精灵特性类型ID,必填,最小值-1(-1表示随机选择1个特性,0及以上为固定特性ID,需与PlayerEffectMAP匹配)"`
|
||
IsShiny int `json:"isShiny" v:"min:-1" comment:"精灵异色(闪光)ID,必填,最小值-1(-1表示随机,0及以上为固定异色状态,稀有精灵特殊外观/属性),原表单hidden但需保留必填逻辑"`
|
||
Level int `json:"level" v:"required|between:1,100" comment:"精灵等级,必填,范围1~100(常规游戏等级上限,影响精灵当前属性强度)"`
|
||
}
|
||
|
||
func init() {
|
||
var task_info_controller = &PetBagController{
|
||
&cool.Controller{
|
||
Prefix: "/admin/monster/bag",
|
||
Api: []string{"Delete", "Update", "Info", "List", "Page"},
|
||
Service: service.NewPetService(),
|
||
},
|
||
}
|
||
// 注册路由
|
||
cool.RegisterController(task_info_controller)
|
||
}
|
||
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)
|
||
return
|
||
|
||
}
|