Files
bl/modules/player/controller/admin/monster_get.go
xinian d258274322
Some checks failed
ci/woodpecker/push/my-first-workflow Pipeline failed
1
2026-02-13 06:44:16 +08:00

73 lines
2.9 KiB
Go
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

package admin
import (
"blazing/cool"
"blazing/modules/player/model"
"blazing/modules/player/service"
"context"
"github.com/gogf/gf/v2/container/gmap"
"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(0), //因为page已经过滤所以这里需要改成0
},
}
// 注册路由
cool.RegisterController(task_info_controller)
}
func (c *PetBagController) GetSession(ctx context.Context, req *PetGetReq) (res *cool.BaseRes, err error) {
var (
admin = cool.GetAdmin(ctx)
//r = g.RequestFromCtx(ctx)
)
t := model.GenPetInfo(
req.PetTypeId, req.IndividualValue, req.NatureId, req.AbilityTypeEnum, req.Level, nil, -1)
t.FixShiny()
service.NewUserService(uint32(admin.UserId)).Pet.PetAdd(t)
return
}
func (c *PetBagController) Level(ctx context.Context, req *PetLevelReq) (res *cool.BaseRes, err error) {
m := gmap.New()
for _, v := range service.NewUserService(0).Pet.Pet_LEVEL_all() {
v.PlayerID
// SELECT
// pp.player_id,
// (pp.data->>'ID')::INT AS id,
// (pp.data->>'Level')::INT AS level
// FROM "player_pet" pp
// WHERE (pp.data->>'Level')::INT > 100
// ORDER BY level DESC;
}
return
}
type PetLevelReq struct {
g.Meta `path:"/getlevel" method:"GET"`
// 新增:精灵相关参数(完全对齐自定义表单配置)
}