Files
bl/modules/blazing/model/done.go
昔念 174562b895 ```
feat(config): 重构配置结构并添加服务器列表支持

- 重命名PortBL字段为GameOnlineID,改进命名语义
- 添加ServerList结构体用于管理服务器配置
- 移除七牛云配置相关字段
- 更新ID生成器使用GameOnlineID参数

fix(server): 调整服务器启动参数和VIP逻辑

- 将启动参数从-port改为-id,统一参数命名
- 更新服务器启动逻辑,基于GameOnlineID获取服务器信息
- 为VIP服务器启用调试模式
- 优化端口可用性检查逻辑

refactor(model): 统一模型基类结构

- 将各模型中的*cool.Model嵌入改为Base基类
- 移除soul.go
2026-01-08 03:30:18 +08:00

89 lines
3.1 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/samber/lo"
"github.com/tnnmigga/enum"
)
type EnumMilestone int
var MilestoneMode = enum.New[struct {
BOSS EnumMilestone //boss类 地图ID->BOSSID ,胜利次数 mapid bossid petid防止换boss后数据不可用
ITEM EnumMilestone //物品类 物品ID 使用精灵
Fight EnumMilestone //挑战类 对战模式->对战类型->1是赢,0是总局数
Moster EnumMilestone //野怪统计 地图ID->怪物ID
Task EnumMilestone
}]()
// 里程碑数据结构与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 {
Base
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"` // 解析后的里程碑详细数据
}
// 检查是否触发过,成功返回触发的次数,失败返回0
func (m *MilestoneEX) CheakNoNumber(count uint32) bool {
// if v.DoneType == model.MilestoneMode.BOSS && IsPrefixBasicSlice(v.Args, []uint32{mapid, bossid}) && v.Count == count {
_, ok := lo.Find(m.Results, func(v1 uint32) bool { //寻找是否触发过
//大于触发值就触发然后1的返回false因为没有奖励这样就可以一直触发
return v1 == count //大于等于就触发
})
//没找到且次数满足才能返回真
if !ok && m.Count >= count {
return true
}
//已经触发过
return false
// }
}
// TableName 返回表名
func (*Milestone) TableName() string {
return TableNameMilestone
}
// GroupName 返回表组名
func (*Milestone) GroupName() string {
return "default"
}
// NewMilestone 创建新里程碑实例
func NewMilestone() *Milestone {
return &Milestone{
Base: *NewBase(),
}
}
// init 初始化表
func init() {
cool.CreateTable(&Milestone{})
}