feat(logic): 实现地图刷怪功能并优化数据库查询

- 在玩家结构中添加 StopChan 通道,用于停止刷怪协程
- 优化 MapEnter 和 MapLeave 函数,支持刷怪功能
- 新增 spawnMonsters 函数实现具体刷怪逻辑
- 优化多个模块的数据库查询语句,提高查询效率
- 调整 PlayerService 中的 Reg 函数,优化数据插入操作
This commit is contained in:
2025-08-23 17:44:12 +08:00
parent bc4bd7eba6
commit b6164f3b9e
11 changed files with 131 additions and 26 deletions

View File

@@ -15,11 +15,12 @@ type MonsterRefresh struct {
MapID int32 `gorm:"not null;index:idx_refresh_by_map_id;comment:'所属地图ID'" json:"map_id"`
MonsterID int32 `gorm:"not null;comment:'怪物唯一编号'" json:"monster_id"`
//Desc string `gorm:"type:varchar(100);not null;comment:'怪物名称(如皮皮)'" json:"desc"`
MinLevel int32 `gorm:"not null;comment:'最低等级'" json:"min_level"`
MaxLevel int32 `gorm:"not null;comment:'最高等级'" json:"max_level"`
Capturable bool `gorm:"not null;comment:'是否可捕捉'" json:"capturable"`
Rate float64 `gorm:"not null;comment:'刷新概率(百分比)'" json:"rate"` //未设置概率的就是默认刷新
Value string `gorm:"type:text;not null;comment:'限制值如19:00-24:00'" json:"value"` //这里是js文本暂定传入时间
MinLevel int32 `gorm:"not null;comment:'最低等级'" json:"min_level"`
MaxLevel int32 `gorm:"not null;comment:'最高等级'" json:"max_level"`
Capturable bool `gorm:"not null;comment:'是否可捕捉'" json:"capturable"`
Rate float64 `gorm:"not null;comment:'刷新概率(百分比'" json:"rate"` //未设置概率的就是默认刷新
Value string `gorm:"type:text;not null;comment:'限制值如19:00-24:00'" json:"value"` //这里是js文本暂定传入时间
}
// TableName MonsterRefresh's table name