This commit is contained in:
aozhiwei 2024-03-14 11:44:13 +08:00
parent e6240ed65d
commit 7b9c30bd9b
3 changed files with 17 additions and 3 deletions

View File

@ -70,6 +70,7 @@ type Player interface {
IsOnline() bool IsOnline() bool
GetTeam() Team GetTeam() Team
SetTeam(Team) SetTeam(Team)
IsReady() bool
FillMFTeamMember(*cs.MFTeamMember) FillMFTeamMember(*cs.MFTeamMember)
GetSortIdx() int32 GetSortIdx() int32
SetSortIdx(int32) SetSortIdx(int32)

View File

@ -120,6 +120,10 @@ func (this *player) IsOnline() bool {
return this.socket.IsValid() return this.socket.IsValid()
} }
func (this *player) IsReady() bool {
return this.isReady != 0
}
func (this *player) GetTeam() common.Team { func (this *player) GetTeam() common.Team {
return this.team return this.team
} }

View File

@ -108,13 +108,22 @@ func (this *team) Started() bool {
func (this *team) CanStartGame(hum common.Player) bool { func (this *team) CanStartGame(hum common.Player) bool {
if !this.Started() { if !this.Started() {
this.state = constant.TEAM_STATE_STARTED if this.GetMemberNum() > 0 {
allReady := true
for _, m := range this.accountIdHash {
if m != this.owner && !m.IsReady() {
allReady = false
break
}
}
return allReady
}
} }
return true return false
} }
func (this *team) StartGame() { func (this *team) StartGame() {
if !this.Started() { if !this.Started() && this.CanStartGame(this.owner) {
this.state = constant.TEAM_STATE_STARTED this.state = constant.TEAM_STATE_STARTED
this.startTime = f5.GetApp().GetNowSeconds() this.startTime = f5.GetApp().GetNowSeconds()
this.genStartGameInfo() this.genStartGameInfo()