- 在玩家结构中添加 StopChan 通道,用于停止刷怪协程 - 优化 MapEnter 和 MapLeave 函数,支持刷怪功能 - 新增 spawnMonsters 函数实现具体刷怪逻辑 - 优化多个模块的数据库查询语句,提高查询效率 - 调整 PlayerService 中的 Reg 函数,优化数据插入操作
42 lines
669 B
Go
42 lines
669 B
Go
package service
|
|
|
|
import (
|
|
"blazing/cool"
|
|
"blazing/modules/blazing/model"
|
|
)
|
|
|
|
type MonsterService struct {
|
|
*cool.Service
|
|
}
|
|
|
|
func NewMonsterService() *MonsterService {
|
|
return &MonsterService{
|
|
&cool.Service{
|
|
Model: model.NewMonsterRefresh(),
|
|
PageQueryOp: &cool.QueryOp{
|
|
FieldEQ: []string{"status", "type"},
|
|
},
|
|
UniqueKey: map[string]string{
|
|
"name": "任务名称不能重复",
|
|
},
|
|
},
|
|
}
|
|
}
|
|
func (s *MonsterService) GetId(mapid uint32) uint32 {
|
|
|
|
m := cool.DBM(s.Model).Where("map_id", mapid)
|
|
var tt []model.MonsterRefresh
|
|
m.Scan(&tt)
|
|
|
|
for _, v := range tt {
|
|
|
|
if v.MapID == int32(mapid) {
|
|
return uint32(v.MonsterID)
|
|
|
|
}
|
|
|
|
}
|
|
return 0
|
|
|
|
}
|