```
All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful

feat(config): 添加事件配置和地图绑定功能

- 在BossConfig中添加MapID字段用于绑定地图ID和Event结构体
- 新增Event结构体包含精灵数组、触发时间、天气等事件相关字段
- 在MapPit中添加MapID字段用于绑定地图ID和Event结构体
- 为MapPit添加IsCapture字段标识是否可捕捉
- 更新NewBossConfig和NewMapPit构造函数初始化Event实例
- 注释掉MapNode中的NodeActiveScript字段
```
This commit is contained in:
昔念
2026-02-22 10:03:46 +08:00
parent f16838a916
commit 790bc21034
3 changed files with 23 additions and 5 deletions

View File

@@ -12,6 +12,9 @@ const (
type BossConfig struct {
*cool.Model // 嵌入通用Model包含ID/创建时间/更新时间等通用字段)
PetBaseConfig
//绑定地图地图ID
MapID []int32 `gorm:"type:int[];comment:'绑定地图地图ID'" json:"map_id"`
*Event
Script string `gorm:"size:1024;default:'';comment:'BOSS脚本'" json:"script"` //boss出招逻辑做成js脚本
// ISboss uint32 `gorm:"not null;default:0;comment:'是否是Boss'" json:"is_boss"`
@@ -33,6 +36,7 @@ func (*BossConfig) GroupName() string {
func NewBossConfig() *BossConfig {
return &BossConfig{
Model: cool.NewModel(),
Event: &Event{},
}
}

View File

@@ -8,10 +8,22 @@ const (
TableNameMapPit = "config_map_pit" // 地图坑位配置表(记录坑位归属、类型、属性、关联刷新规则等)
)
type Event struct {
//携带精灵数组Event
Sprites []int32 `gorm:"type:int[];comment:'携带精灵数组'" json:"sprites"`
//触发开始时间Event
StartTime int32 `gorm:"type:int;default:0;comment:'触发开始时间'" json:"start_time"`
//触发结束时间Event
EndTime int32 `gorm:"type:int;default:0;comment:'触发结束时间'" json:"end_time"`
//触发天气Event
Weather []int32 `gorm:"type:int[];comment:'触发天气'" json:"weather"`
}
// MapPit 地图坑位核心配置模型参照MonsterRefresh实现风格
type MapPit struct {
*BaseConfig // 复用通用基础配置ID/创建时间/更新时间等)
*BaseConfig // 复用通用基础配置ID/创建时间/更新时间等)
MapID []int32 `gorm:"type:int[];comment:'绑定地图地图ID'" json:"map_id"`
*Event
PitName string `gorm:"type:varchar(100);default:'';comment:'坑位名称'" json:"pit_name"`
RefreshID []int `gorm:"type:int[];comment:'关联刷新规则ID列表'" json:"refresh_id"`
@@ -19,8 +31,8 @@ type MapPit struct {
MinLevel int `gorm:"type:int;default:0;comment:'最小等级'" json:"min_level"`
//最大等级
MaxLevel int `gorm:"type:int;default:0;comment:'最大等级'" json:"max_level"`
Script string `gorm:"type:text;not null;comment:'刷新脚本JS格式对应前端编辑器配置'" json:"value"`
//是否可捕捉MapPit
IsCapture int `gorm:"type:int;default:0;comment:'是否可捕捉'" json:"is_capture"`
}
// TableName 指定MapPit对应的数据库表名遵循原模型规范
@@ -37,6 +49,7 @@ func (*MapPit) GroupName() string {
func NewMapPit() *MapPit {
return &MapPit{
BaseConfig: NewBaseConfig(),
Event: &Event{},
}
}

View File

@@ -27,7 +27,8 @@ type MapNode struct {
MapID uint32 `gorm:"not null;index;comment:'所属地图ID'" json:"map_id" description:"地图ID"`
NodeName string `gorm:"type:varchar(100);default:'';comment:'节点名称'" json:"node_name" description:"节点名称"`
//节点激活脚本
NodeActiveScript string `gorm:"type:text;comment:'节点激活脚本'" json:"node_active_script" description:"节点激活脚本"`
// NodeActiveScript string `gorm:"type:text;comment:'节点激活脚本'" json:"node_active_script" description:"节点激活脚本"`
//
// 节点核心配置
NodeType int `gorm:"not null;default:0;comment:'节点类型1-BOSS2-NPC3-场景触发4-传送门)'" json:"node_type" description:"节点类型"`