refactor(common/data/xmlres): 注释掉未使用的MonsterMap配置变量 - 将MonsterMap配置变量注释掉,因为当前不再使用该配置 - 相应地注释掉了初始化代码中的MonsterMap赋值逻辑 feat(logic/controller): 统一CanFight方法返回值为ErrorCode - 修改PlayerFightBoss等战斗控制器中的Can
This commit is contained in:
@@ -3,9 +3,6 @@ package admin
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/service"
|
||||
"context"
|
||||
|
||||
"github.com/gogf/gf/v2/frame/g"
|
||||
)
|
||||
|
||||
type BossController struct {
|
||||
@@ -24,13 +21,13 @@ func init() {
|
||||
cool.RegisterController(task_info_controller)
|
||||
}
|
||||
|
||||
type GetListReq struct {
|
||||
g.Meta `path:"/getlist" method:"POST"`
|
||||
Id uint32 `json:"id" v:"required#请选择要查询的数据"`
|
||||
}
|
||||
// type GetListReq struct {
|
||||
// g.Meta `path:"/getlist" method:"POST"`
|
||||
// Id uint32 `json:"id" v:"required#请选择要查询的数据"`
|
||||
// }
|
||||
|
||||
func (this *BossController) GetList(ctx context.Context, req *GetListReq) (res *cool.BaseRes, err error) {
|
||||
res = &cool.BaseRes{}
|
||||
res.Data = service.NewBossService().GetList(req.Id)
|
||||
return res, nil
|
||||
}
|
||||
// func (this *BossController) GetList(ctx context.Context, req *GetListReq) (res *cool.BaseRes, err error) {
|
||||
// res = &cool.BaseRes{}
|
||||
// res.Data = service.NewBossService().GetList(req.Id)
|
||||
// return res, nil
|
||||
// }
|
||||
|
||||
@@ -16,7 +16,7 @@ func init() {
|
||||
&cool.Controller{
|
||||
Prefix: "/admin/config/mapboss",
|
||||
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"},
|
||||
Service: service.NewMapBossService(),
|
||||
Service: service.NewMapNodeService(),
|
||||
},
|
||||
})
|
||||
}
|
||||
|
||||
@@ -24,8 +24,9 @@ type MapNode struct {
|
||||
*BaseConfig
|
||||
*Event // 嵌入BOSS事件配置
|
||||
// 基础关联字段
|
||||
NodeType int `gorm:"not null;default:0;comment:'节点类型(0是游戏自带分支,其余自增)'" json:"node_type" description:"节点类型"`
|
||||
NodeID uint32 `gorm:"not null;default:0;comment:'节点ID'" json:"node_id" description:"节点ID"`
|
||||
MapID int32 `gorm:"not null;index;comment:'所属地图ID'" json:"map_id" description:"地图ID"`
|
||||
|
||||
NodeID uint32 `gorm:"not null;default:0;comment:'节点ID'" json:"node_id" description:"节点ID"`
|
||||
|
||||
NodeName string `gorm:"type:varchar(100);default:'';comment:'节点名称'" json:"node_name" description:"节点名称"`
|
||||
//节点激活脚本
|
||||
@@ -42,7 +43,7 @@ type MapNode struct {
|
||||
//回调通boss打完给前端发送固定事件
|
||||
//PlotFinishScript string `gorm:"type:text;comment:'剧情完成后脚本回调'" json:"plot_finish_script" description:"剧情完成后脚本回调"`
|
||||
|
||||
BindBossID uint32 `gorm:"default:0;comment:'绑定的BOSS ID(0表示无BOSS)'" json:"bind_boss_id" description:"绑定BOSS ID"`
|
||||
BossIds []uint32 `gorm:"type:jsonb; ;comment:'塔层BOSS ID列表'" json:"boss_ids"`
|
||||
}
|
||||
|
||||
// -------------------------- MapNode 配套方法(遵循项目规范)--------------------------
|
||||
@@ -64,20 +65,6 @@ func NewMapNode() *MapNode {
|
||||
}
|
||||
|
||||
// GetNodeTypeName 获取节点类型的中文名称(方便展示)
|
||||
func (m *MapNode) GetNodeTypeName() string {
|
||||
switch m.NodeType {
|
||||
case MapNodeTypeBoss:
|
||||
return "BOSS节点"
|
||||
case MapNodeTypeNPC:
|
||||
return "NPC节点"
|
||||
case MapNodeTypeScene:
|
||||
return "场景触发节点"
|
||||
case MapNodeTypePortal:
|
||||
return "传送门节点"
|
||||
default:
|
||||
return "未知节点"
|
||||
}
|
||||
}
|
||||
|
||||
// -------------------------- 表结构自动同步 --------------------------
|
||||
func init() {
|
||||
|
||||
@@ -13,9 +13,9 @@ const (
|
||||
|
||||
type BaseTowerConfig struct {
|
||||
*BaseConfig
|
||||
Name string `gorm:"type:varchar(100);default:'';comment:'塔名称'" json:"name" description:"塔名称"`
|
||||
TowerLevel uint32 `gorm:"not null;default:0;uniqueIndex;comment:'塔层数'" json:"tower_level" `
|
||||
BossIds uint32 `gorm:"type:jsonb; ;comment:'塔层BOSS ID列表'" json:"boss_ids"`
|
||||
Name string `gorm:"type:varchar(100);default:'';comment:'塔名称'" json:"name" description:"塔名称"`
|
||||
TowerLevel uint32 `gorm:"not null;default:0;uniqueIndex;comment:'塔层数'" json:"tower_level" `
|
||||
BossIds []uint32 `gorm:"type:jsonb; ;comment:'塔层BOSS ID列表'" json:"boss_ids"`
|
||||
}
|
||||
|
||||
// NewBaseTowerConfig 创建基础塔配置实例(所有塔类型共用)
|
||||
|
||||
@@ -25,23 +25,24 @@ func NewBossService() *BossService {
|
||||
}
|
||||
}
|
||||
|
||||
func (s *BossService) Get(id uint32) *model.BossConfig {
|
||||
func (s *BossService) Get(id uint32) []model.BossConfig {
|
||||
if id == 0 {
|
||||
return nil
|
||||
}
|
||||
var item *model.BossConfig
|
||||
dbm_notenable(s.Model).Where("id", id).Scan(&item)
|
||||
var item []model.BossConfig
|
||||
dbm_notenable(s.Model).Where("id", id).WhereOr("parentId", id).OrderAsc("ordernum").Scan(&item)
|
||||
|
||||
return item
|
||||
|
||||
}
|
||||
func (s *BossService) GetList(id uint32) []model.BossConfig {
|
||||
|
||||
var ret []model.BossConfig
|
||||
// func (s *BossService) GetList(id uint32) []model.BossConfig {
|
||||
|
||||
// 执行 Raw SQL 并扫描返回值
|
||||
dbm_nocache_noenable(s.Model).
|
||||
Wheref(`map_id @> ARRAY[?]::integer[]`, id).WhereOrf(`map_id @> ARRAY[?]::integer[]`, 0).Scan(&ret)
|
||||
// var ret []model.BossConfig
|
||||
|
||||
return ret
|
||||
}
|
||||
// // 执行 Raw SQL 并扫描返回值
|
||||
// dbm_nocache_noenable(s.Model).
|
||||
// Wheref(`map_id @> ARRAY[?]::integer[]`, id).WhereOrf(`map_id @> ARRAY[?]::integer[]`, 0).Scan(&ret)
|
||||
|
||||
// return ret
|
||||
// }
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
)
|
||||
|
||||
type MapBossService struct {
|
||||
*cool.Service
|
||||
}
|
||||
|
||||
func NewMapBossService() *MapBossService {
|
||||
return &MapBossService{
|
||||
&cool.Service{
|
||||
Model: model.NewMapNode(),
|
||||
PageQueryOp: &cool.QueryOp{
|
||||
KeyWordField: []string{"remake"},
|
||||
FieldEQ: []string{"map_id"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
30
modules/config/service/map_node.go
Normal file
30
modules/config/service/map_node.go
Normal file
@@ -0,0 +1,30 @@
|
||||
package service
|
||||
|
||||
import (
|
||||
"blazing/cool"
|
||||
"blazing/modules/config/model"
|
||||
)
|
||||
|
||||
type MapNodeService struct {
|
||||
*cool.Service
|
||||
}
|
||||
|
||||
func NewMapNodeService() *MapNodeService {
|
||||
return &MapNodeService{
|
||||
&cool.Service{
|
||||
Model: model.NewMapNode(),
|
||||
PageQueryOp: &cool.QueryOp{
|
||||
KeyWordField: []string{"remake"},
|
||||
FieldEQ: []string{"map_id"},
|
||||
},
|
||||
},
|
||||
}
|
||||
}
|
||||
func (s *MapNodeService) GetData(mapid, pos uint32) []model.MapNode {
|
||||
|
||||
var pet []model.MapNode //一个特性应该是唯一的,但是我们要获取默认随机特性
|
||||
dbm_enable(s.Model).Where("map_id", mapid).Wheref(`pos @> ARRAY[?]::integer[]`, pos).Scan(&pet)
|
||||
|
||||
return pet
|
||||
|
||||
}
|
||||
@@ -20,3 +20,11 @@ func NewMapPitService() *MapPitService {
|
||||
},
|
||||
}
|
||||
}
|
||||
func (s *MapPitService) GetData(mapid, pos uint32) []model.MapPit {
|
||||
|
||||
var pet []model.MapPit //一个特性应该是唯一的,但是我们要获取默认随机特性
|
||||
dbm_enable(s.Model).Where("map_id", mapid).Wheref(`pos @> ARRAY[?]::integer[]`, pos).Scan(&pet)
|
||||
|
||||
return pet
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user