Documentation
¶
Index ¶
- Constants
- type Group
- type GroupBase
- func (g *GroupBase) AddInviteRecord(inviteeUID string, nowUnix int64)
- func (g *GroupBase) AddPlayer(p Player) error
- func (g *GroupBase) AllowNearbyJoin() bool
- func (g *GroupBase) AllowRecentJoin() bool
- func (g *GroupBase) Base() *GroupBase
- func (g *GroupBase) CanPlayTogether(info *pto.PlayerInfo) error
- func (g *GroupBase) CanStartMatch() bool
- func (g *GroupBase) CheckState(valids ...GroupState) error
- func (g *GroupBase) ClearPlayers()
- func (g *GroupBase) DelInviteRecord(inviteeUID string)
- func (g *GroupBase) GetCaptain() Player
- func (g *GroupBase) GetInviteExpireTimeStamp(uid string) int64
- func (g *GroupBase) GetInviteRecords() map[string]int64
- func (g *GroupBase) GetPlayerInfos() pto.GroupUser
- func (g *GroupBase) GetPlayers() []Player
- func (g *GroupBase) GetState() GroupState
- func (g *GroupBase) GetStateWithLock() GroupState
- func (g *GroupBase) ID() int64
- func (g *GroupBase) IsFull() bool
- func (g *GroupBase) IsInviteExpired(uid string, nowUnix int64) bool
- func (g *GroupBase) PlayerExists(uid string) bool
- func (g *GroupBase) PlayerLimit() int
- func (g *GroupBase) RemovePlayer(p Player) (empty bool)
- func (g *GroupBase) SetAllowNearbyJoin(allow bool)
- func (g *GroupBase) SetAllowRecentJoin(allow bool)
- func (g *GroupBase) SetCaptain(p Player)
- func (g *GroupBase) SetState(s GroupState)
- func (g *GroupBase) SetStateWithLock(s GroupState)
- func (g *GroupBase) UIDs() []string
- type GroupConfig
- type GroupRole
- type GroupSettings
- type GroupState
- type Player
- type PlayerBase
- func (p *PlayerBase) Base() *PlayerBase
- func (p *PlayerBase) CheckOnlineState(valids ...PlayerOnlineState) error
- func (p *PlayerBase) GetOnlineState() PlayerOnlineState
- func (p *PlayerBase) GetOnlineStateWithLock() PlayerOnlineState
- func (p *PlayerBase) GetPlayerInfo() *pto.PlayerInfo
- func (p *PlayerBase) GetVoiceState() PlayerVoiceState
- func (p *PlayerBase) SetOnlineState(s PlayerOnlineState)
- func (p *PlayerBase) SetOnlineStateWithLock(s PlayerOnlineState)
- func (p *PlayerBase) SetVoiceState(s PlayerVoiceState)
- func (p *PlayerBase) UID() string
- type PlayerOnlineState
- type PlayerVoiceState
- type Room
- type RoomBase
- type Team
- type TeamBase
Constants ¶
View Source
const (
InviteExpireSec = 60 * 5
)
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Group ¶
type Group interface { // ID returns the unique group id. ID() int64 // Base returns the base information of the group. // Here we define a concrete struct `GroupBase` // to hold the common fields to avoid lots getter and setter method. Base() *GroupBase // IsFull checks if the group is full. IsFull() bool // SetCaptain sets the captain of the group. SetCaptain(Player) // GetCaptain returns the captain in the group. GetCaptain() Player // CanPlayTogether checks if the player can play with the group's players. CanPlayTogether(*pto.PlayerInfo) error // GetPlayerInfos 获取队伍用户信息 GetPlayerInfos() pto.GroupUser // CanStartMatch checks if the group can start to match. CanStartMatch() bool }
Group represents a group of players.
type GroupBase ¶
type GroupBase struct { GroupID int64 GameMode constant.GameMode ModeVersion int64 MatchStrategy constant.MatchStrategy // Do not do synchronization at this layer, // leave it to the caller to handle it uniformly, // to avoid deadlocks. sync.RWMutex // MatchID is a unique id to identify each match action. MatchID string // Settings holds the settings of the group. Settings GroupSettings // Configs holds the config of the group. Configs GroupConfig // contains filtered or unexported fields }
GroupBase holds the common fields of a Group for all kinds of game mode and match strategy.
func NewGroupBase ¶
func NewGroupBase( groupID int64, playerLimit int, playerBase *PlayerBase, ) *GroupBase
NewGroupBase creates a new GroupBase.
func (*GroupBase) AddInviteRecord ¶
func (*GroupBase) AllowNearbyJoin ¶
func (*GroupBase) AllowRecentJoin ¶
func (*GroupBase) CanPlayTogether ¶
func (g *GroupBase) CanPlayTogether(info *pto.PlayerInfo) error
func (*GroupBase) CanStartMatch ¶
func (*GroupBase) CheckState ¶
func (g *GroupBase) CheckState(valids ...GroupState) error
func (*GroupBase) ClearPlayers ¶
func (g *GroupBase) ClearPlayers()
func (*GroupBase) DelInviteRecord ¶
func (*GroupBase) GetCaptain ¶
func (*GroupBase) GetInviteExpireTimeStamp ¶
func (*GroupBase) GetInviteRecords ¶
func (*GroupBase) GetPlayerInfos ¶
func (*GroupBase) GetPlayers ¶
func (*GroupBase) GetState ¶
func (g *GroupBase) GetState() GroupState
func (*GroupBase) GetStateWithLock ¶
func (g *GroupBase) GetStateWithLock() GroupState
func (*GroupBase) IsInviteExpired ¶
func (*GroupBase) PlayerExists ¶
func (*GroupBase) PlayerLimit ¶
func (*GroupBase) RemovePlayer ¶
func (*GroupBase) SetAllowNearbyJoin ¶
func (*GroupBase) SetAllowRecentJoin ¶
func (*GroupBase) SetCaptain ¶
func (*GroupBase) SetState ¶
func (g *GroupBase) SetState(s GroupState)
func (*GroupBase) SetStateWithLock ¶
func (g *GroupBase) SetStateWithLock(s GroupState)
type GroupConfig ¶
type GroupSettings ¶
type GroupSettings struct {
// contains filtered or unexported fields
}
GroupSettings defines the settings of a group.
type GroupState ¶
type GroupState int8
const ( GroupStateInvite GroupState = 0 GroupStateMatch GroupState = 1 GroupStateGame GroupState = 2 GroupStateDissolved GroupState = 3 )
type Player ¶
type Player interface { Base() *PlayerBase UID() string GetPlayerInfo() *pto.PlayerInfo }
Player represents a player in a Group.
type PlayerBase ¶
type PlayerBase struct { sync.RWMutex GroupID int64 VoiceState PlayerVoiceState // TODO: other common attributes pto.PlayerInfo // contains filtered or unexported fields }
PlayerBase holds the common fields of a Player for all kinds of game mode and match strategy.
func NewPlayerBase ¶
func NewPlayerBase(info *pto.PlayerInfo) *PlayerBase
func (*PlayerBase) Base ¶
func (p *PlayerBase) Base() *PlayerBase
func (*PlayerBase) CheckOnlineState ¶
func (p *PlayerBase) CheckOnlineState(valids ...PlayerOnlineState) error
CheckOnlineState checks if the player is in a valid online state.
func (*PlayerBase) GetOnlineState ¶
func (p *PlayerBase) GetOnlineState() PlayerOnlineState
func (*PlayerBase) GetOnlineStateWithLock ¶
func (p *PlayerBase) GetOnlineStateWithLock() PlayerOnlineState
func (*PlayerBase) GetPlayerInfo ¶
func (p *PlayerBase) GetPlayerInfo() *pto.PlayerInfo
func (*PlayerBase) GetVoiceState ¶
func (p *PlayerBase) GetVoiceState() PlayerVoiceState
func (*PlayerBase) SetOnlineState ¶
func (p *PlayerBase) SetOnlineState(s PlayerOnlineState)
func (*PlayerBase) SetOnlineStateWithLock ¶
func (p *PlayerBase) SetOnlineStateWithLock(s PlayerOnlineState)
func (*PlayerBase) SetVoiceState ¶
func (p *PlayerBase) SetVoiceState(s PlayerVoiceState)
func (*PlayerBase) UID ¶
func (p *PlayerBase) UID() string
type PlayerOnlineState ¶
type PlayerOnlineState int8
PlayerOnlineState is the state of a player. TODO: try to use state machine to manage player state.
const ( PlayerOnlineStateOffline PlayerOnlineState = 0 PlayerOnlineStateOnline PlayerOnlineState = 1 PlayerOnlineStateInGroup PlayerOnlineState = 2 PlayerOnlineStateInMatch PlayerOnlineState = 3 PlayerOnlineStateInGame PlayerOnlineState = 4 PlayerOnlineStateInSettle PlayerOnlineState = 5 )
type PlayerVoiceState ¶
type PlayerVoiceState int8
PlayerVoiceState is the voice state of a player.
const ( PlayerVoiceStateMute PlayerVoiceState = 0 PlayerVoiceStateUnmute PlayerVoiceState = 1 )
type RoomBase ¶
type RoomBase struct { sync.RWMutex GameMode constant.GameMode MatchStrategy constant.MatchStrategy // contains filtered or unexported fields }
func NewRoomBase ¶
func (*RoomBase) GetMatchInfo ¶
func (*RoomBase) RemoveTeam ¶
type TeamBase ¶
type TeamBase struct { sync.RWMutex GameMode constant.GameMode MatchStrategy constant.MatchStrategy // contains filtered or unexported fields }
func NewTeamBase ¶
func (*TeamBase) RemoveGroup ¶
Click to show internal directories.
Click to hide internal directories.