diff --git a/server/matchserver/common/types.go b/server/matchserver/common/types.go index 0e0df053..8afe4a7e 100644 --- a/server/matchserver/common/types.go +++ b/server/matchserver/common/types.go @@ -43,6 +43,8 @@ type Team interface { SendStateNotify() IsLeader(Player) bool Started() bool + CanStartGame(Player) bool + StartGame() } type TeamMgr interface { diff --git a/server/matchserver/constant/constant.go b/server/matchserver/constant/constant.go index b60221c9..66600e71 100644 --- a/server/matchserver/constant/constant.go +++ b/server/matchserver/constant/constant.go @@ -17,9 +17,9 @@ const ( ) const ( - TEAM_STAET_INIT = 0 - TEAM_STAET_STARTED = 1 - TEAM_STAET_MATCHING = 2 + TEAM_STATE_INIT = 0 + TEAM_STATE_STARTED = 1 + TEAM_STATE_MATCHING = 2 ) const ( diff --git a/server/matchserver/player/player.go b/server/matchserver/player/player.go index f3c5f0cc..7bc4832f 100644 --- a/server/matchserver/player/player.go +++ b/server/matchserver/player/player.go @@ -186,7 +186,9 @@ func (this *player) CMHandoverLeader(hdr *f5.MsgHdr, msg *cs.CMHandoverLeader) { func (this *player) CMStartGame(hdr *f5.MsgHdr, msg *cs.CMStartGame) { rspMsg := &cs.SMStartGame{} if !this.GetTeam().Started() { - + if this.GetTeam().CanStartGame(this) { + this.GetTeam().StartGame() + } } this.SendMsg(rspMsg) } diff --git a/server/matchserver/team/team.go b/server/matchserver/team/team.go index e232ae9a..1150ef3a 100644 --- a/server/matchserver/team/team.go +++ b/server/matchserver/team/team.go @@ -93,7 +93,18 @@ func (this *team) IsCopy() bool { } func (this *team) Started() bool { - return this.state == constant.TEAM_STAET_STARTED + return this.state == constant.TEAM_STATE_STARTED +} + +func (this *team) CanStartGame(hum common.Player) bool { + if !this.Started() { + this.state = constant.TEAM_STATE_STARTED + } + return true +} + +func (this *team) StartGame() { + } func (this *team) broadcastMsg(msg proto.Message) { @@ -125,7 +136,7 @@ func (this *team) SendStateNotify() { func newTeam() *team { t := new(team) - t.state = constant.TEAM_STAET_INIT + t.state = constant.TEAM_STATE_INIT t.stateNotifyMsg = &cs.SMTeamStateNotify{} t.stateNotifyMsg.JoinMsg = &cs.MFJoinMsg{} t.accountIdHash = map[string]common.Player{}