1
This commit is contained in:
parent
b5aa526cd4
commit
24a119129e
@ -20,6 +20,7 @@ type room struct {
|
||||
zoneId int32
|
||||
nodeId int32
|
||||
passwd string
|
||||
maxTeamNum int32
|
||||
}
|
||||
owner *member
|
||||
roomState int32
|
||||
@ -43,6 +44,7 @@ func (this *room) init(roomId string, roomIdx int64, mapId int32, owner common.P
|
||||
this.config.zoneId = owner.GetZoneId()
|
||||
this.config.nodeId = owner.GetNodeId()
|
||||
this.config.passwd = passwd
|
||||
this.config.maxTeamNum = constant.ROOM_MAX_TEAM_NUM
|
||||
this.owner = newMember(owner)
|
||||
this.members = map[string]*member{
|
||||
owner.GetAccountId(): this.owner,
|
||||
@ -93,7 +95,7 @@ func (this *room) canJoin(member common.Player, passwd string) bool {
|
||||
if member.GetRoom() != nil {
|
||||
return false
|
||||
}
|
||||
if len(this.teamUuidHash) >= constant.ROOM_MAX_TEAM_NUM {
|
||||
if int32(len(this.teamUuidHash)) >= this.config.maxTeamNum {
|
||||
return false
|
||||
}
|
||||
if this.getMember(member.GetAccountId()) != nil {
|
||||
@ -346,13 +348,40 @@ func (this *room) isOwner(hum common.Player) bool {
|
||||
}
|
||||
|
||||
func (this *room) getNextOwner() *member {
|
||||
return nil
|
||||
var minT *member
|
||||
var maxT *member
|
||||
for i := int32(1); i <= this.config.maxTeamNum; i++ {
|
||||
if i != this.owner.team.teamId {
|
||||
if t, ok := this.teamIdHash[i]; ok {
|
||||
ownerCandidate := t.getOwnerCandidate()
|
||||
if ownerCandidate != nil {
|
||||
if i < this.owner.team.teamId && minT == nil {
|
||||
minT = ownerCandidate
|
||||
}
|
||||
if i > this.owner.team.teamId && maxT == nil {
|
||||
maxT = ownerCandidate
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
if maxT != nil {
|
||||
return maxT
|
||||
} else {
|
||||
return minT
|
||||
}
|
||||
}
|
||||
|
||||
func (this *room) genTeamId() int32 {
|
||||
teamId := int32(1)
|
||||
for i := 1; i < constant.ROOM_MAX_TEAM_NUM; i++ {
|
||||
|
||||
teamId := int32(-1)
|
||||
for i := int32(1); i <= this.config.maxTeamNum; i++ {
|
||||
if _, ok := this.teamIdHash[i]; !ok {
|
||||
teamId = i
|
||||
break
|
||||
}
|
||||
}
|
||||
if teamId < 1 {
|
||||
panic("room.genTeamId error")
|
||||
}
|
||||
return teamId
|
||||
}
|
||||
|
@ -36,6 +36,10 @@ func (this *team) hasAlreadMember() bool {
|
||||
return ok
|
||||
}
|
||||
|
||||
func (this *team) getOwnerCandidate() *member {
|
||||
return nil
|
||||
}
|
||||
|
||||
func newTeam(teamId int32, leader *member) *team {
|
||||
t := new(team)
|
||||
t.teamId = teamId
|
||||
|
Loading…
x
Reference in New Issue
Block a user