entities

package
v0.0.0-...-237b7d6 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: May 19, 2023 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

entities @author LanguageY++2013 2022/11/8 18:28 @company soulgame

entities @author LanguageY++2013 2022/11/10 09:48 @company soulgame

entities @author LanguageY++2013 2022/11/9 18:42 @company soulgame

entities @author LanguageY++2013 2022/11/9 18:31 @company soulgame

entities @author LanguageY++2013 2022/11/9 14:37 @company soulgame

entities @author LanguageY++2013 2022/11/8 09:49 @company soulgame

entities @author LanguageY++2013 2022/11/8 15:49 @company soulgame

entities @author LanguageY++2013 2022/11/9 18:30 @company soulgame

entities @author LanguageY++2013 2022/11/9 15:11 @company soulgame

entities @author LanguageY++2013 2022/11/8 18:31 @company soulgame

Index

Constants

View Source
const (
	AcceptanceCompletedReasonTimeOut    = "TimeOut"
	AcceptanceCompletedReasonAcceptance = "Acceptance"
	AcceptanceCompletedReasonRejection  = "Rejection"

	StatusReasonRejectMatch             = "RejectMatch"
	StatusReasonCreateGameSessionFailed = "CreateGameSessionFailed"
	StatusReasonSearchingFailedBackfill = "SearchingFailedBackfill"
	StatusReasonMatchRejectBackfill     = "MatchRejectBackfill"
)

Variables

View Source
var (
	ErrOutOfTicketQueueSize = errors.New("out of ticket queue size")
)

Functions

func SetGameClient

func SetGameClient(cli open.FlexMatchGameClient)

设置游戏grpc客户端

func SetPublisher

func SetPublisher(pub pubsub.Publisher)

Types

type BatchTicketProcessor

type BatchTicketProcessor struct {
	//媒介
	Matchmaking *Matchmaking
	// contains filtered or unexported fields
}

func MewBatchTicketProcessor

func MewBatchTicketProcessor(Matchmaking *Matchmaking) *BatchTicketProcessor

func (*BatchTicketProcessor) EstimatedWaitTime

func (proc *BatchTicketProcessor) EstimatedWaitTime() int64

EstimatedWaitTime 预计等待时间单位秒,不能低于保底值

func (*BatchTicketProcessor) Input

func (proc *BatchTicketProcessor) Input(batch []*open.MatchmakingTicket)

type CombinationTickets

type CombinationTickets struct {
	// contains filtered or unexported fields
}

票据组合

type Match

type Match struct {
	//匹配唯一ID
	MatchId string

	//当前的对局团队
	Teams []*Team

	//创建时间
	CreationTime int64

	//对局会话连接信息
	GameSessionConnectionInfo *open.GameSessionConnectionInfo
	// contains filtered or unexported fields
}

func NewMatch

func NewMatch(matchmaking *Matchmaking, matchTeams []*Team) (match *Match)

func (*Match) AcceptMatch

func (m *Match) AcceptMatch(ticketId string)

AcceptMatch 玩家接受对局

func (*Match) AcceptTickets

func (m *Match) AcceptTickets() (ret []*open.MatchmakingTicket)

func (*Match) AllTickets

func (m *Match) AllTickets() (tickets []*open.MatchmakingTicket)

AllTickets 所有票据

func (*Match) BuildGameSessionInfo

func (m *Match) BuildGameSessionInfo() *open.GameSessionConnectionInfo

func (*Match) CheckAccepted

func (m *Match) CheckAccepted() bool

CheckAccepted 检测对局团队内的所有成员是否均接受了对局

func (*Match) RejectMatch

func (m *Match) RejectMatch(ticketId string)

RejectMatch 玩家拒绝对局

func (*Match) StartAccept

func (m *Match) StartAccept(acceptanceTimeoutSeconds int64, placingMatchChan chan<- *Match)

StartAccept 开始接受用户接受状态检测协程

func (*Match) StartGameSession

func (m *Match) StartGameSession()

StartGameSession 开启游戏会话

type Matchmaking

type Matchmaking struct {
	//对局配置
	Conf *open.MatchmakingConfiguration

	//票据队列
	TicketQueue TicketQueue

	//票据批次处理器 (TODO:如何根据负载动态调整处理器的数量?)
	BatchTicketProcessors []*BatchTicketProcessor

	//匹配成功计数
	MatchSucceedCounter int64
	// contains filtered or unexported fields
}

func NewMatchmaking

func NewMatchmaking(conf *open.MatchmakingConfiguration) *Matchmaking

func (*Matchmaking) AcceptMatch

func (e *Matchmaking) AcceptMatch(ticketId string, userId int64, acceptType open.AcceptanceType) (err error)

AcceptMatch 玩家接受对局

func (*Matchmaking) CleanUp

func (e *Matchmaking) CleanUp()

数据清理

func (*Matchmaking) DispatchBatches

func (e *Matchmaking) DispatchBatches(batches []*[]*open.MatchmakingTicket)

DispatchBatches 票据批次分派

func (*Matchmaking) EstimatedWaitTime

func (m *Matchmaking) EstimatedWaitTime() int64

EstimatedWaitTime 预计耗时

func (*Matchmaking) MatchFind

func (e *Matchmaking) MatchFind(matchId string) (match *Match, ok bool)

MatchFind 匹配查找

func (*Matchmaking) MatchInsert

func (e *Matchmaking) MatchInsert(match *Match)

MatchInsert 对局数据插入

func (*Matchmaking) MatchRemove

func (e *Matchmaking) MatchRemove(matchId string)

MatchRemove 匹配移除,接收匹配完成时调用(接受超时、全部接收、任意拒绝)

func (*Matchmaking) Reload

func (e *Matchmaking) Reload(conf *open.MatchmakingConfiguration)

配置重载

func (*Matchmaking) StopMatch

func (m *Matchmaking) StopMatch(ticketId string) (err error)

StopMatch 停止/取消匹配

func (*Matchmaking) TicketFind

func (t *Matchmaking) TicketFind(ticketId string) (ticket *open.MatchmakingTicket, ok bool)

TicketFind 票据查找

func (*Matchmaking) TicketInput

func (e *Matchmaking) TicketInput(ticket *open.MatchmakingTicket) (err error)

TicketInput 票据输入

func (*Matchmaking) TicketInsert

func (t *Matchmaking) TicketInsert(ticket *open.MatchmakingTicket)

TicketInsert 票据插入

func (*Matchmaking) TicketQueued

func (e *Matchmaking) TicketQueued(ticket *open.MatchmakingTicket) (err error)

TicketQueued 票据入队列

func (*Matchmaking) TicketRemove

func (t *Matchmaking) TicketRemove(ticketId string)

TicketRemove 票据删除

func (*Matchmaking) TicketSave

func (t *Matchmaking) TicketSave(ticket *open.MatchmakingTicket) error

TicketSave 票据保存

func (*Matchmaking) TicketSearching

func (e *Matchmaking) TicketSearching(tickets []*open.MatchmakingTicket)

func (*Matchmaking) TicketWatch

func (e *Matchmaking) TicketWatch()

TicketWatch 信号监听:

  1. 票据输入
  2. 票据超时检测
  3. 关闭检测

type MatchmakingRule

type MatchmakingRule struct {
	open.MatchmakingRule
	MeasurementsParser   *parser.PropertyExprParser
	ReferenceValueParser *parser.PropertyExprParser
}

type MatchmakingRuleSetWrapper

type MatchmakingRuleSetWrapper struct {
	*open.MatchmakingRuleSet

	//对局所需成员数
	MatchPlayerNum int32
	// contains filtered or unexported fields
}

func (*MatchmakingRuleSetWrapper) CheckExpansionRule

func (rs *MatchmakingRuleSetWrapper) CheckExpansionRule(ep *open.MatchmakingExpansionRule) (err error)

CheckExpansionRule 验证扩展规则

func (*MatchmakingRuleSetWrapper) CheckExpansionRules

func (rs *MatchmakingRuleSetWrapper) CheckExpansionRules() (err error)

CheckExpansionRules 验证扩展规则列表

func (*MatchmakingRuleSetWrapper) CheckParams

func (rsw *MatchmakingRuleSetWrapper) CheckParams() (err error)

func (*MatchmakingRuleSetWrapper) CheckRule

func (rs *MatchmakingRuleSetWrapper) CheckRule(rule *open.MatchmakingRule) (err error)

CheckRule 验证规则

func (*MatchmakingRuleSetWrapper) CheckRules

func (rs *MatchmakingRuleSetWrapper) CheckRules() (err error)

CheckRules 验证规则列表

func (*MatchmakingRuleSetWrapper) CheckTeam

CheckRuleTeam 验证Team定义

func (*MatchmakingRuleSetWrapper) CheckTeams

func (rs *MatchmakingRuleSetWrapper) CheckTeams() (err error)

func (*MatchmakingRuleSetWrapper) DivideBatch

func (rsw *MatchmakingRuleSetWrapper) DivideBatch(tickets []*open.MatchmakingTicket) (batches []*[]*open.MatchmakingTicket)

DivideBatch划分批次

func (*MatchmakingRuleSetWrapper) GetPlayerAttributeType

func (rsw *MatchmakingRuleSetWrapper) GetPlayerAttributeType(attrName string) string

GetPlayerAttributeType 获取玩家属性类型

func (*MatchmakingRuleSetWrapper) GetPropertyExpressionMeasurements

func (rs *MatchmakingRuleSetWrapper) GetPropertyExpressionMeasurements(p *parser.PropertyExprParser, teams []*Team) (measurements []float64)

GetPropertyExpressionMeasurements 获取规则的属性表达式值的测量值

func (*MatchmakingRuleSetWrapper) GetPropertyExpressionReferenceValue

func (rs *MatchmakingRuleSetWrapper) GetPropertyExpressionReferenceValue(p *parser.PropertyExprParser, teams []*Team) (referenceValue float64)

GetPropertyExpressionReferenceValue 获取规则的属性表达式值的参考值

func (*MatchmakingRuleSetWrapper) Init

func (rsw *MatchmakingRuleSetWrapper) Init()

Init 规则集初始化

func (*MatchmakingRuleSetWrapper) MaxDistance

func (rsw *MatchmakingRuleSetWrapper) MaxDistance(ruleName string, maxDistance float64, tryTimes int, creationTime int64) (newMaxDistance float64, ok bool)

MaxDistance 根据扩展规则计算最大距离

type MeasurementResult

type MeasurementResult struct {
	Aggregation string //聚合函数 min/max/avg时等于团队数量, 空时仅执行flatten, 等于所有选择的团队的玩家的数量
	Values      []*MeasurementValue
}

测量值

type MeasurementValue

type MeasurementValue struct {
	// contains filtered or unexported fields
}

type MockGameClient

type MockGameClient struct {
	// contains filtered or unexported fields
}

func NewMockGameClient

func NewMockGameClient() *MockGameClient

func (*MockGameClient) CreateGameSession

type Team

type Team open.MatchTeam

func (*Team) Copy

func (t *Team) Copy() *Team

type Ticket

type Ticket struct {
	*open.MatchmakingTicket
	// contains filtered or unexported fields
}

Ticket 并发保护ticket

type TicketQueue

type TicketQueue interface {
	//票据输入
	Input(ticket *open.MatchmakingTicket) error

	//票据监听
	Watch()
}

func NewRealTicketQueue

func NewRealTicketQueue(batchTicketChan chan<- []*open.MatchmakingTicket, batchMinTicketNum int32, opts ...TicketQueueOption) TicketQueue

type TicketQueueOption

type TicketQueueOption func(q *realTicketQueue)

func WithTicketQueueTimeout

func WithTicketQueueTimeout(timeoutSeconds int64) TicketQueueOption

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL