Merge branch 'look' into develop
This commit is contained in:
commit
b1c936fae8
|
@ -6,7 +6,7 @@
|
||||||
"VerifyClientVersion":true,
|
"VerifyClientVersion":true,
|
||||||
"SrvMaintain":false,
|
"SrvMaintain":false,
|
||||||
"WhiteHttpAddr": [],
|
"WhiteHttpAddr": [],
|
||||||
"HundredScenePreCreate":true,
|
"HundredScenePreCreate":false,
|
||||||
"WriteEventLog": true,
|
"WriteEventLog": true,
|
||||||
"SpreadAccountQPT":100,
|
"SpreadAccountQPT":100,
|
||||||
"FakeVerifyCode":"123456",
|
"FakeVerifyCode":"123456",
|
||||||
|
|
|
@ -2,17 +2,26 @@ package svc
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
|
"net/rpc"
|
||||||
|
|
||||||
|
"github.com/globalsign/mgo"
|
||||||
"github.com/globalsign/mgo/bson"
|
"github.com/globalsign/mgo/bson"
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
|
||||||
"mongo.games.com/game/dbproxy/mongo"
|
"mongo.games.com/game/dbproxy/mongo"
|
||||||
"mongo.games.com/game/model"
|
"mongo.games.com/game/model"
|
||||||
"net/rpc"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
MatchAwardLogDBErr = errors.New("log_matchawardlog db open failed.")
|
MatchAwardDBErr = errors.New("log_matchawardlog db open failed")
|
||||||
)
|
)
|
||||||
|
|
||||||
func MatchAwardLogCollection(plt string) *mongo.Collection {
|
type MatchAwardLog struct {
|
||||||
|
AwardNum map[string]map[int32]int32 // 奖励数量
|
||||||
|
Platform string
|
||||||
|
}
|
||||||
|
|
||||||
|
func MatchAwardCollection(plt string) *mongo.Collection {
|
||||||
s := mongo.MgoSessionMgrSington.GetPltMgoSession(plt, model.MatchAwardLogDBName)
|
s := mongo.MgoSessionMgrSington.GetPltMgoSession(plt, model.MatchAwardLogDBName)
|
||||||
if s != nil {
|
if s != nil {
|
||||||
c, _ := s.DB().C(model.MatchAwardLogCollName)
|
c, _ := s.DB().C(model.MatchAwardLogCollName)
|
||||||
|
@ -21,47 +30,55 @@ func MatchAwardLogCollection(plt string) *mongo.Collection {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func InsertOrUpdateMatchAwardLog(logs ...*model.MatchAwardLog) (err error) {
|
type MatchAwardSvc struct {
|
||||||
for _, log := range logs {
|
|
||||||
clog := MatchAwardLogCollection(log.Platform)
|
|
||||||
if clog == nil {
|
|
||||||
return
|
|
||||||
}
|
}
|
||||||
_, err = clog.Upsert(nil, log)
|
|
||||||
|
func (svc *MatchAwardSvc) UpsertMatchAward(req *model.MatchAward, ret *bool) (err error) {
|
||||||
|
c := MatchAwardCollection(req.Platform)
|
||||||
|
if c == nil {
|
||||||
|
return MatchAwardDBErr
|
||||||
|
}
|
||||||
|
|
||||||
|
_, err = c.Upsert(nil, req)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
// 处理错误
|
logger.Logger.Errorf("UpsertMatchAward err:%v", err)
|
||||||
|
}
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
}
|
|
||||||
return
|
func (svc *MatchAwardSvc) GetMatchAward(plt string, ret *model.MatchAward) (err error) {
|
||||||
|
c := MatchAwardCollection(plt)
|
||||||
|
if c == nil {
|
||||||
|
return MatchAwardDBErr
|
||||||
}
|
}
|
||||||
|
|
||||||
type MatchAwardLogSvc struct {
|
// 旧数据
|
||||||
}
|
old := &MatchAwardLog{}
|
||||||
|
err = c.Find(bson.M{"platform": "1"}).One(old)
|
||||||
func (svc *MatchAwardLogSvc) InsertOrUpdateMatchAwardLog(args []*model.MatchAwardLog, ret *bool) (err error) {
|
|
||||||
err = InsertOrUpdateMatchAwardLog(args...)
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
*ret = true
|
for k, v := range old.AwardNum {
|
||||||
|
d := &model.MatchAward{
|
||||||
|
Platform: k,
|
||||||
|
Award: make(map[int32]int32),
|
||||||
}
|
}
|
||||||
return
|
for kk, vv := range v {
|
||||||
|
d.Award[kk] = vv
|
||||||
}
|
}
|
||||||
func GetMatchAward(plt string, ret *model.MatchAwardLog) (err error) {
|
var b bool
|
||||||
clog := MatchAwardLogCollection(plt)
|
svc.UpsertMatchAward(d, &b)
|
||||||
if clog == nil {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
selecter := bson.M{"platform": plt}
|
c.Remove(bson.M{"platform": "1"})
|
||||||
err = clog.Find(selecter).One(&ret)
|
|
||||||
if err != nil {
|
|
||||||
return nil
|
|
||||||
}
|
}
|
||||||
return
|
// 旧数据
|
||||||
|
|
||||||
|
err = nil
|
||||||
|
err = c.Find(nil).One(ret)
|
||||||
|
if err != nil && err != mgo.ErrNotFound {
|
||||||
|
logger.Logger.Errorf("GetMatchAward err:%v", err)
|
||||||
}
|
}
|
||||||
func (svc *MatchAwardLogSvc) GetMatchAward(Plt string, ret *model.MatchAwardLog) (err error) {
|
|
||||||
err = GetMatchAward(Plt, ret)
|
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
rpc.Register(new(MatchAwardLogSvc))
|
rpc.Register(new(MatchAwardSvc))
|
||||||
}
|
}
|
||||||
|
|
|
@ -39,4 +39,5 @@ const (
|
||||||
ETCDKEY_RANK_TYPE = "/game/RankType" // 排行榜奖励配置
|
ETCDKEY_RANK_TYPE = "/game/RankType" // 排行榜奖励配置
|
||||||
ETCDKEY_AWARD_CONFIG = "/game/awardlog_config" //获奖记录
|
ETCDKEY_AWARD_CONFIG = "/game/awardlog_config" //获奖记录
|
||||||
ETCDKEY_GUIDE = "/game/guide_config" //新手引导配置
|
ETCDKEY_GUIDE = "/game/guide_config" //新手引导配置
|
||||||
|
ETCDKEY_MatchAudience = "/game/match_audience" //比赛观众
|
||||||
)
|
)
|
||||||
|
|
|
@ -135,6 +135,7 @@ type AllConfig struct {
|
||||||
*webapi.AwardLogConfig
|
*webapi.AwardLogConfig
|
||||||
// 新手引导配置
|
// 新手引导配置
|
||||||
*webapi.GuideConfig
|
*webapi.GuideConfig
|
||||||
|
MatchAudience map[int32]*webapi.MatchAudience // 比赛观众列表
|
||||||
}
|
}
|
||||||
|
|
||||||
type GlobalConfig struct {
|
type GlobalConfig struct {
|
||||||
|
@ -163,6 +164,7 @@ func (cm *ConfigMgr) GetConfig(platform string) *AllConfig {
|
||||||
EntrySwitch: make(map[int32]*webapi.EntrySwitch),
|
EntrySwitch: make(map[int32]*webapi.EntrySwitch),
|
||||||
ShopInfos: make(map[int32]*ShopInfo),
|
ShopInfos: make(map[int32]*ShopInfo),
|
||||||
ChannelSwitch: make(map[int32]*webapi.ChannelSwitchConfig),
|
ChannelSwitch: make(map[int32]*webapi.ChannelSwitchConfig),
|
||||||
|
MatchAudience: make(map[int32]*webapi.MatchAudience),
|
||||||
}
|
}
|
||||||
cm.platform[platform] = c
|
cm.platform[platform] = c
|
||||||
}
|
}
|
||||||
|
@ -356,3 +358,18 @@ func (cm *ConfigMgr) GetSkinSkillMaxLevel(plt string, skinId int32) int32 {
|
||||||
}
|
}
|
||||||
return level
|
return level
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (cm *ConfigMgr) AddMatchAudience(d *webapi.MatchAudience) {
|
||||||
|
cfg := cm.GetConfig(d.Platform)
|
||||||
|
cfg.MatchAudience[d.GetSnId()] = d
|
||||||
|
}
|
||||||
|
|
||||||
|
func (cm *ConfigMgr) DelMatchAudience(d *webapi.MatchAudience) {
|
||||||
|
delete(cm.GetConfig(d.Platform).MatchAudience, d.GetSnId())
|
||||||
|
}
|
||||||
|
|
||||||
|
// IsMatchAudience 是不是比赛场观众
|
||||||
|
func (cm *ConfigMgr) IsMatchAudience(plt string, snId int32) bool {
|
||||||
|
_, ok := cm.GetConfig(plt).MatchAudience[snId]
|
||||||
|
return ok
|
||||||
|
}
|
||||||
|
|
|
@ -4,30 +4,29 @@ import (
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// 比赛详情
|
|
||||||
type MatchAwardLog struct {
|
|
||||||
AwardNum map[string]map[int32]int32 // 奖励数量
|
|
||||||
Platform string
|
|
||||||
}
|
|
||||||
|
|
||||||
var (
|
var (
|
||||||
MatchAwardLogDBName = "log"
|
MatchAwardLogDBName = "log"
|
||||||
MatchAwardLogCollName = "log_matchawardlog"
|
MatchAwardLogCollName = "log_matchawardlog"
|
||||||
)
|
)
|
||||||
|
|
||||||
func NewMatchAwardLog() *MatchAwardLog {
|
type MatchAward struct {
|
||||||
return &MatchAwardLog{}
|
Platform string `bson:"-"`
|
||||||
|
Award map[int32]int32
|
||||||
}
|
}
|
||||||
|
|
||||||
func InsertOrUpdateMatchAwardLog(logs ...*MatchAwardLog) (err error) {
|
func UpsertMatchAward(data *MatchAward) error {
|
||||||
if rpcCli == nil {
|
if rpcCli == nil {
|
||||||
return ErrRPClientNoConn
|
return ErrRPClientNoConn
|
||||||
}
|
}
|
||||||
var ret bool
|
var ret bool
|
||||||
return rpcCli.CallWithTimeout("MatchAwardLogSvc.InsertOrUpdateMatchAwardLog", logs, &ret, time.Second*30)
|
return rpcCli.CallWithTimeout("MatchAwardSvc.UpsertMatchAward", data, &ret, time.Second*30)
|
||||||
}
|
}
|
||||||
|
|
||||||
func GetMatchAwardLog(platform string) (ret MatchAwardLog, err error) {
|
func GetMatchAward(platform string) (ret *MatchAward, err error) {
|
||||||
err = rpcCli.CallWithTimeout("MatchAwardLogSvc.GetMatchAward", platform, &ret, time.Second*30)
|
if rpcCli == nil {
|
||||||
return ret, err
|
return nil, ErrRPClientNoConn
|
||||||
|
}
|
||||||
|
ret = new(MatchAward)
|
||||||
|
err = rpcCli.CallWithTimeout("MatchAwardSvc.GetMatchAward", platform, ret, time.Second*30)
|
||||||
|
return
|
||||||
}
|
}
|
||||||
|
|
|
@ -66,7 +66,7 @@
|
||||||
- 2720~2739
|
- 2720~2739
|
||||||
|
|
||||||
#### tournament(锦标赛)
|
#### tournament(锦标赛)
|
||||||
- 2740~2759
|
- 2740~2779
|
||||||
|
|
||||||
#### RankMatch 排位赛
|
#### RankMatch 排位赛
|
||||||
- 2780~2800
|
- 2780~2800
|
||||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -20,6 +20,10 @@ enum TOURNAMENTID{
|
||||||
PACKET_TM_SCTMSeasonRank = 2754;//赛季排行榜
|
PACKET_TM_SCTMSeasonRank = 2754;//赛季排行榜
|
||||||
PACKET_TM_CSTMSeasonAward = 2755;//领取赛季奖励
|
PACKET_TM_CSTMSeasonAward = 2755;//领取赛季奖励
|
||||||
PACKET_TM_SCTMSeasonAward = 2756;//领取赛季奖励
|
PACKET_TM_SCTMSeasonAward = 2756;//领取赛季奖励
|
||||||
|
PACKET_TM_CSMatchList = 2757;// 比赛列表
|
||||||
|
PACKET_TM_SCMatchList = 2758;// 比赛列表
|
||||||
|
PACKET_TM_CSRoomList = 2759; // 比赛房间列表
|
||||||
|
PACKET_TM_SCRoomList = 2760; // 比赛房间列表
|
||||||
}
|
}
|
||||||
//比赛场场次
|
//比赛场场次
|
||||||
//PACKET_TM_CSTMInfo
|
//PACKET_TM_CSTMInfo
|
||||||
|
@ -65,6 +69,7 @@ message TMInfo{
|
||||||
repeated string OnChannelName = 21;//在哪个渠道开启
|
repeated string OnChannelName = 21;//在哪个渠道开启
|
||||||
int32 ShowId = 22; // 比赛区分
|
int32 ShowId = 22; // 比赛区分
|
||||||
int32 AwardNum = 23; //比赛奖励剩余数量
|
int32 AwardNum = 23; //比赛奖励剩余数量
|
||||||
|
int32 AudienceSwitch = 27; // 观战开关 1开启 2关闭
|
||||||
}
|
}
|
||||||
|
|
||||||
message MatchTypeInfo{
|
message MatchTypeInfo{
|
||||||
|
@ -188,3 +193,56 @@ message SCTMSeasonAward {
|
||||||
int32 Lv = 1;//段位
|
int32 Lv = 1;//段位
|
||||||
int32 Code = 2;//0成功 1失败
|
int32 Code = 2;//0成功 1失败
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//PACKET_TM_CSMatchList
|
||||||
|
message CSMatchList{
|
||||||
|
int64 MatchId = 1; // 比赛id 0表示所有比赛场
|
||||||
|
int32 Tp = 2; // 房间类型 0所有房间 1可观战房间
|
||||||
|
}
|
||||||
|
|
||||||
|
message MatchPlayer{
|
||||||
|
int32 SnId = 1; // 玩家id
|
||||||
|
string Name = 2; // 玩家名字
|
||||||
|
string HeadUrl = 3;//头像地址
|
||||||
|
int32 UseRoleId = 4;//使用的人物模型id
|
||||||
|
int32 UseSkinId = 5; // 皮肤id
|
||||||
|
int32 Rank = 6;//排名
|
||||||
|
int32 Score = 7;//分数
|
||||||
|
}
|
||||||
|
|
||||||
|
message MatchInfo{
|
||||||
|
int64 MatchId = 1; // 比赛id
|
||||||
|
int64 InstanceId = 2; // 本场比赛id
|
||||||
|
string Name = 3; // 比赛名字
|
||||||
|
int32 Round = 4; // 当前第几轮
|
||||||
|
int32 TotalRound = 5; // 总轮数
|
||||||
|
int32 RemainNum = 6; // 剩余人数
|
||||||
|
repeated MatchPlayer Players = 7; // 玩家列表
|
||||||
|
}
|
||||||
|
|
||||||
|
message SCTMMatchList{
|
||||||
|
repeated MatchInfo List = 1;
|
||||||
|
int64 MatchId = 2;
|
||||||
|
int32 Tp = 3;
|
||||||
|
}
|
||||||
|
|
||||||
|
//PACKET_TM_CSRoomList
|
||||||
|
message CSRoomList{
|
||||||
|
int64 Id = 1; // 本场比赛id 0表示所有房间
|
||||||
|
int32 Tp = 2; // 房间类型 0所有房间 1可观战房间
|
||||||
|
}
|
||||||
|
|
||||||
|
message MatchRoom{
|
||||||
|
int64 RoomId = 1; // 房间id
|
||||||
|
int64 MatchId = 2; // 比赛id
|
||||||
|
int64 InstanceId = 3; // 本场比赛id
|
||||||
|
int32 Round = 4; // 当前第几轮
|
||||||
|
int32 TotalRound = 5; // 总轮数
|
||||||
|
repeated MatchPlayer Players = 7; // 玩家列表
|
||||||
|
}
|
||||||
|
|
||||||
|
message SCRoomList{
|
||||||
|
repeated MatchRoom List = 1;
|
||||||
|
int64 Id = 2;
|
||||||
|
int32 Tp = 3;
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -490,6 +490,7 @@ message GameMatchDate {
|
||||||
int32 CardType = 24; // 手机卡类型
|
int32 CardType = 24; // 手机卡类型
|
||||||
int32 ShowId = 25; // 比赛区分
|
int32 ShowId = 25; // 比赛区分
|
||||||
int32 AwardNum = 26; //比赛奖励剩余数量
|
int32 AwardNum = 26; //比赛奖励剩余数量
|
||||||
|
int32 AudienceSwitch = 27; // 观战开关 1开启 2关闭
|
||||||
}
|
}
|
||||||
|
|
||||||
// etcd /game/game_match
|
// etcd /game/game_match
|
||||||
|
@ -890,3 +891,10 @@ message GuideConfig {
|
||||||
int32 On = 2; // 引导开关 1开启 2关闭
|
int32 On = 2; // 引导开关 1开启 2关闭
|
||||||
int32 Skip = 3; // 引导跳过开关 1开启 2关闭
|
int32 Skip = 3; // 引导跳过开关 1开启 2关闭
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// etcd /game/match_audience
|
||||||
|
message MatchAudience {
|
||||||
|
string Platform = 1; // 平台
|
||||||
|
int32 SnId = 2; // 玩家ID
|
||||||
|
int64 Ts = 3; // 时间戳
|
||||||
|
}
|
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +1,11 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"mongo.games.com/goserver/core/logger"
|
|
||||||
"mongo.games.com/goserver/core/netlib"
|
|
||||||
|
|
||||||
"mongo.games.com/game/common"
|
"mongo.games.com/game/common"
|
||||||
"mongo.games.com/game/protocol/tournament"
|
"mongo.games.com/game/protocol/tournament"
|
||||||
|
"mongo.games.com/goserver/core/logger"
|
||||||
|
"mongo.games.com/goserver/core/netlib"
|
||||||
|
"sort"
|
||||||
)
|
)
|
||||||
|
|
||||||
func CSTMInfo(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
func CSTMInfo(s *netlib.Session, packetid int, data interface{}, sid int64) error {
|
||||||
|
@ -94,9 +94,135 @@ func CSSignRace(s *netlib.Session, packetid int, data interface{}, sid int64) er
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CSMatchList(s *netlib.Session, packetId int, data interface{}, sid int64) error {
|
||||||
|
logger.Logger.Trace("CSMatchList ", data)
|
||||||
|
msg, ok := data.(*tournament.CSMatchList)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
|
if p == nil {
|
||||||
|
logger.Logger.Warnf("CSMatchList p == nil.")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
pack := &tournament.SCTMMatchList{
|
||||||
|
MatchId: msg.GetMatchId(),
|
||||||
|
Tp: msg.GetTp(),
|
||||||
|
}
|
||||||
|
|
||||||
|
audience := msg.GetTp() == 1
|
||||||
|
list := TournamentMgr.GetTmMatch(p.Platform, int32(msg.GetMatchId()), p.LastChannel, audience, 0)
|
||||||
|
|
||||||
|
// 开始时间排序
|
||||||
|
sort.Slice(list, func(i, j int) bool {
|
||||||
|
return list[i].StartTime < list[j].StartTime
|
||||||
|
})
|
||||||
|
|
||||||
|
for _, v := range list {
|
||||||
|
round := TournamentMgr.GetRound(v.SortId)
|
||||||
|
d := &tournament.MatchInfo{
|
||||||
|
MatchId: int64(v.TMId),
|
||||||
|
InstanceId: v.SortId,
|
||||||
|
Name: v.gmd.MatchName,
|
||||||
|
Round: round,
|
||||||
|
TotalRound: v.GetTotalRound(),
|
||||||
|
RemainNum: TournamentMgr.GetRemainNum(v.SortId),
|
||||||
|
}
|
||||||
|
for _, v := range TournamentMgr.GetRemainPlayer(v.SortId) {
|
||||||
|
var name, headUrl string
|
||||||
|
p := PlayerMgrSington.GetPlayerBySnId(v.SnId)
|
||||||
|
if p != nil {
|
||||||
|
name = p.Name
|
||||||
|
headUrl = p.HeadUrl
|
||||||
|
}
|
||||||
|
d.Players = append(d.Players, &tournament.MatchPlayer{
|
||||||
|
SnId: v.SnId,
|
||||||
|
Name: name,
|
||||||
|
HeadUrl: headUrl,
|
||||||
|
UseRoleId: v.RoleId,
|
||||||
|
UseSkinId: v.SkinId,
|
||||||
|
Rank: v.Rank,
|
||||||
|
Score: v.Grade,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
sort.Slice(d.Players, func(i, j int) bool {
|
||||||
|
if d.Players[i].Score > d.Players[j].Score {
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
if d.Players[i].Score < d.Players[j].Score {
|
||||||
|
return false
|
||||||
|
}
|
||||||
|
return d.Players[i].SnId < d.Players[j].SnId
|
||||||
|
})
|
||||||
|
|
||||||
|
pack.List = append(pack.List, d)
|
||||||
|
}
|
||||||
|
|
||||||
|
p.SendToClient(int(tournament.TOURNAMENTID_PACKET_TM_SCMatchList), pack)
|
||||||
|
logger.Logger.Tracef("SCMatchList %v", pack)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
func CSRoomList(s *netlib.Session, packetId int, data interface{}, sid int64) error {
|
||||||
|
logger.Logger.Trace("CSRoomList ", data)
|
||||||
|
msg, ok := data.(*tournament.CSRoomList)
|
||||||
|
if !ok {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
p := PlayerMgrSington.GetPlayer(sid)
|
||||||
|
if p == nil {
|
||||||
|
logger.Logger.Warnf("CSRoomList p == nil.")
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
pack := &tournament.SCRoomList{
|
||||||
|
Id: msg.GetId(),
|
||||||
|
Tp: msg.GetTp(),
|
||||||
|
}
|
||||||
|
|
||||||
|
audience := msg.GetTp() == 1
|
||||||
|
scenes := TournamentMgr.GetTmRoom(p.Platform, 0, p.LastChannel, audience, msg.GetId())
|
||||||
|
for _, v := range scenes {
|
||||||
|
tm := TournamentMgr.GetTm(v.matchId)
|
||||||
|
if tm == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
room := &tournament.MatchRoom{
|
||||||
|
RoomId: int64(v.sceneId),
|
||||||
|
MatchId: int64(tm.TMId),
|
||||||
|
InstanceId: tm.SortId,
|
||||||
|
Round: TournamentMgr.GetRound(tm.SortId),
|
||||||
|
TotalRound: tm.GetTotalRound(),
|
||||||
|
}
|
||||||
|
for _, v := range v.players {
|
||||||
|
if v.matchCtx == nil {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
d := &tournament.MatchPlayer{
|
||||||
|
SnId: v.matchCtx.copySnid,
|
||||||
|
Name: v.Name,
|
||||||
|
HeadUrl: v.HeadUrl,
|
||||||
|
UseRoleId: v.matchCtx.copyRoleId,
|
||||||
|
UseSkinId: v.matchCtx.copySkinId,
|
||||||
|
Rank: v.matchCtx.rank,
|
||||||
|
Score: v.matchCtx.grade,
|
||||||
|
}
|
||||||
|
room.Players = append(room.Players, d)
|
||||||
|
}
|
||||||
|
pack.List = append(pack.List, room)
|
||||||
|
}
|
||||||
|
p.SendToClient(int(tournament.TOURNAMENTID_PACKET_TM_SCRoomList), pack)
|
||||||
|
logger.Logger.Tracef("SCRoomList %v", pack)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
// 比赛信息列表
|
// 比赛配置列表
|
||||||
common.Register(int(tournament.TOURNAMENTID_PACKET_TM_CSTMInfo), tournament.CSTMInfo{}, CSTMInfo)
|
common.Register(int(tournament.TOURNAMENTID_PACKET_TM_CSTMInfo), tournament.CSTMInfo{}, CSTMInfo)
|
||||||
// 比赛报名
|
// 比赛报名
|
||||||
common.Register(int(tournament.TOURNAMENTID_PACKET_TM_CSSignRace), tournament.CSSignRace{}, CSSignRace)
|
common.Register(int(tournament.TOURNAMENTID_PACKET_TM_CSSignRace), tournament.CSSignRace{}, CSSignRace)
|
||||||
|
// 比赛中比赛列表
|
||||||
|
common.Register(int(tournament.TOURNAMENTID_PACKET_TM_CSMatchList), tournament.CSMatchList{}, CSMatchList)
|
||||||
|
// 比赛中房间列表
|
||||||
|
common.Register(int(tournament.TOURNAMENTID_PACKET_TM_CSRoomList), tournament.CSRoomList{}, CSRoomList)
|
||||||
}
|
}
|
||||||
|
|
|
@ -128,6 +128,7 @@ func (this *AwardLogManager) Update() {
|
||||||
|
|
||||||
func (this *AwardLogManager) Shutdown() {
|
func (this *AwardLogManager) Shutdown() {
|
||||||
this.Save()
|
this.Save()
|
||||||
|
module.UnregisteModule(this)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *AwardLogManager) OnHourTimer() {
|
func (this *AwardLogManager) OnHourTimer() {
|
||||||
|
|
|
@ -148,6 +148,7 @@ func (csm *CoinSceneMgr) PlayerEnter(p *Player, id int32, roomId int32, exclude
|
||||||
}
|
}
|
||||||
|
|
||||||
// AudienceEnter 观众进入房间
|
// AudienceEnter 观众进入房间
|
||||||
|
// id 场次id
|
||||||
func (csm *CoinSceneMgr) AudienceEnter(p *Player, id int32, roomId int32, exclude []int32, ischangeroom bool) hall_proto.OpResultCode {
|
func (csm *CoinSceneMgr) AudienceEnter(p *Player, id int32, roomId int32, exclude []int32, ischangeroom bool) hall_proto.OpResultCode {
|
||||||
//多平台支持
|
//多平台支持
|
||||||
platform := p.GetPlatform()
|
platform := p.GetPlatform()
|
||||||
|
|
|
@ -89,6 +89,8 @@ func init() {
|
||||||
etcd.Register(etcd.ETCDKEY_AWARD_CONFIG, webapi.AwardLogConfig{}, platformConfigEvent)
|
etcd.Register(etcd.ETCDKEY_AWARD_CONFIG, webapi.AwardLogConfig{}, platformConfigEvent)
|
||||||
// 新手引导
|
// 新手引导
|
||||||
etcd.Register(etcd.ETCDKEY_GUIDE, webapi.GuideConfig{}, platformConfigEvent)
|
etcd.Register(etcd.ETCDKEY_GUIDE, webapi.GuideConfig{}, platformConfigEvent)
|
||||||
|
// 比赛观众
|
||||||
|
etcd.Register(etcd.ETCDKEY_MatchAudience, webapi.MatchAudience{}, handlerEvent)
|
||||||
}
|
}
|
||||||
|
|
||||||
func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
func platformConfigEvent(ctx context.Context, completeKey string, isInit bool, event *clientv3.Event, data interface{}) {
|
||||||
|
@ -395,6 +397,13 @@ func handlerEvent(ctx context.Context, completeKey string, isInit bool, event *c
|
||||||
if isInit || event.Type == clientv3.EventTypePut {
|
if isInit || event.Type == clientv3.EventTypePut {
|
||||||
ActMgrSington.AddGiveConfig(config, config.Platform)
|
ActMgrSington.AddGiveConfig(config, config.Platform)
|
||||||
}
|
}
|
||||||
|
case *webapi.MatchAudience:
|
||||||
|
switch event.Type {
|
||||||
|
case clientv3.EventTypePut:
|
||||||
|
PlatformMgrSingleton.AddMatchAudience(config)
|
||||||
|
case clientv3.EventTypeDelete:
|
||||||
|
PlatformMgrSingleton.DelMatchAudience(config)
|
||||||
|
}
|
||||||
|
|
||||||
default:
|
default:
|
||||||
logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey)
|
logger.Logger.Errorf("etcd completeKey:%s, Not processed", completeKey)
|
||||||
|
|
|
@ -97,7 +97,6 @@ func (ms *MatchSceneMgr) MatchStart(tm *TmMatch) {
|
||||||
}
|
}
|
||||||
// 填充机器人
|
// 填充机器人
|
||||||
if scene != nil && !scene.IsFull() {
|
if scene != nil && !scene.IsFull() {
|
||||||
tm.RobotGradesDecline(1)
|
|
||||||
needRobotNum := scene.playerNum - len(scene.players)
|
needRobotNum := scene.playerNum - len(scene.players)
|
||||||
logger.Logger.Trace("MatchStart 填充机器人", needRobotNum)
|
logger.Logger.Trace("MatchStart 填充机器人", needRobotNum)
|
||||||
pack := &server.WGInviteMatchRob{
|
pack := &server.WGInviteMatchRob{
|
||||||
|
|
|
@ -1594,7 +1594,7 @@ func (this *Player) DgGameLogout() {
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Player) ThirdGameLogout() {
|
func (this *Player) ThirdGameLogout() {
|
||||||
_LeaveTransferThird2SystemTask(this)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Player) IsOnLine() bool {
|
func (this *Player) IsOnLine() bool {
|
||||||
|
|
|
@ -1024,6 +1024,7 @@ func (this *Scene) GetSceneName() string {
|
||||||
}
|
}
|
||||||
return "[unknow scene name]"
|
return "[unknow scene name]"
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Scene) RandRobotCnt() {
|
func (this *Scene) RandRobotCnt() {
|
||||||
if len(this.paramsEx) > 0 {
|
if len(this.paramsEx) > 0 {
|
||||||
gps := PlatformMgrSingleton.GetGameFree(this.limitPlatform.IdStr, this.paramsEx[0])
|
gps := PlatformMgrSingleton.GetGameFree(this.limitPlatform.IdStr, this.paramsEx[0])
|
||||||
|
@ -1263,3 +1264,17 @@ func (this *Scene) TryForceDelectMatchInfo() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// CanAudience 是否允许观战
|
||||||
|
func (this *Scene) CanAudience() bool {
|
||||||
|
switch {
|
||||||
|
case this.matchId > 0: // 比赛场
|
||||||
|
tm := TournamentMgr.GetTm(this.matchId)
|
||||||
|
if tm != nil {
|
||||||
|
return tm.gmd.GetAudienceSwitch() == 1
|
||||||
|
}
|
||||||
|
return false
|
||||||
|
default:
|
||||||
|
return true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
|
@ -115,6 +115,19 @@ func (m *SceneMgr) GetScenesByGameFreeId(gameFreeId int32) []*Scene {
|
||||||
return scenes
|
return scenes
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (m *SceneMgr) GetMatchRoom(sortId int64) []*Scene {
|
||||||
|
var scenes []*Scene
|
||||||
|
for _, value := range m.scenes {
|
||||||
|
if value.matchId == sortId {
|
||||||
|
s := m.GetScene(value.sceneId)
|
||||||
|
if s != nil {
|
||||||
|
scenes = append(scenes, value)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return scenes
|
||||||
|
}
|
||||||
|
|
||||||
// MarshalAllRoom 获取房间列表
|
// MarshalAllRoom 获取房间列表
|
||||||
func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode, clubId, sceneMode, sceneId int,
|
func (m *SceneMgr) MarshalAllRoom(platform string, groupId, gameId int, gameMode, clubId, sceneMode, sceneId int,
|
||||||
gameFreeId, snId int32, start, end, pageSize int32) ([]*webapi2.RoomInfo, int32, int32) {
|
gameFreeId, snId int32, start, end, pageSize int32) ([]*webapi2.RoomInfo, int32, int32) {
|
||||||
|
|
|
@ -74,6 +74,8 @@ func (tm *TmMatch) Start() {
|
||||||
tm.BroadcastMessage(int(tournament.TOURNAMENTID_PACKET_TM_SCTMStart), pack)
|
tm.BroadcastMessage(int(tournament.TOURNAMENTID_PACKET_TM_SCTMStart), pack)
|
||||||
logger.Logger.Trace("SCTMStart ", pack)
|
logger.Logger.Trace("SCTMStart ", pack)
|
||||||
|
|
||||||
|
tm.RobotGradesDecline(1)
|
||||||
|
|
||||||
//创建房间
|
//创建房间
|
||||||
timer.StartTimer(timer.TimerActionWrapper(func(h timer.TimerHandle, ud interface{}) bool {
|
timer.StartTimer(timer.TimerActionWrapper(func(h timer.TimerHandle, ud interface{}) bool {
|
||||||
MatchSceneMgrSingleton.MatchStart(tm)
|
MatchSceneMgrSingleton.MatchStart(tm)
|
||||||
|
@ -87,6 +89,10 @@ func (tm *TmMatch) Stop() {
|
||||||
logger.Logger.Trace("(this *TmMatch) Stop()")
|
logger.Logger.Trace("(this *TmMatch) Stop()")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (tm *TmMatch) GetTotalRound() int32 {
|
||||||
|
return int32(len(tm.gmd.GetMatchPromotion()) - 1)
|
||||||
|
}
|
||||||
|
|
||||||
func (tm *TmMatch) BroadcastMessage(packetId int, rawPack interface{}) {
|
func (tm *TmMatch) BroadcastMessage(packetId int, rawPack interface{}) {
|
||||||
mgs := make(map[*netlib.Session][]*srvproto.MCSessionUnion)
|
mgs := make(map[*netlib.Session][]*srvproto.MCSessionUnion)
|
||||||
for _, tmp := range tm.TmPlayer {
|
for _, tmp := range tm.TmPlayer {
|
||||||
|
|
|
@ -24,13 +24,8 @@ import (
|
||||||
"mongo.games.com/game/webapi"
|
"mongo.games.com/game/webapi"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
|
||||||
module.RegisteModule(TournamentMgr, time.Second, 0)
|
|
||||||
ClockMgrSington.RegisteSinker(TournamentMgr)
|
|
||||||
}
|
|
||||||
|
|
||||||
const (
|
|
||||||
// 如果这里比赛类型没有,默认是锦标赛
|
// 如果这里比赛类型没有,默认是锦标赛
|
||||||
|
const (
|
||||||
MatchTypeNormal = iota + 1 // 锦标赛
|
MatchTypeNormal = iota + 1 // 锦标赛
|
||||||
MatchTypeChampion // 冠军赛/实物赛
|
MatchTypeChampion // 冠军赛/实物赛
|
||||||
MatchTypeVIP // vip比赛
|
MatchTypeVIP // vip比赛
|
||||||
|
@ -54,6 +49,11 @@ const (
|
||||||
DaiDing = 2 // 待定
|
DaiDing = 2 // 待定
|
||||||
)
|
)
|
||||||
|
|
||||||
|
func init() {
|
||||||
|
module.RegisteModule(TournamentMgr, time.Second, 0)
|
||||||
|
ClockMgrSington.RegisteSinker(TournamentMgr)
|
||||||
|
}
|
||||||
|
|
||||||
var TournamentMgr = NewTournament()
|
var TournamentMgr = NewTournament()
|
||||||
|
|
||||||
type PerRankInfo struct {
|
type PerRankInfo struct {
|
||||||
|
@ -78,8 +78,8 @@ type SignupInfo struct {
|
||||||
|
|
||||||
type PlayerRoundInfo struct {
|
type PlayerRoundInfo struct {
|
||||||
players []*PlayerMatchContext // 本轮结算信息
|
players []*PlayerMatchContext // 本轮结算信息
|
||||||
ranks []*PlayerMatchContext // 本来排名
|
ranks []*PlayerMatchContext // 本轮排名
|
||||||
num int // 本来完成人数
|
num int // 本轮完成人数
|
||||||
}
|
}
|
||||||
|
|
||||||
type Tournament struct {
|
type Tournament struct {
|
||||||
|
@ -91,7 +91,7 @@ type Tournament struct {
|
||||||
playerWaitStart map[int32]int64 // 等待时间 玩家Id:等待时长秒
|
playerWaitStart map[int32]int64 // 等待时间 玩家Id:等待时长秒
|
||||||
matches map[int32]map[int64]*TmMatch // 开始比赛的数据,比赛配置Id:比赛顺序序号:一场开始的比赛数据
|
matches map[int32]map[int64]*TmMatch // 开始比赛的数据,比赛配置Id:比赛顺序序号:一场开始的比赛数据
|
||||||
players map[int64]map[int32]*PlayerMatchContext // 比赛中玩家 比赛顺序序号:玩家id:玩家信息
|
players map[int64]map[int32]*PlayerMatchContext // 比赛中玩家 比赛顺序序号:玩家id:玩家信息
|
||||||
roundPlayers map[int64]map[int32]*PlayerRoundInfo // 每轮比赛数据 比赛顺序序号:第几轮
|
roundPlayers map[int64]map[int32]*PlayerRoundInfo // 每轮比赛数据备份 比赛顺序序号:第几轮
|
||||||
finalPerRank map[int64][]*PerRankInfo // 本场比赛排名,每淘汰一位记录一位,最后记录决赛玩家 比赛顺序序号
|
finalPerRank map[int64][]*PerRankInfo // 本场比赛排名,每淘汰一位记录一位,最后记录决赛玩家 比赛顺序序号
|
||||||
MatchAwardNum map[string]map[int32]int32 // 比赛配置Id:比赛奖励次數
|
MatchAwardNum map[string]map[int32]int32 // 比赛配置Id:比赛奖励次數
|
||||||
}
|
}
|
||||||
|
@ -146,6 +146,7 @@ func (this *Tournament) checkData(cfg *webapiproto.GameMatchDate) bool {
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 记录淘汰人员
|
||||||
func (this *Tournament) addFinalPlayer(sortId int64, p *PerRankInfo) {
|
func (this *Tournament) addFinalPlayer(sortId int64, p *PerRankInfo) {
|
||||||
if this.finalPerRank[sortId] == nil {
|
if this.finalPerRank[sortId] == nil {
|
||||||
this.finalPerRank[sortId] = []*PerRankInfo{}
|
this.finalPerRank[sortId] = []*PerRankInfo{}
|
||||||
|
@ -153,6 +154,7 @@ func (this *Tournament) addFinalPlayer(sortId int64, p *PerRankInfo) {
|
||||||
this.finalPerRank[sortId] = append(this.finalPerRank[sortId], p)
|
this.finalPerRank[sortId] = append(this.finalPerRank[sortId], p)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 查询一场比赛某轮的历史数据
|
||||||
func (this *Tournament) getRoundPlayer(sortId int64, round int32) *PlayerRoundInfo {
|
func (this *Tournament) getRoundPlayer(sortId int64, round int32) *PlayerRoundInfo {
|
||||||
_, ok := this.roundPlayers[sortId]
|
_, ok := this.roundPlayers[sortId]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -168,6 +170,96 @@ func (this *Tournament) getRoundPlayer(sortId int64, round int32) *PlayerRoundIn
|
||||||
return v
|
return v
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetRemainNum 剩余比赛人数
|
||||||
|
func (this *Tournament) GetRemainNum(sortId int64) int32 {
|
||||||
|
tm := this.GetTm(sortId)
|
||||||
|
if tm == nil {
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
round := this.GetRound(sortId)
|
||||||
|
l := tm.gmd.GetMatchPromotion()
|
||||||
|
if round <= int32(len(l)) {
|
||||||
|
return l[round-1]
|
||||||
|
}
|
||||||
|
return 0
|
||||||
|
}
|
||||||
|
|
||||||
|
type MatchPlayerInfo struct {
|
||||||
|
SnId int32
|
||||||
|
RoleId int32
|
||||||
|
SkinId int32
|
||||||
|
Rank int32
|
||||||
|
Grade int32
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetRemainPlayer 未淘汰的人
|
||||||
|
func (this *Tournament) GetRemainPlayer(sortId int64) []*MatchPlayerInfo {
|
||||||
|
tm := this.GetTm(sortId)
|
||||||
|
if tm == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
round := this.GetRound(sortId)
|
||||||
|
useRobot := this.IsRobotOn(tm.gmd)
|
||||||
|
|
||||||
|
var ret []*MatchPlayerInfo
|
||||||
|
|
||||||
|
realPlayer := func() {
|
||||||
|
for _, v := range tm.TmPlayer {
|
||||||
|
p := PlayerMgrSington.GetPlayerBySnId(v.SnId)
|
||||||
|
if p != nil {
|
||||||
|
ret = append(ret, &MatchPlayerInfo{
|
||||||
|
SnId: v.SnId,
|
||||||
|
RoleId: p.GetRoleId(),
|
||||||
|
SkinId: p.Skin.ModId,
|
||||||
|
Grade: 1000,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
robotPlayer := func(n int) {
|
||||||
|
for _, v := range tm.robotGrades[n] {
|
||||||
|
ret = append(ret, &MatchPlayerInfo{
|
||||||
|
SnId: v.copySnid,
|
||||||
|
RoleId: v.copyRoleId,
|
||||||
|
SkinId: v.CopySkinId,
|
||||||
|
Grade: v.grade,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if round <= 1 {
|
||||||
|
if useRobot {
|
||||||
|
robotPlayer(0)
|
||||||
|
realPlayer()
|
||||||
|
} else {
|
||||||
|
realPlayer()
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if useRobot {
|
||||||
|
robotPlayer(int(round - 1))
|
||||||
|
} else {
|
||||||
|
if this.roundPlayers[sortId] != nil {
|
||||||
|
d := this.roundPlayers[sortId][round-1]
|
||||||
|
if d != nil {
|
||||||
|
for _, v := range d.ranks {
|
||||||
|
ret = append(ret, &MatchPlayerInfo{
|
||||||
|
SnId: v.copySnid,
|
||||||
|
RoleId: v.copyRoleId,
|
||||||
|
SkinId: v.copySkinId,
|
||||||
|
Grade: v.grade,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
// GetSignUpPlayers 获取报名人员
|
||||||
|
// id 比赛配置id
|
||||||
func (this *Tournament) GetSignUpPlayers(platform string, id int32) map[int32]*TmPlayer {
|
func (this *Tournament) GetSignUpPlayers(platform string, id int32) map[int32]*TmPlayer {
|
||||||
v, ok := this.signupPlayers[platform]
|
v, ok := this.signupPlayers[platform]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -194,7 +286,7 @@ func (this *Tournament) UpdateData(init bool, data *webapiproto.GameMatchDateLis
|
||||||
this.FixMatchTimeStamp(v)
|
this.FixMatchTimeStamp(v)
|
||||||
configs[v.Id] = v
|
configs[v.Id] = v
|
||||||
} else {
|
} else {
|
||||||
logger.Logger.Error("GameMatchDate error: ", v)
|
logger.Logger.Errorf("GameMatchDate check error: %v", v)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -239,14 +331,6 @@ func (this *Tournament) UpdateData(init bool, data *webapiproto.GameMatchDateLis
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.GameMatchDateList[data.Platform] = configs
|
this.GameMatchDateList[data.Platform] = configs
|
||||||
//拉取数据
|
|
||||||
if this.MatchAwardNum == nil {
|
|
||||||
ret, err := model.GetMatchAwardLog(data.Platform)
|
|
||||||
logger.Logger.Tracef("ret = %v,err = %v", ret, err)
|
|
||||||
if err == nil {
|
|
||||||
this.MatchAwardNum = ret.AwardNum
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// 通知平台玩家数据更新
|
// 通知平台玩家数据更新
|
||||||
if !init {
|
if !init {
|
||||||
//todo 优化
|
//todo 优化
|
||||||
|
@ -796,6 +880,7 @@ func (this *Tournament) CreatePlayerMatchContext(p *Player, m *TmMatch, seq int)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 是否淘汰
|
||||||
func (this *Tournament) isOut(sortId int64, snid int32) bool {
|
func (this *Tournament) isOut(sortId int64, snid int32) bool {
|
||||||
if this.finalPerRank[sortId] != nil {
|
if this.finalPerRank[sortId] != nil {
|
||||||
for _, info := range this.finalPerRank[sortId] {
|
for _, info := range this.finalPerRank[sortId] {
|
||||||
|
@ -1516,6 +1601,72 @@ func (this *Tournament) GetSCTMInfosPack(platform, channelName string) *tourname
|
||||||
return pack
|
return pack
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetTmMatch 查询比赛中的比赛
|
||||||
|
func (this *Tournament) GetTmMatch(plt string, matchId int32, channelName string, audience bool, sortId int64) []*TmMatch {
|
||||||
|
matches := this.GetAllMatchInfo(plt)
|
||||||
|
if matches == nil {
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
|
var ids []int32
|
||||||
|
for id, info := range matches {
|
||||||
|
if info == nil || info.MatchSwitch != 1 {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if matchId > 0 && id != matchId {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if channelName != "" && !common.InMatchChannel(info.OnChannelName, channelName) {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if info.GetAudienceSwitch() == 1 != audience {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ids = append(ids, id)
|
||||||
|
}
|
||||||
|
|
||||||
|
var ret []*TmMatch
|
||||||
|
if sortId > 0 {
|
||||||
|
for _, v := range ids {
|
||||||
|
d := this.matches[v]
|
||||||
|
if d != nil {
|
||||||
|
r, ok := d[sortId]
|
||||||
|
if ok && r != nil {
|
||||||
|
return []*TmMatch{r}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
for _, v := range ids {
|
||||||
|
for _, vv := range this.matches[v] {
|
||||||
|
ret = append(ret, vv)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
|
func (this *Tournament) GetTmRoom(plt string, matchId int32, channelName string, audience bool, sortId int64) []*Scene {
|
||||||
|
tm := this.GetTmMatch(plt, matchId, channelName, audience, sortId)
|
||||||
|
|
||||||
|
sort.Slice(tm, func(i, j int) bool {
|
||||||
|
return tm[i].SortId < tm[j].SortId
|
||||||
|
})
|
||||||
|
|
||||||
|
var ret []*Scene
|
||||||
|
for _, v := range tm {
|
||||||
|
d := SceneMgrSingleton.GetMatchRoom(v.SortId)
|
||||||
|
sort.Slice(d, func(i, j int) bool {
|
||||||
|
return d[i].createTime.Before(d[j].createTime)
|
||||||
|
})
|
||||||
|
ret = append(ret, d...)
|
||||||
|
}
|
||||||
|
|
||||||
|
return ret
|
||||||
|
}
|
||||||
|
|
||||||
func (this *Tournament) MakeMatchLog(platform string, tmId int32, sortId int64) *model.MatchLog {
|
func (this *Tournament) MakeMatchLog(platform string, tmId int32, sortId int64) *model.MatchLog {
|
||||||
gameMatchDate := this.GetMatchInfo(platform, tmId, sortId)
|
gameMatchDate := this.GetMatchInfo(platform, tmId, sortId)
|
||||||
if gameMatchDate == nil {
|
if gameMatchDate == nil {
|
||||||
|
@ -1608,6 +1759,20 @@ func (this *Tournament) ModuleName() string {
|
||||||
|
|
||||||
func (this *Tournament) Init() {
|
func (this *Tournament) Init() {
|
||||||
logger.Logger.Trace("Tournament Init")
|
logger.Logger.Trace("Tournament Init")
|
||||||
|
for _, v := range PlatformMgrSingleton.GetPlatforms() {
|
||||||
|
if v == nil || v.IdStr == "0" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
ret, err := model.GetMatchAward(v.IdStr)
|
||||||
|
if err != nil {
|
||||||
|
logger.Logger.Tracef("GetMatchAward error %v", err)
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
if this.MatchAwardNum == nil {
|
||||||
|
this.MatchAwardNum = make(map[string]map[int32]int32)
|
||||||
|
}
|
||||||
|
this.MatchAwardNum[v.IdStr] = ret.Award
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Tournament) Update() {
|
func (this *Tournament) Update() {
|
||||||
|
@ -1650,35 +1815,42 @@ func (this *Tournament) Update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func (this *Tournament) OnDayTimer() {
|
func (this *Tournament) OnDayTimer() {
|
||||||
this.MatchAwardNum = make(map[string]map[int32]int32)
|
for k := range this.MatchAwardNum {
|
||||||
this.Save()
|
this.MatchAwardNum[k] = make(map[int32]int32)
|
||||||
logger.Logger.Trace("比赛场每日库存清理!!!")
|
|
||||||
}
|
}
|
||||||
|
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
||||||
|
this.SaveMatchAward()
|
||||||
|
return nil
|
||||||
|
}), nil, "save_match_award_times").Start()
|
||||||
|
}
|
||||||
|
|
||||||
func (this *Tournament) Shutdown() {
|
func (this *Tournament) Shutdown() {
|
||||||
// 保存数据
|
this.SaveMatchAward()
|
||||||
this.Save()
|
module.UnregisteModule(this)
|
||||||
}
|
}
|
||||||
func (this *Tournament) Save() {
|
|
||||||
logger.Logger.Info("保存比赛场每日奖励数据!!!!", this.MatchAwardNum)
|
func (this *Tournament) SaveMatchAward() {
|
||||||
if this.MatchAwardNum == nil {
|
if this.MatchAwardNum == nil {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
for platform, _ := range this.MatchAwardNum {
|
logger.Logger.Tracef("保存比赛场奖励领取次数")
|
||||||
matchAwardLog := model.NewMatchAwardLog()
|
for platform, v := range this.MatchAwardNum {
|
||||||
matchAwardLog.AwardNum = this.MatchAwardNum
|
d := &model.MatchAward{
|
||||||
matchAwardLog.Platform = platform
|
Platform: platform,
|
||||||
task.New(nil, task.CallableWrapper(func(o *basic.Object) interface{} {
|
Award: make(map[int32]int32),
|
||||||
err := model.InsertOrUpdateMatchAwardLog(matchAwardLog)
|
}
|
||||||
|
for k, vv := range v {
|
||||||
|
d.Award[k] = vv
|
||||||
|
}
|
||||||
|
err := model.UpsertMatchAward(d)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
logger.Logger.Error("saveMatchAwardLog error %v", err)
|
logger.Logger.Errorf("SaveMatchAward error %v", err)
|
||||||
return err
|
|
||||||
}
|
|
||||||
return nil
|
|
||||||
}), task.CompleteNotifyWrapper(func(data interface{}, tt task.Task) {
|
|
||||||
})).StartByFixExecutor("saveMatchAwardLogTask")
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (this *Tournament) getWeekDay() int {
|
func (this *Tournament) getWeekDay() int {
|
||||||
getWeekNum := func(t time.Time) int {
|
getWeekNum := func(t time.Time) int {
|
||||||
strWeek := []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
|
strWeek := []string{"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"}
|
||||||
|
@ -1711,7 +1883,7 @@ func (this *Tournament) FixMatchTimeStamp(d *webapiproto.GameMatchDate) {
|
||||||
week := this.getWeekDay()
|
week := this.getWeekDay()
|
||||||
st := time.Unix(d.MatchTimeStamp[0], 0).In(l)
|
st := time.Unix(d.MatchTimeStamp[0], 0).In(l)
|
||||||
et := time.Unix(d.MatchTimeStamp[1], 0).In(l)
|
et := time.Unix(d.MatchTimeStamp[1], 0).In(l)
|
||||||
logger.Logger.Tracef("FixMatchTimeStamp 1 id:%v now:%v week:%v start:%v end:%v", d.Id, bTs, bTs.Weekday(), st, et)
|
//logger.Logger.Tracef("FixMatchTimeStamp 1 id:%v now:%v week:%v start:%v end:%v", d.Id, bTs, bTs.Weekday(), st, et)
|
||||||
// 重复时间段比赛时间
|
// 重复时间段比赛时间
|
||||||
for _, v := range d.MatchTimeWeek {
|
for _, v := range d.MatchTimeWeek {
|
||||||
if v == int32(week) {
|
if v == int32(week) {
|
||||||
|
@ -1723,8 +1895,7 @@ func (this *Tournament) FixMatchTimeStamp(d *webapiproto.GameMatchDate) {
|
||||||
|
|
||||||
st = time.Unix(d.MatchTimeStamp[0], 0).In(l)
|
st = time.Unix(d.MatchTimeStamp[0], 0).In(l)
|
||||||
et = time.Unix(d.MatchTimeStamp[1], 0).In(l)
|
et = time.Unix(d.MatchTimeStamp[1], 0).In(l)
|
||||||
logger.Logger.Tracef("FixMatchTimeStamp 2 id:%v now:%v week:%v start:%v end:%v", d.Id, bTs, bTs.Weekday(), st, et)
|
//logger.Logger.Tracef("FixMatchTimeStamp 2 id:%v now:%v week:%v start:%v end:%v", d.Id, bTs, bTs.Weekday(), st, et)
|
||||||
|
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1738,6 +1909,8 @@ func (this *Tournament) OnHourTimer() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GetMatchAwardNum 剩余奖励数量
|
||||||
|
// id 比赛配置id
|
||||||
func (this *Tournament) GetMatchAwardNum(platform string, id int32) int32 {
|
func (this *Tournament) GetMatchAwardNum(platform string, id int32) int32 {
|
||||||
var num int32
|
var num int32
|
||||||
if this.MatchAwardNum != nil && this.MatchAwardNum[platform] != nil {
|
if this.MatchAwardNum != nil && this.MatchAwardNum[platform] != nil {
|
||||||
|
@ -1761,3 +1934,11 @@ func (this *Tournament) GetMatchAwardNum(platform string, id int32) int32 {
|
||||||
}
|
}
|
||||||
return num
|
return num
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (this *Tournament) GetRound(sortId int64) int32 {
|
||||||
|
d, ok := this.roundPlayers[sortId]
|
||||||
|
if !ok || d == nil {
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
return int32(len(d))
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue