比赛日志用开始比赛时备份的配置不能用最新配置
This commit is contained in:
parent
d7b72cd6ea
commit
41361621ef
|
@ -22,6 +22,9 @@ func MatchLogCollection(plt string) *mongo.Collection {
|
||||||
c, first := s.DB().C(model.MatchLogCollName)
|
c, first := s.DB().C(model.MatchLogCollName)
|
||||||
if first {
|
if first {
|
||||||
c.EnsureIndex(mgo.Index{Key: []string{"gamefreeid"}, Background: true, Sparse: true})
|
c.EnsureIndex(mgo.Index{Key: []string{"gamefreeid"}, Background: true, Sparse: true})
|
||||||
|
c.EnsureIndex(mgo.Index{Key: []string{"matchid"}, Background: true, Sparse: true})
|
||||||
|
c.EnsureIndex(mgo.Index{Key: []string{"starttime"}, Background: true, Sparse: true})
|
||||||
|
c.EnsureIndex(mgo.Index{Key: []string{"endtime"}, Background: true, Sparse: true})
|
||||||
}
|
}
|
||||||
return c
|
return c
|
||||||
}
|
}
|
||||||
|
|
|
@ -38,6 +38,7 @@ type MatchLog struct {
|
||||||
StartTime time.Time //开始时间
|
StartTime time.Time //开始时间
|
||||||
EndTime time.Time //结束时间
|
EndTime time.Time //结束时间
|
||||||
Players []*MatchPlayer //参赛人员数据
|
Players []*MatchPlayer //参赛人员数据
|
||||||
|
SortId int64 // 本场id
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
|
@ -59,6 +59,8 @@ func CSSignRace(s *netlib.Session, packetid int, data interface{}, sid int64) er
|
||||||
pack.RetCode = code //0成功 1重复报名 2比赛没有开启 3道具不足 4不在报名时间段 5金币不足 6钻石不足
|
pack.RetCode = code //0成功 1重复报名 2比赛没有开启 3道具不足 4不在报名时间段 5金币不足 6钻石不足
|
||||||
}
|
}
|
||||||
|
|
||||||
|
logger.Logger.Infof("player(%v) match(%v) SignUp is ok.", p.SnId, tmId)
|
||||||
|
|
||||||
if code == int32(tournament.SignRaceCode_OPRC_Close) ||
|
if code == int32(tournament.SignRaceCode_OPRC_Close) ||
|
||||||
code == int32(tournament.SignRaceCode_OPRC_Time) {
|
code == int32(tournament.SignRaceCode_OPRC_Time) {
|
||||||
TournamentMgr.CancelSignUpAll(platform, tmId)
|
TournamentMgr.CancelSignUpAll(platform, tmId)
|
||||||
|
@ -73,7 +75,7 @@ func CSSignRace(s *netlib.Session, packetid int, data interface{}, sid int64) er
|
||||||
logger.Logger.Trace("SCSignRace ", pack)
|
logger.Logger.Trace("SCSignRace ", pack)
|
||||||
|
|
||||||
// 检查是否可以开始比赛(关闭机器人时,比赛开赛)
|
// 检查是否可以开始比赛(关闭机器人时,比赛开赛)
|
||||||
if code == 0 && signSucc && !TournamentMgr.IsUseRobot(platform, tmId) {
|
if code == 0 && signSucc && !TournamentMgr.IsUseRobot(platform, tmId, 0) {
|
||||||
if TournamentMgr.CanStart(platform, tmId) {
|
if TournamentMgr.CanStart(platform, tmId) {
|
||||||
TournamentMgr.Start(platform, tmId)
|
TournamentMgr.Start(platform, tmId)
|
||||||
}
|
}
|
||||||
|
|
|
@ -246,7 +246,18 @@ func (this *Tournament) UpdateData(init bool, data *webapiproto.GameMatchDateLis
|
||||||
}
|
}
|
||||||
|
|
||||||
// GetMatchInfo 比赛配置
|
// GetMatchInfo 比赛配置
|
||||||
func (this *Tournament) GetMatchInfo(platform string, tmId int32) *webapiproto.GameMatchDate {
|
// !!!没有sortId会获取最新配置
|
||||||
|
func (this *Tournament) GetMatchInfo(platform string, tmId int32, sortId int64) *webapiproto.GameMatchDate {
|
||||||
|
if sortId > 0 {
|
||||||
|
v := this.matches[tmId]
|
||||||
|
if v != nil {
|
||||||
|
vv := v[sortId]
|
||||||
|
if vv != nil {
|
||||||
|
return vv.gmd
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return nil
|
||||||
|
}
|
||||||
if list, ok := this.GameMatchDateList[platform]; ok {
|
if list, ok := this.GameMatchDateList[platform]; ok {
|
||||||
if gmd, ok1 := list[tmId]; ok1 {
|
if gmd, ok1 := list[tmId]; ok1 {
|
||||||
return gmd
|
return gmd
|
||||||
|
@ -257,7 +268,7 @@ func (this *Tournament) GetMatchInfo(platform string, tmId int32) *webapiproto.G
|
||||||
|
|
||||||
// MatchSwitch 比赛开关
|
// MatchSwitch 比赛开关
|
||||||
func (this *Tournament) MatchSwitch(platform string, tmId int32) bool {
|
func (this *Tournament) MatchSwitch(platform string, tmId int32) bool {
|
||||||
return this.IsMatchOn(this.GetMatchInfo(platform, tmId))
|
return this.IsMatchOn(this.GetMatchInfo(platform, tmId, 0))
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsMatchOn 比赛开关
|
// IsMatchOn 比赛开关
|
||||||
|
@ -266,8 +277,8 @@ func (this *Tournament) IsMatchOn(match *webapiproto.GameMatchDate) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsUseRobot 是否用机器人
|
// IsUseRobot 是否用机器人
|
||||||
func (this *Tournament) IsUseRobot(platform string, tmId int32) bool {
|
func (this *Tournament) IsUseRobot(platform string, tmId int32, sortId int64) bool {
|
||||||
return this.IsRobotOn(this.GetMatchInfo(platform, tmId))
|
return this.IsRobotOn(this.GetMatchInfo(platform, tmId, sortId))
|
||||||
}
|
}
|
||||||
|
|
||||||
// IsRobotOn 是否用机器人
|
// IsRobotOn 是否用机器人
|
||||||
|
@ -387,7 +398,7 @@ func (this *Tournament) IsMatchWaiting(platform string, snId int32) (bool, int32
|
||||||
// 报名费用 0成功 3道具不足 5金币不足 6钻石不足 7免费次数不足
|
// 报名费用 0成功 3道具不足 5金币不足 6钻石不足 7免费次数不足
|
||||||
func (this *Tournament) signUpCost(p *Player, tmId int32, cost bool) (bool, int32) {
|
func (this *Tournament) signUpCost(p *Player, tmId int32, cost bool) (bool, int32) {
|
||||||
logger.Logger.Tracef("signUpCost 比赛id:%v 玩家:%v 报名:%v", tmId, p.SnId, cost)
|
logger.Logger.Tracef("signUpCost 比赛id:%v 玩家:%v 报名:%v", tmId, p.SnId, cost)
|
||||||
gmd := this.GetMatchInfo(p.Platform, tmId)
|
gmd := this.GetMatchInfo(p.Platform, tmId, 0)
|
||||||
if gmd == nil || p.IsRob {
|
if gmd == nil || p.IsRob {
|
||||||
return true, 0
|
return true, 0
|
||||||
}
|
}
|
||||||
|
@ -482,7 +493,7 @@ func (this *Tournament) signUpCost(p *Player, tmId int32, cost bool) (bool, int3
|
||||||
func (this *Tournament) SignUp(tmId int32, p *Player) (bool, int32) {
|
func (this *Tournament) SignUp(tmId int32, p *Player) (bool, int32) {
|
||||||
logger.Logger.Tracef("报名 比赛id:%v 玩家:%v", tmId, p.SnId)
|
logger.Logger.Tracef("报名 比赛id:%v 玩家:%v", tmId, p.SnId)
|
||||||
// 开启
|
// 开启
|
||||||
info := this.GetMatchInfo(p.Platform, tmId)
|
info := this.GetMatchInfo(p.Platform, tmId, 0)
|
||||||
if !this.IsMatchOn(info) {
|
if !this.IsMatchOn(info) {
|
||||||
return false, int32(tournament.SignRaceCode_OPRC_Close)
|
return false, int32(tournament.SignRaceCode_OPRC_Close)
|
||||||
}
|
}
|
||||||
|
@ -636,7 +647,7 @@ func (this *Tournament) ForceQuit(platform string, snId int32) {
|
||||||
func (this *Tournament) CanStart(platform string, tmId int32) bool {
|
func (this *Tournament) CanStart(platform string, tmId int32) bool {
|
||||||
if this.signupPlayers != nil && this.signupPlayers[platform] != nil {
|
if this.signupPlayers != nil && this.signupPlayers[platform] != nil {
|
||||||
if signInfo, ok := this.signupPlayers[platform][tmId]; ok {
|
if signInfo, ok := this.signupPlayers[platform][tmId]; ok {
|
||||||
matchInfo := this.GetMatchInfo(signInfo.Platform, tmId)
|
matchInfo := this.GetMatchInfo(signInfo.Platform, tmId, 0)
|
||||||
if matchInfo != nil {
|
if matchInfo != nil {
|
||||||
n := 0
|
n := 0
|
||||||
for _, v := range signInfo.signup {
|
for _, v := range signInfo.signup {
|
||||||
|
@ -669,7 +680,7 @@ func (this *Tournament) Start(platform string, tmId int32) {
|
||||||
this.matches[tmId] = make(map[int64]*TmMatch)
|
this.matches[tmId] = make(map[int64]*TmMatch)
|
||||||
}
|
}
|
||||||
|
|
||||||
matchInfo := this.GetMatchInfo(platform, tmId)
|
matchInfo := this.GetMatchInfo(platform, tmId, 0)
|
||||||
signInfo := this.signupPlayers[platform][tmId]
|
signInfo := this.signupPlayers[platform][tmId]
|
||||||
|
|
||||||
if matchInfo == nil || signInfo == nil || len(signInfo.signup) == 0 {
|
if matchInfo == nil || signInfo == nil || len(signInfo.signup) == 0 {
|
||||||
|
@ -1409,7 +1420,11 @@ func (this *Tournament) GetSCTMInfosPack(platform, channelName string) *tourname
|
||||||
}
|
}
|
||||||
|
|
||||||
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)
|
gameMatchDate := this.GetMatchInfo(platform, tmId, sortId)
|
||||||
|
if gameMatchDate == nil {
|
||||||
|
logger.Logger.Errorf("MakeMatchLog gameMatchDate == nil tmId:%d sortId:%d", tmId, sortId)
|
||||||
|
return nil
|
||||||
|
}
|
||||||
matchLog := model.NewMatchLog()
|
matchLog := model.NewMatchLog()
|
||||||
_, ok := this.roundPlayers[sortId]
|
_, ok := this.roundPlayers[sortId]
|
||||||
if !ok {
|
if !ok {
|
||||||
|
@ -1463,6 +1478,7 @@ func (this *Tournament) MakeMatchLog(platform string, tmId int32, sortId int64)
|
||||||
matchLog.GameFreeId = gameMatchDate.GameFreeId
|
matchLog.GameFreeId = gameMatchDate.GameFreeId
|
||||||
matchLog.StartTime = time.Unix(this.matches[tmId][sortId].StartTime, 0)
|
matchLog.StartTime = time.Unix(this.matches[tmId][sortId].StartTime, 0)
|
||||||
matchLog.EndTime = time.Now()
|
matchLog.EndTime = time.Now()
|
||||||
|
matchLog.SortId = sortId
|
||||||
return matchLog
|
return matchLog
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1495,7 +1511,7 @@ func (this *Tournament) Update() {
|
||||||
if info == nil || info.Ts <= 0 {
|
if info == nil || info.Ts <= 0 {
|
||||||
continue
|
continue
|
||||||
}
|
}
|
||||||
matchInfo := this.GetMatchInfo(info.Platform, info.TmId)
|
matchInfo := this.GetMatchInfo(info.Platform, info.TmId, 0)
|
||||||
if this.IsMatchOn(matchInfo) && !this.IsOutTime(matchInfo) && this.IsRobotOn(matchInfo) {
|
if this.IsMatchOn(matchInfo) && !this.IsOutTime(matchInfo) && this.IsRobotOn(matchInfo) {
|
||||||
needTime := this.playerWaitStart[snId]
|
needTime := this.playerWaitStart[snId]
|
||||||
if time.Now().Unix()-info.Ts > needTime {
|
if time.Now().Unix()-info.Ts > needTime {
|
||||||
|
|
Loading…
Reference in New Issue