feat(cache): 添加复合键缓存操作支持 添加了基于 uint32+string 组合键的缓存操作方法,包括 GetByCompoundKey、SetByCompoundKey、DelByCompoundKey 和 ContainsByCompoundKey 方法,用于处理用户ID和会话ID的组合缓存场景 fix(vscode): 添加 cSpell 配置支持 struc 词汇 refactor(session): 移除过时的会话管理方法 移除了基于单一字符串键的会话管理方法,因为已迁移到使用 复合键的缓存操作方式 ```
110 lines
8.1 KiB
Go
110 lines
8.1 KiB
Go
package model
|
||
|
||
import (
|
||
"blazing/cool"
|
||
)
|
||
|
||
const (
|
||
TableNameMeleeConfig = "config_boss_melee" // BOSS配置表(全量包含基础/奖励/护盾/捕捉/特效/世界野怪/地图费用/战斗通用逻辑)
|
||
)
|
||
|
||
// PetBaseConfig BOSS配置模型(覆盖所有补充的配置项:GBTL/非VIP费用/首场景/战斗通用逻辑)
|
||
type PetBaseConfig 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"`
|
||
Nature int32 `gorm:"not null;default:0;comment:'BOSS属性-性格'" json:"nature"`
|
||
Effect []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS特性'" json:"effect"`
|
||
Lv int32 `gorm:"not null;comment:'BOSS等级(LvHpMatchUser非0时此配置无效)'" json:"lv"`
|
||
Color string `gorm:"comment:'BOSS颜色'" json:"color"`
|
||
Hp int32 `gorm:"not null;comment:'BOSS血量值(LvHpMatchUser非0时此配置无效)'" json:"hp"`
|
||
|
||
// ===================== BOSS属性(Boss_prop) =====================
|
||
Prop []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS属性'" json:"prop"`
|
||
|
||
SKill []uint32 `gorm:"type:jsonb;not null;default:'[]';comment:'BOSS技能'" json:"skill"`
|
||
|
||
IsEnable uint32 `gorm:"not null;default:0;comment:'是否启用'" json:"is_enable"`
|
||
Desc *string `gorm:"comment:'BOSS描述'" json:"desc"`
|
||
|
||
// ISMELEE uint32 `gorm:"not null;default:0;comment:'是否乱斗配置'" json:"is_melee"`
|
||
// // ===================== 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"`
|
||
}
|
||
|
||
// MeleeConfigEX 扩展BOSS配置模型(用于前端/业务层的数组格式解析)
|
||
|
||
// TableName 指定MeleeConfig对应的数据库表名
|
||
func (*PetBaseConfig) TableName() string {
|
||
return TableNameMeleeConfig
|
||
}
|
||
|
||
// GroupName 指定表所属的分组(保持和怪物刷新表一致)
|
||
func (*PetBaseConfig) GroupName() string {
|
||
return "default"
|
||
}
|
||
|
||
// NewMeleeConfig 创建一个新的MeleeConfig实例(初始化通用Model字段+所有默认值)
|
||
|
||
func NewMeettConfig() *PetBaseConfig {
|
||
return &PetBaseConfig{
|
||
Model: cool.NewModel(),
|
||
}
|
||
}
|
||
|
||
// init 程序启动时自动创建/同步boss_config表结构
|
||
func init() {
|
||
cool.CreateTable(&PetBaseConfig{})
|
||
}
|