```
feat(blazing): 更新怪物刷新规则模型结构 重构 monster_refresh.go 中的 MonsterRefresh 模型,调整字段定义以支持更灵活的刷新配置。 新增 MapID、MinLevel、MaxLevel、FixPos 和 Script 字段,用于支持地图和等级相关的刷新逻辑。 保留部分异色相关字段并标记为待定,便于后续决定是否移除。 新增 MonsterRefreshEX 结构体扩展 MonsterRefresh 并支持数组形式的 MonsterID 和 ShinyID。 修改注释内容以准确反映当前字段含义与用途。 同时修正 dict_info.go 中查询条件错误,将 type in (?) 更正
This commit is contained in:
22
modules/blazing/controller/admin/boss.go
Normal file
22
modules/blazing/controller/admin/boss.go
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
package admin
|
||||||
|
|
||||||
|
import (
|
||||||
|
"blazing/cool"
|
||||||
|
"blazing/modules/blazing/service"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BossController struct {
|
||||||
|
*cool.Controller
|
||||||
|
}
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
var task_info_controller = &BossController{
|
||||||
|
&cool.Controller{
|
||||||
|
Prefix: "/admin/monster/boss",
|
||||||
|
Api: []string{"Add", "Delete", "Update", "Info", "List", "Page"},
|
||||||
|
Service: service.NewBossService(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
// 注册路由
|
||||||
|
cool.RegisterController(task_info_controller)
|
||||||
|
}
|
||||||
108
modules/blazing/model/boss.go
Normal file
108
modules/blazing/model/boss.go
Normal file
@@ -0,0 +1,108 @@
|
|||||||
|
package model
|
||||||
|
|
||||||
|
import (
|
||||||
|
"blazing/cool"
|
||||||
|
)
|
||||||
|
|
||||||
|
const (
|
||||||
|
TableNameBossConfig = "boss_config" // BOSS配置表(全量包含基础/奖励/护盾/捕捉/特效/世界野怪/地图费用/战斗通用逻辑)
|
||||||
|
)
|
||||||
|
|
||||||
|
// BossConfig BOSS配置模型(覆盖所有补充的配置项:GBTL/非VIP费用/首场景/战斗通用逻辑)
|
||||||
|
type BossConfig struct {
|
||||||
|
*cool.Model // 嵌入通用Model(包含ID/创建时间/更新时间等通用字段)
|
||||||
|
|
||||||
|
// ===================== 基础配置 =====================
|
||||||
|
BossID int32 `gorm:"not null;comment:'BOSS唯一标识ID'" json:"boss_id"`
|
||||||
|
MapID int32 `gorm:"not null;comment:'BOSS所在地图ID'" json:"map_id"`
|
||||||
|
InitX int32 `gorm:"not null;default:0;comment:'BOSS初始X坐标(对应玩家登陆坐标逻辑)'" json:"init_x"`
|
||||||
|
InitY int32 `gorm:"not null;default:0;comment:'BOSS初始Y坐标(对应玩家登陆坐标逻辑)'" json:"init_y"`
|
||||||
|
BossVisible int32 `gorm:"not null;default:0;comment:'BOSS是否可见(0:不可见,1:可见)'" json:"boss_visible"`
|
||||||
|
AppearTime string `gorm:"not null;comment:'BOSS出现时间(格式示例:0 23,空格分隔的时间点)'" json:"appear_time"`
|
||||||
|
Name string `gorm:"not null;comment:'BOSS名称'" json:"name"`
|
||||||
|
NonVipCost int32 `gorm:"not null;default:0;comment:'非VIP用户进地图需支付的赛尔豆(VIP用户免费,默认0)'" json:"non_vip_cost"`
|
||||||
|
PrimaryScene int32 `gorm:"not null;default:0;comment:'首场景标识(0:非首场景地图;n>0:第n星系的星球且是首场景,默认0)'" json:"primary_scene"`
|
||||||
|
|
||||||
|
// ===================== 战斗核心属性(BossMon节点) =====================
|
||||||
|
MonID int32 `gorm:"not null;comment:'BOSS对应的精灵ID'" json:"mon_id"`
|
||||||
|
Hp int32 `gorm:"not null;comment:'BOSS血量值(LvHpMatchUser非0时此配置无效)'" json:"hp"`
|
||||||
|
Lv int32 `gorm:"not null;comment:'BOSS等级(LvHpMatchUser非0时此配置无效)'" json:"lv"`
|
||||||
|
Atk int32 `gorm:"not null;comment:'BOSS物理攻击'" json:"atk"`
|
||||||
|
Def int32 `gorm:"not null;comment:'BOSS物理防御'" json:"def"`
|
||||||
|
Spatk int32 `gorm:"not null;comment:'BOSS特殊攻击'" json:"spatk"`
|
||||||
|
Spdef int32 `gorm:"not null;comment:'BOSS特殊防御'" json:"spdef"`
|
||||||
|
Spd int32 `gorm:"not null;comment:'BOSS速度'" json:"spd"`
|
||||||
|
|
||||||
|
// ===================== BOSS奖励规则(Boss_bonus) =====================
|
||||||
|
BonusProbability int32 `gorm:"not null;default:0;comment:'打赢BOSS给奖励概率-分子(值域:0-1000,默认0)'" json:"bonus_probability"`
|
||||||
|
BonusTotalProbability int32 `gorm:"not null;default:1000;comment:'打赢BOSS给奖励概率-分母(值域:1000,默认1000)'" json:"bonus_total_probability"`
|
||||||
|
BonusMonsterProbability int32 `gorm:"not null;default:0;comment:'给精灵奖励比例(值域:0-1000,默认0;物品奖励比例=分母-此值)'" json:"bonus_monster_probability"`
|
||||||
|
BonusID int32 `gorm:"not null;comment:'奖励ID(必配,有效BonusID)'" json:"bonus_id"`
|
||||||
|
MonBonusOutID int32 `gorm:"not null;comment:'精灵奖励ID(必配,有效精灵BonusID,奖精灵时生效)'" json:"mon_bonus_out_id"`
|
||||||
|
ItemBonusOutID int32 `gorm:"not null;comment:'物品奖励ID(必配,有效物品BonusID,奖物品时生效)'" json:"item_bonus_out_id"`
|
||||||
|
|
||||||
|
NewSeIdxs string `gorm:"type:text;not null;default:'0';comment:'新特效idx(值域:1-2000,0无特效,对应conf/new_se.xml,空格分隔列表)'" json:"new_se_idxs"`
|
||||||
|
|
||||||
|
// ===================== BOSS护盾属性 =====================
|
||||||
|
Shield int32 `gorm:"not null;default:0;comment:'BOSS护盾Hp(如蘑菇怪,默认0)'" json:"shield"`
|
||||||
|
MaxAccLostShield int32 `gorm:"not null;default:0;comment:'护盾变化通知AS的阈值(默认0)'" json:"max_acc_lost_shield"`
|
||||||
|
ShieldRecoverTime int32 `gorm:"not null;default:0;comment:'护盾恢复时间间隔(默认0)'" json:"shield_recover_time"`
|
||||||
|
|
||||||
|
// ===================== BOSS对战/捕捉规则 =====================
|
||||||
|
BossCatchable int32 `gorm:"not null;default:0;comment:'BOSS是否可被捕捉(0:否,1:是,默认0)'" json:"boss_catchable"`
|
||||||
|
BossFinOnce int32 `gorm:"not null;default:0;comment:'拥有后是否不能再打(0:否,1:是,默认0)'" json:"boss_fin_once"`
|
||||||
|
BossFinTaskWay int32 `gorm:"not null;default:0;comment:'完成任务方式(0:正常+捕捉;1:仅正常;2:仅捕捉,默认0)'" json:"boss_fin_task_way"`
|
||||||
|
PkFlag int32 `gorm:"not null;default:0;comment:'是否单精灵对战(0:否,1:是,默认0)'" json:"pk_flag"`
|
||||||
|
LvHpMatchUser int32 `gorm:"not null;default:0;comment:'等级血量匹配用户(0:无效;2:低5级;3:高2级;4:高5级;5:低10级;6:低5级且HP4倍;7:同等级且HP2.5倍)'" json:"lv_hp_match_user"`
|
||||||
|
//VipOnly int32 `gorm:"not null;default:0;comment:'仅VIP可打(0:否,1:是,默认0)'" json:"vip_only"`
|
||||||
|
|
||||||
|
// ===================== 世界野怪变身配置 =====================
|
||||||
|
WorldWildProb int32 `gorm:"not null;default:0;comment:'变身世界野怪概率分子(值域:0-1000,默认0)'" json:"world_wild_prob"`
|
||||||
|
WorldWildMonId int32 `gorm:"not null;default:0;comment:'变身世界野怪的精灵ID(默认0)'" json:"world_wild_mon_id"`
|
||||||
|
WorldWildMonLv int32 `gorm:"not null;default:0;comment:'变身世界野怪的等级(默认0)'" json:"world_wild_mon_lv"`
|
||||||
|
WorldWildStart int32 `gorm:"not null;default:0;comment:'世界野怪出现起始时间(值域:0-23,默认0)'" json:"world_wild_start"`
|
||||||
|
WorldWildEnd int32 `gorm:"not null;default:23;comment:'世界野怪出现终止时间(值域:0-23,默认23)'" json:"world_wild_end"`
|
||||||
|
|
||||||
|
// ===================== 战斗开始/结束通用逻辑配置 =====================
|
||||||
|
// 支持battle_mode_vs_boss battle_mode_no_region_boss,战斗协议2411、41129
|
||||||
|
TimeFlag int32 `gorm:"not null;default:0;comment:'战斗时间判断标识(关联activity_config_pool.xml,默认0)'" json:"time_flag"`
|
||||||
|
DailyKey string `gorm:"not null;default:'';comment:'战斗每天挑战次数key(为空则不限制次数)'" json:"daily_key"`
|
||||||
|
MaxTimes int32 `gorm:"not null;default:0;comment:'每天挑战上限(非0生效,默认0)'" json:"max_times"`
|
||||||
|
VipMaxTimes int32 `gorm:"not null;default:0;comment:'VIP每天挑战上限(非0生效,0时等于MaxTimes,默认0)'" json:"vip_max_times"`
|
||||||
|
WinBonusId int32 `gorm:"not null;default:0;comment:'战斗成功输出奖励ID(对应no_wait_bonus.xml,默认0)'" json:"win_bonus_id"`
|
||||||
|
WinOutId int32 `gorm:"not null;default:0;comment:'战斗成功输出奖励OutID(对应no_wait_bonus.xml,默认0)'" json:"win_out_id"`
|
||||||
|
FailBonusId int32 `gorm:"not null;default:0;comment:'战斗失败输出奖励ID(对应no_wait_bonus.xml,默认0)'" json:"fail_bonus_id"`
|
||||||
|
FailOutId int32 `gorm:"not null;default:0;comment:'战斗失败输出奖励OutID(对应no_wait_bonus.xml,默认0)'" json:"fail_out_id"`
|
||||||
|
BitSet string `gorm:"type:text;not null;default:'';comment:'战斗成功bitset限制条件(默认空)'" json:"bit_set"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// BossConfigEX 扩展BOSS配置模型(用于前端/业务层的数组格式解析)
|
||||||
|
type BossConfigEX struct {
|
||||||
|
BossConfig
|
||||||
|
NewSeIdxs []uint32 `json:"new_se_idxs"` // 特效idx数组(解析空格分隔的字符串为数组)
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableName 指定BossConfig对应的数据库表名
|
||||||
|
func (*BossConfig) TableName() string {
|
||||||
|
return TableNameBossConfig
|
||||||
|
}
|
||||||
|
|
||||||
|
// GroupName 指定表所属的分组(保持和怪物刷新表一致)
|
||||||
|
func (*BossConfig) GroupName() string {
|
||||||
|
return "default"
|
||||||
|
}
|
||||||
|
|
||||||
|
// NewBossConfig 创建一个新的BossConfig实例(初始化通用Model字段+所有默认值)
|
||||||
|
func NewBossConfig() *BossConfig {
|
||||||
|
return &BossConfig{
|
||||||
|
Model: cool.NewModel(),
|
||||||
|
BonusTotalProbability: 1000, // 奖励概率分母默认1000
|
||||||
|
WorldWildEnd: 23, // 世界野怪结束时间默认23
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
// init 程序启动时自动创建/同步boss_config表结构
|
||||||
|
func init() {
|
||||||
|
cool.CreateTable(&BossConfig{})
|
||||||
|
}
|
||||||
@@ -5,43 +5,51 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
TableNameMonsterRefresh = "monster_refresh" // 怪物刷新规则表
|
TableNameMonsterRefresh = "monster_refresh" // 怪物刷新规则表(地图-精灵等级-刷新脚本配置)
|
||||||
|
|
||||||
)
|
)
|
||||||
|
|
||||||
// MonsterRefresh 怪物刷新规则模型(对应XML中的<monster>标签)
|
// MonsterRefresh 怪物刷新规则模型(对应前端配置的地图/精灵/等级/脚本配置)
|
||||||
type MonsterRefresh struct {
|
type MonsterRefresh struct {
|
||||||
*cool.Model
|
*cool.Model // 嵌入通用Model(包含ID/创建时间/更新时间等通用字段)
|
||||||
|
|
||||||
MonsterID int32 `gorm:"not null;comment:'对应原怪物唯一编号'" json:"monster_id"`
|
MapID int32 `gorm:"not null;comment:'地图ID'" json:"map_id"`
|
||||||
ShinyID int32 `gorm:"not null;uniqueIndex;comment:'异色唯一标识ID'" json:"shiny_id"`
|
MonsterID string `gorm:"not null;comment:'精灵ID,填0为填充数组'" json:"monster_id"`
|
||||||
RefreshScript string `gorm:"type:text;not null;comment:'刷新脚本(JS格式,可包含时间/天气/地形等条件)'" json:"refresh_script"`
|
MinLevel int32 `gorm:"not null;comment:'精灵最低等级'" json:"min_level"`
|
||||||
|
MaxLevel int32 `gorm:"not null;comment:'精灵最高等级'" json:"max_level"`
|
||||||
|
FixPos int32 `gorm:"not null;comment:'固定位置刷新(0:随机位置,没有固定位置的时候就会取一个随机位置,如果没有随机位置就不刷新,1-9:固定位置)'" json:"fix_pos"`
|
||||||
|
Script string `gorm:"type:text;not null;comment:'刷新脚本(JS格式,对应前端编辑器配置)'" json:"value"`
|
||||||
|
|
||||||
ShinyFilter string `gorm:"type:text;not null;comment:'异色滤镜效果(文本描述或配置参数)'" json:"shiny_filter"`
|
// 以下为原模型保留的异色相关字段(前端暂未配置,如需移除可删除)
|
||||||
ShinyEffect string `gorm:"type:text;not null;comment:'异色光效效果(文本描述或配置参数)'" json:"shiny_effect"`
|
ShinyID string `gorm:"not null;comment:'异色唯一标识ID'" json:"shiny_id"`
|
||||||
// TODO: 增加ruffle的显示异色效果
|
// ShinyFilter string `gorm:"type:text;not null;comment:'异色滤镜效果(文本描述或配置参数)'" json:"shiny_filter"`
|
||||||
|
// ShinyEffect string `gorm:"type:text;not null;comment:'异色光效效果(文本描述或配置参数)'" json:"shiny_effect"`
|
||||||
|
// TODO: 增加ruffle的显示异色效果(如需保留则完善,无需则删除)
|
||||||
}
|
}
|
||||||
|
|
||||||
// TableName MonsterRefresh's table name
|
type MonsterRefreshEX struct {
|
||||||
|
MonsterRefresh
|
||||||
|
MonsterID []uint32 `json:"monster_id"`
|
||||||
|
ShinyID []uint32 `json:"shiny_id"`
|
||||||
|
}
|
||||||
|
|
||||||
|
// TableName 指定MonsterRefresh对应的数据库表名
|
||||||
func (*MonsterRefresh) TableName() string {
|
func (*MonsterRefresh) TableName() string {
|
||||||
return TableNameMonsterRefresh
|
return TableNameMonsterRefresh
|
||||||
}
|
}
|
||||||
|
|
||||||
// GroupName MonsterRefresh's table group
|
// GroupName 指定表所属的分组(保持和参考示例一致)
|
||||||
func (*MonsterRefresh) GroupName() string {
|
func (*MonsterRefresh) GroupName() string {
|
||||||
return "default"
|
return "default"
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMonsterRefresh create a new MonsterRefresh
|
// NewMonsterRefresh 创建一个新的MonsterRefresh实例(初始化通用Model)
|
||||||
func NewMonsterRefresh() *MonsterRefresh {
|
func NewMonsterRefresh() *MonsterRefresh {
|
||||||
return &MonsterRefresh{
|
return &MonsterRefresh{
|
||||||
Model: cool.NewModel(),
|
Model: cool.NewModel(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// 初始化表结构
|
// init 初始化表结构(程序启动时自动创建/同步表)
|
||||||
func init() {
|
func init() {
|
||||||
|
|
||||||
cool.CreateTable(&MonsterRefresh{})
|
cool.CreateTable(&MonsterRefresh{})
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
18
modules/blazing/service/boss.go
Normal file
18
modules/blazing/service/boss.go
Normal file
@@ -0,0 +1,18 @@
|
|||||||
|
package service
|
||||||
|
|
||||||
|
import (
|
||||||
|
"blazing/cool"
|
||||||
|
"blazing/modules/blazing/model"
|
||||||
|
)
|
||||||
|
|
||||||
|
type BossService struct {
|
||||||
|
*cool.Service
|
||||||
|
}
|
||||||
|
|
||||||
|
func NewBossService() *BossService {
|
||||||
|
return &BossService{
|
||||||
|
&cool.Service{
|
||||||
|
Model: model.NewBossConfig(),
|
||||||
|
},
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -15,6 +15,13 @@ type DictInfoService struct {
|
|||||||
*cool.Service
|
*cool.Service
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// func init() {
|
||||||
|
|
||||||
|
// t, _ := NewDictInfoService().Data(context.TODO(), []string{"mapid"})
|
||||||
|
// fmt.Println(t)
|
||||||
|
|
||||||
|
// }
|
||||||
|
|
||||||
// Data方法, 用于获取数据
|
// Data方法, 用于获取数据
|
||||||
func (s *DictInfoService) Data(ctx context.Context, types []string) (data interface{}, err error) {
|
func (s *DictInfoService) Data(ctx context.Context, types []string) (data interface{}, err error) {
|
||||||
var (
|
var (
|
||||||
@@ -24,7 +31,7 @@ func (s *DictInfoService) Data(ctx context.Context, types []string) (data interf
|
|||||||
mType := cool.DBM(dictTypeModel)
|
mType := cool.DBM(dictTypeModel)
|
||||||
// 如果types不为空, 则查询指定类型的数据
|
// 如果types不为空, 则查询指定类型的数据
|
||||||
if len(types) > 0 {
|
if len(types) > 0 {
|
||||||
mType = mType.Where("type in (?)", types)
|
mType = mType.Where("key in (?)", types)
|
||||||
}
|
}
|
||||||
// 查询所有类型
|
// 查询所有类型
|
||||||
typeData, err := mType.All()
|
typeData, err := mType.All()
|
||||||
|
|||||||
Reference in New Issue
Block a user