1
This commit is contained in:
parent
7f26148a75
commit
15ca5cc7c0
@ -40,6 +40,7 @@ type Team interface {
|
||||
OnPlayerOnline(Player)
|
||||
IsCopy() bool
|
||||
SendUpdateNotify()
|
||||
IsLeader(Player) bool
|
||||
}
|
||||
|
||||
type TeamMgr interface {
|
||||
@ -55,7 +56,6 @@ type Player interface {
|
||||
GetSessionId() string
|
||||
GetZoneId() int32
|
||||
GetNodeId() int32
|
||||
GetPing() int32
|
||||
IsOnline() bool
|
||||
GetTeam() Team
|
||||
SetTeam(Team)
|
||||
|
@ -2,6 +2,7 @@ package player
|
||||
|
||||
import (
|
||||
"cs"
|
||||
"q5"
|
||||
"f5"
|
||||
"github.com/golang/protobuf/proto"
|
||||
"main/common"
|
||||
@ -23,15 +24,12 @@ type player struct {
|
||||
nodeId int32
|
||||
name string
|
||||
avatarUrl string
|
||||
heroId string
|
||||
headFrame string
|
||||
ping int32
|
||||
isLeader int32
|
||||
specSkill int32
|
||||
state int32
|
||||
isReady int32
|
||||
permission int32
|
||||
hero *hero
|
||||
hero hero
|
||||
team common.Team
|
||||
}
|
||||
|
||||
@ -47,10 +45,14 @@ func (this *player) init(req *pendingLoginRequest, rsp *common.LoginRsp){
|
||||
this.sessionId = req.msg.GetSessionId()
|
||||
this.zoneId = req.msg.GetZoneId()
|
||||
this.nodeId = req.msg.GetNodeId()
|
||||
/*this.name = name
|
||||
this.avatarUrl = avatarUrl
|
||||
this.heroId = heroId
|
||||
this.headFrame = headFrame*/
|
||||
this.name = rsp.Info.UserInfo.Name
|
||||
this.avatarUrl = rsp.Info.UserInfo.HeadId
|
||||
this.headFrame = rsp.Info.UserInfo.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){
|
||||
@ -59,10 +61,14 @@ func (this *player) againInit(req *pendingLoginRequest, rsp *common.LoginRsp){
|
||||
this.sessionId = req.msg.GetSessionId()
|
||||
this.zoneId = req.msg.GetZoneId()
|
||||
this.nodeId = req.msg.GetNodeId()
|
||||
/*this.name = name
|
||||
this.avatarUrl = avatarUrl
|
||||
this.heroId = heroId
|
||||
this.headFrame = headFrame*/
|
||||
this.name = rsp.Info.UserInfo.Name
|
||||
this.avatarUrl = rsp.Info.UserInfo.HeadId
|
||||
this.headFrame = rsp.Info.UserInfo.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 {
|
||||
@ -97,18 +103,10 @@ func (this *player) GetAvatarUrl() string {
|
||||
return this.avatarUrl
|
||||
}
|
||||
|
||||
func (this *player) GetHeroId() string {
|
||||
return this.heroId
|
||||
}
|
||||
|
||||
func (this *player) GetHeadFrame() string {
|
||||
return this.headFrame
|
||||
}
|
||||
|
||||
func (this *player) GetPing() int32 {
|
||||
return this.ping
|
||||
}
|
||||
|
||||
func (this *player) GetZoneId() int32 {
|
||||
return this.zoneId
|
||||
}
|
||||
@ -121,16 +119,6 @@ func (this *player) IsOnline() bool {
|
||||
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 {
|
||||
return this.team
|
||||
}
|
||||
@ -142,7 +130,11 @@ func (this *player) SetTeam(team common.Team) {
|
||||
func (this *player) FillMFTeamMember(member_pb *cs.MFTeamMember) {
|
||||
member_pb.AccountId = proto.String(this.accountId)
|
||||
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.Hero = &cs.MFHero{}
|
||||
|
@ -76,6 +76,10 @@ func (this *team) Join(hum common.Player) bool {
|
||||
return true
|
||||
}
|
||||
|
||||
func (this *team) IsLeader(hum common.Player) bool {
|
||||
return hum == this.owner
|
||||
}
|
||||
|
||||
func (this *team) isFull() bool {
|
||||
return len(this.accountIdHash) >= 4
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user