Files
bl/modules/blazing/model/done.go
昔念 e54d4bacaa ```
feat(fight): 增加战斗模式枚举并重构战斗逻辑判断

- 引入完整的 BattleMode 枚举定义,替代原有的 BattleStatus,明确区分各类战斗场景
- 在多个控制器中替换对旧 Status 字段的依赖,统一使用 Mode 判断战斗状态
- 修复部分函数调用前未检查 FightC 是否为空的问题,增加 ErrBattleEnded 错误返回
- 调整
2025-11-21 02:40:27 +08:00

67 lines
2.3 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"
"github.com/tnnmigga/enum"
)
type EnumMilestone int
var MilestoneMode = enum.New[struct {
BOSS EnumMilestone //boss类 地图ID->BOSSID
ITEM EnumMilestone //物品类 物品ID 使用精灵
Fight EnumMilestone //挑战类 对战模式->对战类型->1是赢,0是总局数
}]()
// 里程碑数据结构与DoneEvent对应记录单条里程碑的详细信息
// type MilestoneData struct {
// DoneType EnumMilestone `json:"done_type"` // 里程碑类型0-地图解锁1-BOSS击杀2-物品收集等)
// Args []uint32 `json:"args"` // 关联ID列表如地图ID、BOSSID、物品ID等
// Results []uint32 `json:"results"` // 完成情况参数(如:击杀次数、收集数量阈值等)
// Count uint32 `json:"count"` // 累计完成次数某BOSS累计击杀3次
// //IsCompleted bool `json:"is_completed"` // 是否完全达成(用于区分阶段性里程碑)
// }
const TableNameMilestone = "milestone"
// Milestone 数据库存储结构体映射milestone表
type Milestone struct {
*cool.Model
PlayerID uint64 `gorm:"not null;index:idx_milestone_by_player_id;comment:'所属玩家ID'" json:"player_id"`
DoneType EnumMilestone `gorm:"not null;comment:'里程碑类型'" json:"done_type"`
Args string `gorm:"type:text;not null;comment:'里程碑ID'" json:"args"`
// 注:不单独设置"里程碑ID",通过 PlayerID + DoneType + IDs 组合唯一标识一个里程碑(更灵活)
Results string `gorm:"type:jsonb;not null;comment:'里程碑参数'" json:"results"`
Count uint32 `gorm:"not null;comment:'里程碑完成次数'" json:"count"`
}
// MilestoneEX 里程碑扩展结构体,用于业务层解析后的数据操作
type MilestoneEX struct {
Milestone
Args []uint32 // 解析后的里程碑详细数据
Results []uint32 `json:"results"` // 解析后的里程碑详细数据
}
// TableName 返回表名
func (*Milestone) TableName() string {
return TableNameMilestone
}
// GroupName 返回表组名
func (*Milestone) GroupName() string {
return "default"
}
// NewMilestone 创建新里程碑实例
func NewMilestone() *Milestone {
return &Milestone{
Model: cool.NewModel(),
}
}
// init 初始化表
func init() {
cool.CreateTable(&Milestone{})
}