This commit is contained in:
aozhiwei 2024-03-12 17:00:02 +08:00
parent 7f26148a75
commit 15ca5cc7c0
3 changed files with 28 additions and 32 deletions

View File

@ -40,6 +40,7 @@ type Team interface {
OnPlayerOnline(Player) OnPlayerOnline(Player)
IsCopy() bool IsCopy() bool
SendUpdateNotify() SendUpdateNotify()
IsLeader(Player) bool
} }
type TeamMgr interface { type TeamMgr interface {
@ -55,7 +56,6 @@ type Player interface {
GetSessionId() string GetSessionId() string
GetZoneId() int32 GetZoneId() int32
GetNodeId() int32 GetNodeId() int32
GetPing() int32
IsOnline() bool IsOnline() bool
GetTeam() Team GetTeam() Team
SetTeam(Team) SetTeam(Team)

View File

@ -2,6 +2,7 @@ package player
import ( import (
"cs" "cs"
"q5"
"f5" "f5"
"github.com/golang/protobuf/proto" "github.com/golang/protobuf/proto"
"main/common" "main/common"
@ -23,15 +24,12 @@ type player struct {
nodeId int32 nodeId int32
name string name string
avatarUrl string avatarUrl string
heroId string
headFrame string headFrame string
ping int32
isLeader int32
specSkill int32 specSkill int32
state int32 state int32
isReady int32 isReady int32
permission int32 permission int32
hero *hero hero hero
team common.Team team common.Team
} }
@ -47,10 +45,14 @@ func (this *player) init(req *pendingLoginRequest, rsp *common.LoginRsp){
this.sessionId = req.msg.GetSessionId() this.sessionId = req.msg.GetSessionId()
this.zoneId = req.msg.GetZoneId() this.zoneId = req.msg.GetZoneId()
this.nodeId = req.msg.GetNodeId() this.nodeId = req.msg.GetNodeId()
/*this.name = name this.name = rsp.Info.UserInfo.Name
this.avatarUrl = avatarUrl this.avatarUrl = rsp.Info.UserInfo.HeadId
this.heroId = heroId this.headFrame = rsp.Info.UserInfo.HeadFrame
this.headFrame = headFrame*/ {
this.hero.heroUniId = rsp.Info.HeroInfo.HeroUniId
this.hero.heroId = q5.ToInt32(rsp.Info.HeroInfo.HeroId)
this.hero.quality = q5.ToInt32(rsp.Info.HeroInfo.Quality)
}
} }
func (this *player) againInit(req *pendingLoginRequest, rsp *common.LoginRsp){ func (this *player) againInit(req *pendingLoginRequest, rsp *common.LoginRsp){
@ -59,10 +61,14 @@ func (this *player) againInit(req *pendingLoginRequest, rsp *common.LoginRsp){
this.sessionId = req.msg.GetSessionId() this.sessionId = req.msg.GetSessionId()
this.zoneId = req.msg.GetZoneId() this.zoneId = req.msg.GetZoneId()
this.nodeId = req.msg.GetNodeId() this.nodeId = req.msg.GetNodeId()
/*this.name = name this.name = rsp.Info.UserInfo.Name
this.avatarUrl = avatarUrl this.avatarUrl = rsp.Info.UserInfo.HeadId
this.heroId = heroId this.headFrame = rsp.Info.UserInfo.HeadFrame
this.headFrame = headFrame*/ {
this.hero.heroUniId = rsp.Info.HeroInfo.HeroUniId
this.hero.heroId = q5.ToInt32(rsp.Info.HeroInfo.HeroId)
this.hero.quality = q5.ToInt32(rsp.Info.HeroInfo.Quality)
}
} }
func (this *player) GetSocket() f5.WspCliConn { func (this *player) GetSocket() f5.WspCliConn {
@ -97,18 +103,10 @@ func (this *player) GetAvatarUrl() string {
return this.avatarUrl return this.avatarUrl
} }
func (this *player) GetHeroId() string {
return this.heroId
}
func (this *player) GetHeadFrame() string { func (this *player) GetHeadFrame() string {
return this.headFrame return this.headFrame
} }
func (this *player) GetPing() int32 {
return this.ping
}
func (this *player) GetZoneId() int32 { func (this *player) GetZoneId() int32 {
return this.zoneId return this.zoneId
} }
@ -121,16 +119,6 @@ func (this *player) IsOnline() bool {
return this.socket.IsValid() return this.socket.IsValid()
} }
func (this *player) internalSetPing(ping int32) {
if ping < 30 {
this.ping = 30
} else if ping > 1000 {
this.ping = 1000
} else {
this.ping = ping
}
}
func (this *player) GetTeam() common.Team { func (this *player) GetTeam() common.Team {
return this.team return this.team
} }
@ -142,7 +130,11 @@ func (this *player) SetTeam(team common.Team) {
func (this *player) FillMFTeamMember(member_pb *cs.MFTeamMember) { func (this *player) FillMFTeamMember(member_pb *cs.MFTeamMember) {
member_pb.AccountId = proto.String(this.accountId) member_pb.AccountId = proto.String(this.accountId)
member_pb.Name = proto.String(this.name) member_pb.Name = proto.String(this.name)
member_pb.IsLeader = proto.Int32(this.isLeader) if this.GetTeam().IsLeader(this) {
member_pb.IsLeader = proto.Int32(1)
} else {
member_pb.IsLeader = proto.Int32(0)
}
member_pb.SpecSkill = proto.Int32(this.specSkill) member_pb.SpecSkill = proto.Int32(this.specSkill)
{ {
member_pb.Hero = &cs.MFHero{} member_pb.Hero = &cs.MFHero{}

View File

@ -76,6 +76,10 @@ func (this *team) Join(hum common.Player) bool {
return true return true
} }
func (this *team) IsLeader(hum common.Player) bool {
return hum == this.owner
}
func (this *team) isFull() bool { func (this *team) isFull() bool {
return len(this.accountIdHash) >= 4 return len(this.accountIdHash) >= 4
} }