This commit is contained in:
aozhiwei 2024-03-12 21:30:10 +08:00
parent fb5d7f37cd
commit 3703cc0c28
2 changed files with 16 additions and 3 deletions

View File

@ -17,7 +17,7 @@ type LoginRsp struct {
UserInfo struct {
Activated string `json:"activated"`
RenameCount string `json:"rename_count"`
AccountID string `json:"account_id"`
AccountId string `json:"account_id"`
Name string `json:"name"`
HeadId string `json:"head_id"`
HeroId string `json:"hero_id"`
@ -40,6 +40,7 @@ type Team interface {
OnPlayerOnline(Player)
IsCopy() bool
SendUpdateNotify()
SendStateNotify()
IsLeader(Player) bool
Started() bool
}

View File

@ -4,6 +4,7 @@ import (
"q5"
"cs"
"main/common"
"main/constant"
"github.com/golang/protobuf/proto"
)
@ -17,7 +18,8 @@ type team struct {
nodeId int32
mapId int32
owner common.Player
started bool
state int32
stateNotifyMsg *cs.SMTeamStateNotify
accountIdHash map[string]common.Player
}
@ -26,6 +28,7 @@ func (this *team) init(teamUuid string, owner common.Player) {
this.zoneId = owner.GetZoneId()
this.nodeId = owner.GetNodeId()
this.owner = owner
this.stateNotifyMsg.JoinMsg.TeamUuid = proto.String(this.teamUuid)
owner.SetTeam(this)
this.accountIdHash[owner.GetAccountId()] = owner
}
@ -90,7 +93,7 @@ func (this *team) IsCopy() bool {
}
func (this *team) Started() bool {
return this.started
return this.state == constant.TEAM_STAET_STARTED
}
func (this *team) broadcastMsg(msg proto.Message) {
@ -114,8 +117,17 @@ func (this *team) SendUpdateNotify() {
this.broadcastMsg(notifyMsg)
}
func (this *team) SendStateNotify() {
notifyMsg := &cs.SMTeamStateNotify{}
notifyMsg.State = proto.Int32(this.state)
this.broadcastMsg(notifyMsg)
}
func newTeam() *team {
t := new(team)
t.state = constant.TEAM_STAET_INIT
t.stateNotifyMsg = &cs.SMTeamStateNotify{}
t.stateNotifyMsg.JoinMsg = &cs.MFJoinMsg{}
t.accountIdHash = map[string]common.Player{}
return t
}