Files
bl/modules/config/model/map_node.go
xinian 1969c01f3e
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
feat: 添加战胜规则配置模块
2026-03-21 00:57:18 +08:00

87 lines
3.6 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 model
import (
"blazing/cool"
)
// 这个是替换盖亚的实现,因为是单独类的
const (
// 新增地图节点表常量
TableNameMapNode = "config_map_node" // 地图节点配置表记录地图各节点的类型、绑定BOSS、剧情等信息
)
// 节点类型常量定义
const (
MapNodeTypeBoss = 1 // BOSS节点
MapNodeTypeNPC = 2 // NPC节点
MapNodeTypeScene = 3 // 场景触发节点
MapNodeTypePortal = 4 // 传送门节点
)
type BroadcastNode struct {
//节点激活脚本
TriggerID uint32 `gorm:"comment:'触发器ID'" json:"trigger_id" description:"触发器ID"`
//BOSS位置,多位置就是循环触发,固定点就是单位置,如果要实现原地动,就用2个固定位置来做
//0:固定点,1:多位置,2:循环触发 赛有随机的boss和伪装的boss,如果是伪装boss,就触发剧情后实现boss的切换后再操作
Pos string `gorm:"type:varchar(255);default:'';comment:'位置'" json:"pos"`
HP int32 `gorm:"type:int;default:0;comment:'血量'" json:"hp" description:"血量"`
//方向BroadcastNode
Direction int32 `gorm:"type:int;default:0;comment:'方向'" json:"direction" description:"方向"`
}
// MapNode 地图节点配置模型
type MapNode struct {
*BaseConfig
*Event // 嵌入BOSS事件配置
*BroadcastNode
// 基础关联字段
MapID int32 `gorm:"not null;index;comment:'所属地图ID'" json:"map_id" description:"地图ID"`
//可以是精灵也可以是NPC ,到时候npc用高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:"节点名称"`
WinBonusID int `gorm:"type:int;default:0;comment:'胜利奖励ID'" json:"win_bonus_id"`
FailBonusID int `gorm:"type:int;default:0;comment:'失败奖励ID'" json:"fail_bonus_id"`
//是否需要广播,比如雷伊
IsBroadcast int `gorm:"type:int;default:0;comment:'是否需要广播'" json:"is_broadcast"`
// 剧情相关配置 通过剧情去主动触发boss显示和对话显示 ,待重构通过NPC节点判断哪种类型
TriggerPlotID uint32 `gorm:"default:0;comment:'触发剧情ID0表示无剧情'" json:"trigger_plot_id" description:"触发剧情ID"`
//BindPlotIDs []uint32 `gorm:"type:int[];comment:'绑定的剧情ID列表'" json:"bind_plot_ids" description:"绑定剧情ID列表"`
//完成后的脚本回调比如战胜和击败绑定不同的任务ID以及剧情绑定不同的ID
//回调通boss打完给前端发送固定事件
//PlotFinishScript string `gorm:"type:text;comment:'剧情完成后脚本回调'" json:"plot_finish_script" description:"剧情完成后脚本回调"`
Rule []uint32 `gorm:"type:jsonb; ;comment:'战胜规则'" json:"rule"`
BossIds []uint32 `gorm:"type:jsonb; ;comment:'塔层BOSS ID列表'" json:"boss_ids"`
}
// -------------------------- MapNode 配套方法(遵循项目规范)--------------------------
// TableName 指定数据库表名
func (*MapNode) TableName() string {
return TableNameMapNode
}
// GroupName 指定分组名称(与原有规范保持一致)
func (*MapNode) GroupName() string {
return "default"
}
// NewMapNode 创建MapNode实例
func NewMapNode() *MapNode {
return &MapNode{
BaseConfig: NewBaseConfig(),
}
}
// GetNodeTypeName 获取节点类型的中文名称(方便展示)
// -------------------------- 表结构自动同步 --------------------------
func init() {
// 同步原有地图配置表
cool.CreateTable(&MapConfig{})
// 同步新增的地图节点配置表
cool.CreateTable(&MapNode{})
}