1
This commit is contained in:
parent
c3808188d0
commit
72adda7fbb
@ -74,9 +74,11 @@ type Team interface {
|
||||
SendStateNotify()
|
||||
IsLeader(Player) bool
|
||||
Started() bool
|
||||
Matching() bool
|
||||
CanStartGame(Player) bool
|
||||
StartGame()
|
||||
GetMemberNum() int32
|
||||
IsLock() bool
|
||||
|
||||
Leave(Player)
|
||||
Disband()
|
||||
|
@ -189,7 +189,7 @@ func (this *player) FillMFTeamMember(member_pb *cs.MFTeamMember) {
|
||||
func (this *player) CMLeaveTeam(hdr *f5.MsgHdr, msg *cs.CMLeaveTeam) {
|
||||
rspMsg := &cs.SMLeaveTeam{}
|
||||
team := this.GetTeam()
|
||||
if this.GetTeam().Started() {
|
||||
if this.GetTeam().IsLock() {
|
||||
rspMsg.Errcode = proto.Int32(1)
|
||||
rspMsg.Errmsg = proto.String("team already started")
|
||||
this.SendMsg(rspMsg)
|
||||
@ -206,7 +206,7 @@ func (this *player) CMLeaveTeam(hdr *f5.MsgHdr, msg *cs.CMLeaveTeam) {
|
||||
func (this *player) CMDisbandTeam(hdr *f5.MsgHdr, msg *cs.CMDisbandTeam) {
|
||||
rspMsg := &cs.SMDisbandTeam{}
|
||||
team := this.GetTeam()
|
||||
if this.GetTeam().Started() {
|
||||
if this.GetTeam().IsLock() {
|
||||
rspMsg.Errcode = proto.Int32(1)
|
||||
rspMsg.Errmsg = proto.String("team already started")
|
||||
} else {
|
||||
@ -219,7 +219,7 @@ func (this *player) CMDisbandTeam(hdr *f5.MsgHdr, msg *cs.CMDisbandTeam) {
|
||||
func (this *player) CMKickOut(hdr *f5.MsgHdr, msg *cs.CMKickOut) {
|
||||
rspMsg := &cs.SMKickOut{}
|
||||
team := this.GetTeam()
|
||||
if this.GetTeam().Started() {
|
||||
if this.GetTeam().IsLock() {
|
||||
rspMsg.Errcode = proto.Int32(1)
|
||||
rspMsg.Errmsg = proto.String("team already started")
|
||||
} else {
|
||||
@ -232,7 +232,7 @@ func (this *player) CMKickOut(hdr *f5.MsgHdr, msg *cs.CMKickOut) {
|
||||
func (this *player) CMHandoverLeader(hdr *f5.MsgHdr, msg *cs.CMHandoverLeader) {
|
||||
rspMsg := &cs.SMHandoverLeader{}
|
||||
team := this.GetTeam()
|
||||
if this.GetTeam().Started() {
|
||||
if this.GetTeam().IsLock() {
|
||||
rspMsg.Errcode = proto.Int32(1)
|
||||
rspMsg.Errmsg = proto.String("team already started")
|
||||
} else {
|
||||
@ -244,7 +244,7 @@ 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().IsLock() {
|
||||
if this.GetTeam().CanStartGame(this) {
|
||||
this.GetTeam().StartGame()
|
||||
}
|
||||
@ -267,7 +267,7 @@ func (this *player) CMCancel(hdr *f5.MsgHdr, msg *cs.CMCancel) {
|
||||
|
||||
func (this *player) CMSetReady(hdr *f5.MsgHdr, msg *cs.CMSetReady) {
|
||||
rspMsg := &cs.SMSetReady{}
|
||||
if this.GetTeam().Started() {
|
||||
if this.GetTeam().IsLock() {
|
||||
rspMsg.Errcode = proto.Int32(1)
|
||||
rspMsg.Errmsg = proto.String("team already started")
|
||||
} else {
|
||||
@ -283,7 +283,7 @@ func (this *player) CMSetReady(hdr *f5.MsgHdr, msg *cs.CMSetReady) {
|
||||
|
||||
func (this *player) CMSetSpecSkill(hdr *f5.MsgHdr, msg *cs.CMSetSpecSkill) {
|
||||
rspMsg := &cs.SMSetSpecSkill{}
|
||||
if this.GetTeam().Started() {
|
||||
if this.GetTeam().IsLock() {
|
||||
rspMsg.Errcode = proto.Int32(1)
|
||||
rspMsg.Errmsg = proto.String("team already started")
|
||||
return
|
||||
@ -308,7 +308,7 @@ func (this *player) CMSetSpecSkill(hdr *f5.MsgHdr, msg *cs.CMSetSpecSkill) {
|
||||
|
||||
func (this *player) CMChooseHero(hdr *f5.MsgHdr, msg *cs.CMChooseHero) {
|
||||
rspMsg := &cs.SMChooseHero{}
|
||||
if this.GetTeam().Started() {
|
||||
if this.GetTeam().IsLock() {
|
||||
rspMsg.Errcode = proto.Int32(1)
|
||||
rspMsg.Errmsg = proto.String("team already started")
|
||||
this.SendMsg(rspMsg)
|
||||
@ -334,7 +334,7 @@ func (this *player) CMChooseHero(hdr *f5.MsgHdr, msg *cs.CMChooseHero) {
|
||||
|
||||
func (this *player) CMChooseMap(hdr *f5.MsgHdr, msg *cs.CMChooseMap) {
|
||||
rspMsg := &cs.SMChooseMap{}
|
||||
if this.GetTeam().Started() {
|
||||
if this.GetTeam().IsLock() {
|
||||
rspMsg.Errcode = proto.Int32(1)
|
||||
rspMsg.Errmsg = proto.String("team already started")
|
||||
this.SendMsg(rspMsg)
|
||||
@ -371,7 +371,7 @@ func (this *player) updateChoose(skillId int32, heroUniId string,
|
||||
url,
|
||||
params,
|
||||
func(rsp f5.HttpCliResponse) {
|
||||
if this.GetTeam() != nil && !this.GetTeam().Started() {
|
||||
if this.GetTeam() != nil && !this.GetTeam().IsLock() {
|
||||
if rsp.GetErr() != nil {
|
||||
cb(500, "server internal error")
|
||||
return
|
||||
@ -416,7 +416,7 @@ func (this *player) updateMap(mapId int32,
|
||||
url,
|
||||
params,
|
||||
func(rsp f5.HttpCliResponse) {
|
||||
if this.GetTeam() != nil && !this.GetTeam().Started() {
|
||||
if this.GetTeam() != nil && !this.GetTeam().IsLock() {
|
||||
if rsp.GetErr() != nil {
|
||||
cb(500, "server internal error")
|
||||
return
|
||||
@ -448,7 +448,7 @@ func (this *player) updateMap(mapId int32,
|
||||
|
||||
func (this *player) CMGrantInvitePermission(hdr *f5.MsgHdr, msg *cs.CMGrantInvitePermission) {
|
||||
rspMsg := &cs.SMGrantInvitePermission{}
|
||||
if this.GetTeam().Started() {
|
||||
if this.GetTeam().IsLock() {
|
||||
rspMsg.Errcode = proto.Int32(1)
|
||||
rspMsg.Errmsg = proto.String("team already started")
|
||||
} else {
|
||||
|
@ -107,8 +107,16 @@ func (this *team) Started() bool {
|
||||
return this.state == constant.TEAM_STATE_STARTED
|
||||
}
|
||||
|
||||
func (this *team) Matching() bool {
|
||||
return this.state == constant.TEAM_STATE_MATCHING
|
||||
}
|
||||
|
||||
func (this *team) IsLock() bool {
|
||||
return this.Started() || this.Matching()
|
||||
}
|
||||
|
||||
func (this *team) CanStartGame(hum common.Player) bool {
|
||||
if !this.Started() {
|
||||
if !this.IsLock() {
|
||||
if this.GetMemberNum() > 0 {
|
||||
allReady := true
|
||||
for _, m := range this.accountIdHash {
|
||||
@ -124,17 +132,22 @@ func (this *team) CanStartGame(hum common.Player) bool {
|
||||
}
|
||||
|
||||
func (this *team) StartGame() {
|
||||
if !this.Started() && this.CanStartGame(this.owner) {
|
||||
this.state = constant.TEAM_STATE_STARTED
|
||||
this.startTime = f5.GetApp().GetNowSeconds()
|
||||
this.stateNotifyMsg.State = proto.Int32(this.state)
|
||||
this.genStartGameInfo()
|
||||
this.SendStateNotify()
|
||||
f5.GetTimer().SetInterval(1000, func(e int32, args *q5.Args) {
|
||||
if e == q5.TIMER_EXEC_EVENT {
|
||||
this.SendStateNotify()
|
||||
}
|
||||
})
|
||||
if !this.IsLock() && this.CanStartGame(this.owner) {
|
||||
if this.IsMobaMode() {
|
||||
this.state = constant.TEAM_STATE_MATCHING
|
||||
this.SendStateNotify()
|
||||
} else {
|
||||
this.state = constant.TEAM_STATE_STARTED
|
||||
this.startTime = f5.GetApp().GetNowSeconds()
|
||||
this.stateNotifyMsg.State = proto.Int32(this.state)
|
||||
this.genStartGameInfo()
|
||||
this.SendStateNotify()
|
||||
f5.GetTimer().SetInterval(1000, func(e int32, args *q5.Args) {
|
||||
if e == q5.TIMER_EXEC_EVENT {
|
||||
this.SendStateNotify()
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user