This commit is contained in:
aozhiwei 2024-03-13 19:39:16 +08:00
parent 899f7dcf11
commit 3a9bf7cfd2
3 changed files with 25 additions and 8 deletions

View File

@ -52,6 +52,7 @@ type Team interface {
HandoverLeader(Player, string)
CancelMatch()
SetReady(Player)
GrantInvitePermission(Player, string)
}
type TeamMgr interface {

View File

@ -186,8 +186,11 @@ func (this *player) CMKickOut(hdr *f5.MsgHdr, msg *cs.CMKickOut) {
func (this *player) CMHandoverLeader(hdr *f5.MsgHdr, msg *cs.CMHandoverLeader) {
rspMsg := &cs.SMHandoverLeader{}
if !this.GetTeam().Started() {
if this.GetTeam().Started() {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("team already started")
} else {
this.GetTeam().HandoverLeader(this, msg.GetTargetId())
}
this.SendMsg(rspMsg)
}
@ -204,24 +207,33 @@ func (this *player) CMStartGame(hdr *f5.MsgHdr, msg *cs.CMStartGame) {
func (this *player) CMCancel(hdr *f5.MsgHdr, msg *cs.CMCancel) {
rspMsg := &cs.SMCancel{}
if !this.GetTeam().Started() {
if this.GetTeam().Started() {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("team already started")
} else {
this.GetTeam().CancelMatch()
}
this.SendMsg(rspMsg)
}
func (this *player) CMSetReady(hdr *f5.MsgHdr, msg *cs.CMSetReady) {
rspMsg := &cs.SMSetReady{}
if !this.GetTeam().Started() {
if this.GetTeam().Started() {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("team already started")
} else {
this.GetTeam().SetReady(this)
}
this.SendMsg(rspMsg)
}
func (this *player) CMGrantInvitePermission(hdr *f5.MsgHdr, msg *cs.CMGrantInvitePermission) {
rspMsg := &cs.SMGrantInvitePermission{}
if !this.GetTeam().Started() {
if this.GetTeam().Started() {
rspMsg.Errcode = proto.Int32(1)
rspMsg.Errmsg = proto.String("team already started")
} else {
this.GetTeam().GrantInvitePermission(this, msg.GetTargetId())
}
this.SendMsg(rspMsg)
}

View File

@ -155,6 +155,10 @@ func (this *team) SetReady(common.Player) {
}
}
func (this *team) GrantInvitePermission(common.Player, string) {
}
func (this *team) genStartGameInfo() {
startInfo := struct {
ZoneId int32 `json:"zone_id"`