All checks were successful
ci/woodpecker/push/my-first-workflow Pipeline was successful
refactor(common): 统一Redis连接方式并优化代码结构
- 将 g.Redis("cool").Conn(ctx) 统一改为 Redis.Conn(ctx) 的调用方式
- 在coolconfig中添加ServerList.GetID()方法用于生成服务器唯一标识
- 引入gconv包用于类型转换操作
feat(rpc): 完善ListenFight函数实现集群消息监听
- 新增ListenFight函数,完全对齐ListenFunc
42 lines
646 B
Go
42 lines
646 B
Go
package service
|
|
|
|
import (
|
|
"blazing/cool"
|
|
"blazing/modules/player/model"
|
|
)
|
|
|
|
type PVPService struct {
|
|
BaseService
|
|
}
|
|
|
|
func NewPVPService(id uint32) *PVPService {
|
|
return &PVPService{
|
|
|
|
BaseService: BaseService{userid: id,
|
|
|
|
Service: &cool.Service{Model: model.NewPVP()},
|
|
},
|
|
}
|
|
|
|
}
|
|
func (s *PVPService) Get(userid uint32) (ret *model.PVP) {
|
|
|
|
//todo待测试
|
|
|
|
m := s.dbm_fix(s.Model).Where("season", model.Curpvp)
|
|
|
|
m.Scan(&ret)
|
|
if ret == nil {
|
|
ret = &model.PVP{
|
|
PlayerID: uint32(userid),
|
|
Season: uint32(model.Curpvp),
|
|
RankInfo: model.PVPRankInfo{
|
|
Score: 800,
|
|
},
|
|
}
|
|
s.dbm_fix(s.Model).Data(ret).Insert()
|
|
}
|
|
|
|
return
|
|
}
|