68 lines
1.5 KiB
Go
68 lines
1.5 KiB
Go
package team
|
|
|
|
import (
|
|
"q5"
|
|
"f5"
|
|
"cs"
|
|
"main/common"
|
|
"mt"
|
|
)
|
|
|
|
type teamMgr struct {
|
|
cs.MsgHandlerImpl
|
|
curIdx int64
|
|
teamUuidHash map[string]*team
|
|
}
|
|
|
|
func (this *teamMgr) Init() {
|
|
this.teamUuidHash = make(map[string]*team)
|
|
this.curIdx = f5.GetApp().GetNowSeconds()
|
|
}
|
|
|
|
func (this *teamMgr) UnInit() {
|
|
}
|
|
|
|
func (this *teamMgr) CreateTeam(hum common.Player, msg *cs.CMLogin, mapInfo* common.MapInfoRsp) common.Team {
|
|
teamUuid := this.genTeamUuid(hum.GetZoneId(), hum.GetNodeId())
|
|
team := newTeam()
|
|
team.init(teamUuid, hum, msg, mapInfo)
|
|
this.teamUuidHash[team.teamUuid] = team
|
|
return team
|
|
}
|
|
|
|
func (this *teamMgr) genTeamUuid(zoneId int32, nodeId int32) string {
|
|
teamUuid := ""
|
|
for true {
|
|
teamUuid = this.internalGenTeamUuid(zoneId, nodeId)
|
|
if this.GetTeamByUuid(teamUuid) == nil {
|
|
return teamUuid
|
|
}
|
|
}
|
|
panic("genTeamUuid error")
|
|
}
|
|
|
|
func (this *teamMgr) internalGenTeamUuid(zoneId int32, nodeId int32) string {
|
|
this.curIdx++
|
|
teamUuid := q5.ToString(zoneId) + "_" + q5.ToString(nodeId) + "_" +
|
|
q5.Md5Str(q5.ToString(f5.GetApp().NewUuid()) + q5.ToString(f5.GetApp().GetPid()) +
|
|
q5.ToString(this.curIdx) +
|
|
mt.Table.MatchCluster.GetIp() + "520d8eAbB(8cf1^#$^&!@d833a42c820432PDAFE^^)")
|
|
return teamUuid
|
|
}
|
|
|
|
func (this *teamMgr) GetTeamByUuid(teamUuid string) common.Team {
|
|
team, ok := this.teamUuidHash[teamUuid]
|
|
if ok {
|
|
return team
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func (this *teamMgr) OnEnterNewUser(hum common.Player) {
|
|
|
|
}
|
|
|
|
func (this *teamMgr) removeTeam(teamUuid string) {
|
|
delete(this.teamUuidHash, teamUuid)
|
|
}
|