Documentation ¶
Index ¶
- Variables
- type ApiServer
- type CardModification
- type CardOperation
- type CardType
- type Engine
- func (e *Engine) AddGameEvent(gameEvent GameEvent)
- func (e *Engine) BallPlacementPos() *Location
- func (e *Engine) CardNumberIncremented(team Team)
- func (e *Engine) CommandForEvent(event *GameEvent) (command RefCommand, forTeam Team, err error)
- func (e *Engine) Continue()
- func (e *Engine) FoulCounterIncremented(team Team)
- func (e *Engine) LogCard(card *EventCard)
- func (e *Engine) LogCommand()
- func (e *Engine) LogGameEvent(event GameEvent)
- func (e *Engine) LogHint(hint string, description string, team Team)
- func (e *Engine) LogIgnoredGameEvent(event GameEvent)
- func (e *Engine) LogModify(m EventModifyValue)
- func (e *Engine) LogStage(stage Stage)
- func (e *Engine) LogTeamBotSubstitutionChange(forTeam Team, substituteBot bool)
- func (e *Engine) LogTeamGoalkeeperChange(forTeam Team, oldGoalkeeperId int, newGoalkeeperId int)
- func (e *Engine) LogTime(description string, forTeam Team)
- func (e *Engine) PlacementFailuresIncremented(team Team)
- func (e *Engine) Process(event Event) error
- func (e *Engine) ResetGame()
- func (e *Engine) SendCommand(command RefCommand, forTeam Team)
- func (e *Engine) UndoLastAction()
- func (e *Engine) Update() (newFullSecond bool, eventTriggered bool)
- type EngineState
- type Event
- type EventCard
- type EventCommand
- type EventConsumer
- type EventModifyCardTime
- type EventModifyGameEventBehavior
- type EventModifyValue
- type EventStage
- type EventTrigger
- type GameController
- func (c *GameController) OnNewEvent(event Event)
- func (c *GameController) ProcessAutoRefRequests(id string, request refproto.AutoRefToController) error
- func (c *GameController) ProcessGeometry(data *sslproto.SSL_GeometryData)
- func (c *GameController) ProcessTeamRequests(teamName string, request refproto.TeamToController) error
- func (c *GameController) Run()
- type GameEvent
- func (e GameEvent) AddsRedCard() bool
- func (e GameEvent) AddsYellowCard() bool
- func (e GameEvent) ByTeam() Team
- func (e GameEvent) IncrementsFoulCounter() bool
- func (e GameEvent) IsContinueGame() bool
- func (e GameEvent) IsSecondary() bool
- func (e GameEvent) IsSkipped() bool
- func (e GameEvent) String() string
- func (e GameEvent) ToProto() *refproto.GameEvent
- type GameEventBehavior
- type GameEventDetails
- type GameEventProposal
- type GameEventType
- type GameState
- type History
- type HistoryEntry
- type HistoryPreserver
- type Location
- type MessageWrapper
- type Publisher
- type RefCommand
- type RefMessage
- type Stage
- type StageOperation
- type State
- func (s State) BotSubstitutionIntend() Team
- func (s State) DeepCopy() (c State)
- func (s State) GameState() GameState
- func (s *State) GetFirstGameEvent(gameEventType GameEventType) *GameEvent
- func (s *State) PrimaryGameEvent() *GameEvent
- func (s State) String() string
- func (s *State) TeamByName(teamName string) Team
- type Team
- type TeamChoice
- type TeamInfo
- type TriggerType
- type UiProtocolEntry
- type UiProtocolType
Constants ¶
This section is empty.
Variables ¶
var GameEventBehaviors = []GameEventBehavior{GameEventBehaviorOn, GameEventBehaviorMajority, GameEventBehaviorOff}
GameEventBehaviors contain all known command enum constants
var GameEventTypes = []GameEventType{ GameEventNone, GameEventPrepared, GameEventNoProgressInGame, GameEventPlacementFailed, GameEventPlacementSucceeded, GameEventBotSubstitution, GameEventTooManyRobots, GameEventBallLeftFieldTouchLine, GameEventBallLeftFieldGoalLine, GameEventPossibleGoal, GameEventGoal, GameEventIndirectGoal, GameEventChippedGoal, GameEventAimlessKick, GameEventKickTimeout, GameEventKeeperHeldBall, GameEventAttackerDoubleTouchedBall, GameEventAttackerInDefenseArea, GameEventAttackerTouchedKeeper, GameEventBotDribbledBallTooFar, GameEventBotKickedBallTooFast, GameEventAttackerTooCloseToDefenseArea, GameEventBotInterferedPlacement, GameEventBotCrashDrawn, GameEventBotCrashUnique, GameEventBotCrashUniqueSkipped, GameEventBotPushedBot, GameEventBotPushedBotSkipped, GameEventBotHeldBallDeliberately, GameEventBotTippedOver, GameEventBotTooFastInStop, GameEventDefenderTooCloseToKickPoint, GameEventDefenderInDefenseAreaPartially, GameEventDefenderInDefenseArea, GameEventMultipleCards, GameEventMultiplePlacementFailures, GameEventMultipleFouls, GameEventUnsportingBehaviorMinor, GameEventUnsportingBehaviorMajor, }
GameStates contain all known command enum constants
var GameStates = []GameState{ GameStateHalted, GameStateStopped, GameStateRunning, GameStatePreKickoff, GameStatePrePenalty, GameStateTimeout, GameStateBallPlacement, }
GameStates contain all known command enum constants
var RefCommands = []RefCommand{ CommandUnknown, CommandHalt, CommandStop, CommandNormalStart, CommandForceStart, CommandDirect, CommandIndirect, CommandKickoff, CommandPenalty, CommandTimeout, CommandBallPlacement, }
Commands contain all known command enum constants
var Stages = []Stage{ StagePreGame, StageFirstHalf, StageHalfTime, StageSecondHalfPre, StageSecondHalf, StageOvertimeBreak, StageOvertimeFirstHalfPre, StageOvertimeFirstHalf, StageOvertimeHalfTime, StageOvertimeSecondHalfPre, StageOvertimeSecondHalf, StageShootoutBreak, StageShootout, StagePostGame, }
Stages include all available stages, ordered
var Teams = []Team{TeamYellow, TeamBlue, TeamBoth, TeamUnknown}
Teams contain all known team enum constants
Functions ¶
This section is empty.
Types ¶
type ApiServer ¶
type ApiServer struct { Consumer EventConsumer // contains filtered or unexported fields }
func (*ApiServer) PublishState ¶
func (a *ApiServer) PublishState(state State, engineState EngineState)
func (*ApiServer) PublishUiProtocol ¶ added in v0.16.0
func (a *ApiServer) PublishUiProtocol(protocol []UiProtocolEntry)
func (*ApiServer) PublishWrapper ¶ added in v0.3.0
func (a *ApiServer) PublishWrapper(wrapper MessageWrapper)
type CardModification ¶
type CardModification struct { CardID int `json:"cardId" yaml:"cardId"` TimeLeft time.Duration `json:"timeLeft" yaml:"timeLeft"` }
CardModification to apply to a card
type CardOperation ¶
type CardOperation string
CardOperation on a card
const ( // CardOperationAdd add a card CardOperationAdd CardOperation = "add" // CardOperationRevoke revoke a card CardOperationRevoke CardOperation = "revoke" // CardOperationModify modify a card CardOperationModify CardOperation = "modify" )
type Engine ¶
type Engine struct { State *State UiProtocol []UiProtocolEntry EngineState EngineState StageTimes map[Stage]time.Duration TimeProvider timer.TimeProvider LastTimeUpdate time.Time History History Geometry config.Geometry Rand *rand.Rand // contains filtered or unexported fields }
func (*Engine) AddGameEvent ¶ added in v0.8.0
func (*Engine) BallPlacementPos ¶ added in v0.8.0
BallPlacementPos determines the ball placement position based on the primary game event
func (*Engine) CardNumberIncremented ¶ added in v0.9.0
func (*Engine) CommandForEvent ¶ added in v0.9.0
func (e *Engine) CommandForEvent(event *GameEvent) (command RefCommand, forTeam Team, err error)
func (*Engine) FoulCounterIncremented ¶ added in v0.9.0
func (*Engine) LogCommand ¶ added in v0.3.0
func (e *Engine) LogCommand()
LogCommand adds a command to the protocol
func (*Engine) LogGameEvent ¶ added in v0.3.0
LogGameEvent adds a game event to the protocol
func (*Engine) LogHint ¶ added in v0.28.0
LogHint adds a hint for the game-controller operator to the protocol
func (*Engine) LogIgnoredGameEvent ¶ added in v0.10.0
LogIgnoredGameEvent adds an ignored game event to the protocol
func (*Engine) LogModify ¶ added in v0.9.0
func (e *Engine) LogModify(m EventModifyValue)
LogModify adds a modification to the protocol
func (*Engine) LogTeamBotSubstitutionChange ¶ added in v0.17.0
LogTeamBotSubstitutionChange adds a bot substitution intend change from a team to the protocol
func (*Engine) LogTeamGoalkeeperChange ¶ added in v0.17.0
LogTeamGoalkeeperChange adds a goalkeeper change from a team to the protocol
func (*Engine) LogTime ¶ added in v0.6.0
LogTime adds a time event (like stage time ends or card time ends) to the protocol
func (*Engine) PlacementFailuresIncremented ¶ added in v0.9.0
func (*Engine) SendCommand ¶ added in v0.4.0
func (e *Engine) SendCommand(command RefCommand, forTeam Team)
func (*Engine) UndoLastAction ¶
func (e *Engine) UndoLastAction()
UndoLastAction restores the last state from internal history
type EngineState ¶ added in v0.23.0
type EngineState struct { AutoRefsConnected []string `json:"autoRefsConnected" yaml:"autoRefsConnected"` TeamConnected map[Team]bool `json:"teamConnected" yaml:"teamConnected"` TeamConnectionVerified map[Team]bool `json:"teamConnectionVerified" yaml:"teamConnectionVerified"` }
func NewEngineState ¶ added in v0.23.0
func NewEngineState() (e EngineState)
type Event ¶
type Event struct { Card *EventCard `json:"card" yaml:"card"` Command *EventCommand `json:"command" yaml:"command"` Modify *EventModifyValue `json:"modify" yaml:"modify"` Stage *EventStage `json:"stage" yaml:"stage"` Trigger *EventTrigger `json:"trigger" yaml:"trigger"` GameEvent *GameEvent `json:"gameEvent" yaml:"gameEvent"` }
Event holds all possible events. Only one at a time can be applied
type EventCard ¶
type EventCard struct { ForTeam Team `json:"forTeam" yaml:"forTeam"` Type CardType `json:"cardType" yaml:"type"` Operation CardOperation `json:"operation" yaml:"operation"` Modification CardModification `json:"modification" yaml:"modification"` }
EventCard is an event that can be applied
type EventCommand ¶
type EventCommand struct { ForTeam *Team `json:"forTeam" yaml:"forTeam"` Type RefCommand `json:"commandType" yaml:"type"` Location *Location `json:"location" yaml:"location"` }
EventCommand is an event that can be applied
func (EventCommand) String ¶
func (c EventCommand) String() string
type EventConsumer ¶
type EventConsumer interface {
OnNewEvent(event Event)
}
type EventModifyCardTime ¶
type EventModifyCardTime struct { CardID int `json:"cardId" yaml:"cardId"` Duration string `json:"duration" yaml:"duration"` }
EventModifyCardTime holds the duration for a certain yellow card duration
type EventModifyGameEventBehavior ¶ added in v0.10.0
type EventModifyGameEventBehavior struct { GameEventType GameEventType `json:"gameEventType" yaml:"gameEventType"` GameEventBehavior GameEventBehavior `json:"gameEventBehavior" yaml:"gameEventBehavior"` }
EventModifyGameEventBehavior holds the type to behavior mapping
type EventModifyValue ¶
type EventModifyValue struct { ForTeam Team `json:"forTeam,omitempty"` Goals *int `json:"goals,omitempty" yaml:"goals"` Goalkeeper *int `json:"goalkeeper,omitempty" yaml:"goalkeeper"` YellowCards *int `json:"yellowCards,omitempty" yaml:"yellowCards"` YellowCardTime *EventModifyCardTime `json:"yellowCardTime,omitempty" yaml:"yellowCardTime"` RedCards *int `json:"redCards,omitempty" yaml:"redCards"` TimeoutsLeft *int `json:"timeoutsLeft,omitempty" yaml:"timeoutsLeft"` TimeoutTimeLeft *string `json:"timeoutTimeLeft,omitempty" yaml:"timeoutTimeLeft"` OnPositiveHalf *bool `json:"onPositiveHalf,omitempty" yaml:"onPositiveHalf"` TeamName *string `json:"teamName,omitempty" yaml:"teamName"` FoulCounter *int `json:"foulCounter,omitempty" yaml:"foulCounter"` BallPlacementFailures *int `json:"ballPlacementFailures,omitempty" yaml:"ballPlacementFailures"` CanPlaceBall *bool `json:"canPlaceBall,omitempty" yaml:"canPlaceBall"` Division *config.Division `json:"division,omitempty" yaml:"division"` AutoContinue *bool `json:"autoContinue,omitempty" yaml:"autoContinue"` GameEventBehavior *EventModifyGameEventBehavior `json:"gameEventBehavior,omitempty" yaml:"gameEventBehavior"` BotSubstitutionIntend *bool `json:"botSubstitutionIntend,omitempty" yaml:"botSubstitutionIntend"` RemoveGameEvent *int `json:"removeGameEvent,omitempty" yaml:"removeGameEvent"` }
EventModifyValue is an event that can be applied
func (EventModifyValue) String ¶
func (m EventModifyValue) String() string
func (EventModifyValue) Type ¶ added in v0.11.1
func (m EventModifyValue) Type() string
func (EventModifyValue) Value ¶ added in v0.11.1
func (m EventModifyValue) Value() string
type EventStage ¶
type EventStage struct {
StageOperation StageOperation `json:"stageOperation" yaml:"stageOperation"`
}
EventStage is an event that can be applied
type EventTrigger ¶
type EventTrigger struct {
Type TriggerType `json:"triggerType" yaml:"type"`
}
EventTrigger is an event that can be applied
type GameController ¶
type GameController struct { Config config.Controller Publisher Publisher ApiServer ApiServer AutoRefServer *rcon.AutoRefServer TeamServer *rcon.TeamServer CiServer rcon.CiServer Engine Engine ConnectionMutex sync.Mutex PublishMutex sync.Mutex VisionReceiver *vision.Receiver // contains filtered or unexported fields }
GameController controls a game
func NewGameController ¶
func NewGameController() (c *GameController)
NewGameController creates a new RefBox
func (*GameController) OnNewEvent ¶
func (c *GameController) OnNewEvent(event Event)
OnNewEvent processes the given event
func (*GameController) ProcessAutoRefRequests ¶ added in v0.8.0
func (c *GameController) ProcessAutoRefRequests(id string, request refproto.AutoRefToController) error
func (*GameController) ProcessGeometry ¶ added in v0.9.0
func (c *GameController) ProcessGeometry(data *sslproto.SSL_GeometryData)
func (*GameController) ProcessTeamRequests ¶ added in v0.8.0
func (c *GameController) ProcessTeamRequests(teamName string, request refproto.TeamToController) error
func (*GameController) Run ¶
func (c *GameController) Run()
Run the GameController by starting several go-routines. This method will not block.
type GameEvent ¶ added in v0.8.0
type GameEvent struct { Type GameEventType `json:"type"` Details GameEventDetails `json:"details"` Origins []string `json:"origins"` }
GameEvent combines the type of a game event with the corresponding detail structures
func (GameEvent) AddsRedCard ¶ added in v0.8.0
AddsRedCard checks if this game event causes a red card
func (GameEvent) AddsYellowCard ¶ added in v0.8.0
AddsYellowCard checks if this game event causes a yellow card
func (GameEvent) ByTeam ¶ added in v0.8.0
ByTeam extracts the `ByTeam` attribute from the game event details
func (GameEvent) IncrementsFoulCounter ¶ added in v0.8.0
IncrementsFoulCounter checks if the game event increments the foul counter
func (GameEvent) IsContinueGame ¶ added in v0.9.0
IsContinueGame checks if the game event should trigger continuing the game based on the current primary event
func (GameEvent) IsSecondary ¶ added in v0.8.0
IsSecondary checks if this game event is a secondary one that does not influence the next referee command
func (GameEvent) IsSkipped ¶ added in v0.11.0
IsSkipped checks if the game event is a skipped one (one for which the game was not stopped based on the decision of a team)
type GameEventBehavior ¶ added in v0.10.0
type GameEventBehavior string
const ( GameEventBehaviorOn GameEventBehavior = "on" GameEventBehaviorMajority GameEventBehavior = "majority" GameEventBehaviorOff GameEventBehavior = "off" )
func (GameEventBehavior) Valid ¶ added in v0.19.0
func (b GameEventBehavior) Valid() bool
Valid checks if the GameEventBehavior enum value is among the known values
type GameEventDetails ¶ added in v0.8.0
type GameEventDetails struct { BallLeftFieldTouchLine *refproto.GameEvent_BallLeftField `json:"ballLeftFieldTouchLine,omitempty"` BallLeftFieldGoalLine *refproto.GameEvent_BallLeftField `json:"ballLeftFieldGoalLine,omitempty"` AimlessKick *refproto.GameEvent_AimlessKick `json:"aimlessKick,omitempty"` PossibleGoal *refproto.GameEvent_Goal `json:"possibleGoal,omitempty"` Goal *refproto.GameEvent_Goal `json:"goal,omitempty"` IndirectGoal *refproto.GameEvent_IndirectGoal `json:"indirectGoal,omitempty"` ChippedGoal *refproto.GameEvent_ChippedGoal `json:"chippedGoal,omitempty"` BotTooFastInStop *refproto.GameEvent_BotTooFastInStop `json:"botTooFastInStop,omitempty"` BotTippedOver *refproto.GameEvent_BotTippedOver `json:"botTippedOver,omitempty"` BotInterferedPlacement *refproto.GameEvent_BotInterferedPlacement `json:"botInterferedPlacement,omitempty"` BotCrashDrawn *refproto.GameEvent_BotCrashDrawn `json:"botCrashDrawn,omitempty"` BotKickedBallTooFast *refproto.GameEvent_BotKickedBallTooFast `json:"botKickedBallTooFast,omitempty"` BotDribbledBallTooFar *refproto.GameEvent_BotDribbledBallTooFar `json:"botDribbledBallTooFar,omitempty"` BotCrashUnique *refproto.GameEvent_BotCrashUnique `json:"botCrashUnique,omitempty"` BotCrashUniqueSkipped *refproto.GameEvent_BotCrashUnique `json:"botCrashUniqueSkipped,omitempty"` BotPushedBot *refproto.GameEvent_BotPushedBot `json:"botPushedBot,omitempty"` BotPushedBotSkipped *refproto.GameEvent_BotPushedBot `json:"botPushedBotSkipped,omitempty"` BotHeldBallDeliberately *refproto.GameEvent_BotHeldBallDeliberately `json:"botHeldBallDeliberately,omitempty"` AttackerDoubleTouchedBall *refproto.GameEvent_AttackerDoubleTouchedBall `json:"attackerDoubleTouchedBall,omitempty"` AttackerTooCloseToDefenseArea *refproto.GameEvent_AttackerTooCloseToDefenseArea `json:"attackerTooCloseToDefenseArea,omitempty"` AttackerInDefenseArea *refproto.GameEvent_AttackerInDefenseArea `json:"attackerInDefenseArea,omitempty"` AttackerTouchedKeeper *refproto.GameEvent_AttackerTouchedKeeper `json:"attackerTouchedKeeper,omitempty"` DefenderTooCloseToKickPoint *refproto.GameEvent_DefenderTooCloseToKickPoint `json:"defenderTooCloseToKickPoint,omitempty"` DefenderInDefenseAreaPartially *refproto.GameEvent_DefenderInDefenseAreaPartially `json:"defenderInDefenseAreaPartially,omitempty"` DefenderInDefenseArea *refproto.GameEvent_DefenderInDefenseArea `json:"defenderInDefenseArea,omitempty"` KeeperHeldBall *refproto.GameEvent_KeeperHeldBall `json:"keeperHeldBall,omitempty"` UnsportingBehaviorMinor *refproto.GameEvent_UnsportingBehaviorMinor `json:"unsportingBehaviorMinor,omitempty"` UnsportingBehaviorMajor *refproto.GameEvent_UnsportingBehaviorMajor `json:"unsportingBehaviorMajor,omitempty"` MultipleCards *refproto.GameEvent_MultipleCards `json:"multiple,omitempty"` MultipleFouls *refproto.GameEvent_MultipleFouls `json:"multipleFouls,omitempty"` MultiplePlacementFailures *refproto.GameEvent_MultiplePlacementFailures `json:"multiplePlacementFailures,omitempty"` KickTimeout *refproto.GameEvent_KickTimeout `json:"kickTimeout,omitempty"` NoProgressInGame *refproto.GameEvent_NoProgressInGame `json:"noProgressInGame,omitempty"` PlacementFailed *refproto.GameEvent_PlacementFailed `json:"placementFailed,omitempty"` PlacementSucceeded *refproto.GameEvent_PlacementSucceeded `json:"placementSucceeded,omitempty"` Prepared *refproto.GameEvent_Prepared `json:"prepared,omitempty"` BotSubstitution *refproto.GameEvent_BotSubstitution `json:"botSubstitution,omitempty"` TooManyRobots *refproto.GameEvent_TooManyRobots `json:"tooManyRobots,omitempty"` }
GameEventDetails holds details of a game event. Only one field should be non-nil
func GameEventDetailsFromProto ¶ added in v0.16.0
func GameEventDetailsFromProto(event refproto.GameEvent) (d GameEventDetails)
GameEventDetailsFromProto converts a protobuf game event into internal details
func (GameEventDetails) EventType ¶ added in v0.8.0
func (d GameEventDetails) EventType() GameEventType
EventType returns the internal game event type of game event details
func (GameEventDetails) String ¶ added in v0.16.0
func (d GameEventDetails) String() string
String converts the game event details to a string
type GameEventProposal ¶ added in v0.10.0
type GameEventProposal struct { ProposerId string `json:"proposerId"` GameEvent GameEvent `json:"gameEvent"` ValidUntil time.Time `json:"validUntil"` }
GameEventProposal holds a proposal for a game event from an autoRef
type GameEventType ¶ added in v0.3.0
type GameEventType string
const ( GameEventNone GameEventType = "" GameEventPrepared GameEventType = "prepared" GameEventNoProgressInGame GameEventType = "noProgressInGame" GameEventPlacementFailed GameEventType = "placementFailed" GameEventPlacementSucceeded GameEventType = "placementSucceeded" GameEventBotSubstitution GameEventType = "botSubstitution" GameEventTooManyRobots GameEventType = "tooManyRobots" GameEventBallLeftFieldTouchLine GameEventType = "ballLeftFieldTouchLine" GameEventBallLeftFieldGoalLine GameEventType = "ballLeftFieldGoalLine" GameEventPossibleGoal GameEventType = "possibleGoal" GameEventGoal GameEventType = "goal" GameEventIndirectGoal GameEventType = "indirectGoal" GameEventChippedGoal GameEventType = "chippedGoal" GameEventAimlessKick GameEventType = "aimlessKick" GameEventKickTimeout GameEventType = "kickTimeout" GameEventKeeperHeldBall GameEventType = "keeperHeldBall" GameEventAttackerDoubleTouchedBall GameEventType = "attackerDoubleTouchedBall" GameEventAttackerInDefenseArea GameEventType = "attackerInDefenseArea" GameEventAttackerTouchedKeeper GameEventType = "attackerTouchedKeeper" GameEventBotDribbledBallTooFar GameEventType = "botDribbledBallTooFar" GameEventBotKickedBallTooFast GameEventType = "botKickedBallTooFast" GameEventAttackerTooCloseToDefenseArea GameEventType = "attackerTooCloseToDefenseArea" GameEventBotInterferedPlacement GameEventType = "botInterferedPlacement" GameEventBotCrashDrawn GameEventType = "botCrashDrawn" GameEventBotCrashUnique GameEventType = "botCrashUnique" GameEventBotCrashUniqueSkipped GameEventType = "botCrashUniqueSkipped" GameEventBotPushedBot GameEventType = "botPushedBot" GameEventBotPushedBotSkipped GameEventType = "botPushedBotSkipped" GameEventBotHeldBallDeliberately GameEventType = "botHeldBallDeliberately" GameEventBotTippedOver GameEventType = "botTippedOver" GameEventBotTooFastInStop GameEventType = "botTooFastInStop" GameEventDefenderTooCloseToKickPoint GameEventType = "defenderTooCloseToKickPoint" GameEventDefenderInDefenseAreaPartially GameEventType = "defenderInDefenseAreaPartially" GameEventDefenderInDefenseArea GameEventType = "defenderInDefenseArea" GameEventMultipleCards GameEventType = "multipleCards" GameEventMultiplePlacementFailures GameEventType = "multiplePlacementFailures" GameEventMultipleFouls GameEventType = "multipleFouls" GameEventUnsportingBehaviorMinor GameEventType = "unsportingBehaviorMinor" GameEventUnsportingBehaviorMajor GameEventType = "unsportingBehaviorMajor" )
func AllGameEvents ¶ added in v0.10.0
func AllGameEvents() []GameEventType
AllGameEvents returns a list of all known game events
func (GameEventType) Valid ¶ added in v0.19.0
func (g GameEventType) Valid() bool
Valid checks if the GameEventType enum value is among the known values
type GameState ¶
type GameState string
GameState of a game
const ( // GameStateHalted halted GameStateHalted GameState = "Halted" // GameStateStopped stopped GameStateStopped GameState = "Stopped" // GameStateRunning running GameStateRunning GameState = "Running" // GameStatePreKickoff kickoff GameStatePreKickoff GameState = "Prepare Kickoff" // GameStatePrePenalty penalty GameStatePrePenalty GameState = "Prepare Penalty" // GameStateTimeout timeout GameStateTimeout GameState = "Timeout" // GameStateBallPlacement ball placement GameStateBallPlacement GameState = "Ball Placement" )
type History ¶ added in v0.3.0
type History []HistoryEntry
type HistoryEntry ¶ added in v0.3.0
type HistoryEntry struct { State State UiProtocol []UiProtocolEntry }
type HistoryPreserver ¶ added in v0.3.0
type HistoryPreserver struct {
// contains filtered or unexported fields
}
func (*HistoryPreserver) Close ¶ added in v0.3.0
func (r *HistoryPreserver) Close()
Close closes the history file
func (*HistoryPreserver) CloseOnExit ¶ added in v0.26.0
func (r *HistoryPreserver) CloseOnExit()
CloseOnExit makes sure to close the file when program exists
func (*HistoryPreserver) Load ¶ added in v0.3.0
func (r *HistoryPreserver) Load() (*History, error)
Load loads the history from the filesystem
func (*HistoryPreserver) Open ¶ added in v0.3.0
func (r *HistoryPreserver) Open() error
Open opens the history file
func (*HistoryPreserver) Save ¶ added in v0.3.0
func (r *HistoryPreserver) Save(history History)
Save writes the current state into a file
type MessageWrapper ¶ added in v0.3.0
type MessageWrapper struct { State *State `json:"state"` UiProtocol *[]UiProtocolEntry `json:"gameEvents"` EngineState *EngineState `json:"engineState"` }
type Publisher ¶
type Publisher struct { Message RefMessage // contains filtered or unexported fields }
Publisher can publish state and commands to the teams
func NewPublisher ¶
NewPublisher creates a new publisher that publishes referee messages via UDP to the teams
type RefCommand ¶
type RefCommand string
RefCommand is a command to be send to the teams
const ( // CommandUnknown not set CommandUnknown RefCommand = "" // CommandHalt HALT CommandHalt RefCommand = "halt" // CommandStop STOP CommandStop RefCommand = "stop" // CommandNormalStart NORMAL_START CommandNormalStart RefCommand = "normalStart" // CommandForceStart FORCE_START CommandForceStart RefCommand = "forceStart" // CommandDirect DIRECT CommandDirect RefCommand = "direct" // CommandIndirect INDIRECT CommandIndirect RefCommand = "indirect" // CommandKickoff KICKOFF CommandKickoff RefCommand = "kickoff" // CommandPenalty PENALTY CommandPenalty RefCommand = "penalty" // CommandTimeout TIMEOUT CommandTimeout RefCommand = "timeout" // CommandBallPlacement BALL_PLACEMENT CommandBallPlacement RefCommand = "ballPlacement" )
func (RefCommand) ContinuesGame ¶ added in v0.9.0
func (c RefCommand) ContinuesGame() bool
func (RefCommand) IsFreeKick ¶ added in v0.19.0
func (c RefCommand) IsFreeKick() bool
func (RefCommand) NeedsTeam ¶ added in v0.19.0
func (c RefCommand) NeedsTeam() bool
func (RefCommand) Valid ¶ added in v0.19.0
func (c RefCommand) Valid() bool
Valid checks if the RefCommand enum value is among the known values
type RefMessage ¶ added in v0.8.0
type RefMessage struct { ProtoMsg *refproto.Referee Send func() // contains filtered or unexported fields }
func (*RefMessage) Publish ¶ added in v0.8.0
func (p *RefMessage) Publish(state *State)
Publish the state and command
type Stage ¶
type Stage string
Stage represents the different stages of a game
const ( // StagePreGame before game has started StagePreGame Stage = "Pre-First Half" // StageFirstHalf in first half StageFirstHalf Stage = "First Half" // StageHalfTime in half time StageHalfTime Stage = "Half Time" // StageSecondHalfPre before second half StageSecondHalfPre Stage = "Pre-Second Half" // StageSecondHalf in second half StageSecondHalf Stage = "Second Half" // StageOvertimeBreak in break to overtime StageOvertimeBreak Stage = "Overtime Break" // StageOvertimeFirstHalfPre before first overtime half StageOvertimeFirstHalfPre Stage = "Pre-Overtime First Half" // StageOvertimeFirstHalf in first overtime half StageOvertimeFirstHalf Stage = "Overtime First Half" // StageOvertimeHalfTime in overtime half time StageOvertimeHalfTime Stage = "Overtime Half Time" // StageOvertimeSecondHalfPre before second overtime half StageOvertimeSecondHalfPre Stage = "Pre-Overtime Second Half" // StageOvertimeSecondHalf in second overtime half StageOvertimeSecondHalf Stage = "Overtime Second Half" // StageShootoutBreak in break to shootout StageShootoutBreak Stage = "Shootout Break" // StageShootout in Shootout StageShootout Stage = "Shootout" // StagePostGame after game ended StagePostGame Stage = "End of Game" )
func (Stage) IsPausedStage ¶ added in v0.6.0
func (Stage) IsPreStage ¶
type StageOperation ¶
type StageOperation string
StageOperation to apply on the current stage
const ( // StageNext next stage StageNext StageOperation = "next" // StagePrevious previous stage StagePrevious StageOperation = "previous" // StageEndGame ends the game StageEndGame StageOperation = "endGame" )
type State ¶
type State struct { Stage Stage `json:"stage" yaml:"stage"` Command RefCommand `json:"command" yaml:"command"` CommandFor Team `json:"commandForTeam" yaml:"commandForTeam"` GameEvents []*GameEvent `json:"gameEvents" yaml:"gameEvents"` StageTimeElapsed time.Duration `json:"stageTimeElapsed" yaml:"stageTimeElapsed"` StageTimeLeft time.Duration `json:"stageTimeLeft" yaml:"stageTimeLeft"` MatchTimeStart time.Time `json:"matchTimeStart" yaml:"matchTimeStart"` MatchDuration time.Duration `json:"matchDuration" yaml:"matchDuration"` // MatchDuration contains the updated match duration based on MatchTimeStart for the UI TeamState map[Team]*TeamInfo `json:"teamState" yaml:"teamState"` Division config.Division `json:"division" yaml:"division"` PlacementPos *Location `json:"placementPos" yaml:"placementPos"` AutoContinue bool `json:"autoContinue" yaml:"autoContinue"` NextCommand RefCommand `json:"nextCommand" yaml:"nextCommand"` NextCommandFor Team `json:"nextCommandFor" yaml:"nextCommandFor"` GameEventBehavior map[GameEventType]GameEventBehavior `json:"gameEventBehavior" yaml:"gameEventBehavior"` GameEventProposals []*GameEventProposal `json:"gameEventProposals" yaml:"gameEventProposals"` CurrentActionDeadline time.Time `json:"currentActionDeadline" yaml:"currentActionDeadline"` CurrentActionTimeRemaining time.Duration `json:"currentActionTimeRemaining" yaml:"currentActionTimeRemaining"` // CurrentActionTimeRemaining contains the updated remaining lack of progress time for the UI }
State of the game
func NewState ¶
func NewState() (s *State)
NewState creates a new state, initialized for the start of a new game
func (State) BotSubstitutionIntend ¶ added in v0.11.0
func (*State) GetFirstGameEvent ¶ added in v0.19.0
func (s *State) GetFirstGameEvent(gameEventType GameEventType) *GameEvent
func (*State) PrimaryGameEvent ¶ added in v0.14.0
func (*State) TeamByName ¶ added in v0.8.0
type Team ¶
type Team string
Team is one of Yellow or Blue
func NewTeam ¶ added in v0.8.0
NewTeam creates a team from a protobuf team. Its either a single team or unknown. Not both.
func (Team) Is ¶ added in v0.23.1
Is returns true, if the team is equal to given team, respecting unknown and both accordingly
func (Team) Opposite ¶
Opposite returns the other team if the team is not Yellow or Blue, return the same team
type TeamChoice ¶ added in v0.8.0
TeamChoice represents an outstanding team choice request
type TeamInfo ¶
type TeamInfo struct { Name string `json:"name" yaml:"name"` Goals int `json:"goals" yaml:"goals"` Goalkeeper int `json:"goalkeeper" yaml:"goalkeeper"` YellowCards int `json:"yellowCards" yaml:"yellowCards"` YellowCardTimes []time.Duration `json:"yellowCardTimes" yaml:"yellowCardTimes"` RedCards int `json:"redCards" yaml:"redCards"` TimeoutsLeft int `json:"timeoutsLeft" yaml:"timeoutsLeft"` TimeoutTimeLeft time.Duration `json:"timeoutTimeLeft" yaml:"timeoutTimeLeft"` OnPositiveHalf bool `json:"onPositiveHalf" yaml:"onPositiveHalf"` FoulCounter int `json:"foulCounter" yaml:"foulCounter"` BallPlacementFailures int `json:"ballPlacementFailures" yaml:"ballPlacementFailures"` CanPlaceBall bool `json:"canPlaceBall" yaml:"canPlaceBall"` MaxAllowedBots int `json:"maxAllowedBots" yaml:"maxAllowedBots"` BotSubstitutionIntend bool `json:"botSubstitutionIntend" yaml:"botSubstitutionIntend"` }
TeamInfo about a team
type TriggerType ¶
type TriggerType string
TriggerType is something that can be triggered
const ( // TriggerResetMatch reset match TriggerResetMatch TriggerType = "resetMatch" // TriggerSwitchColor switch color TriggerSwitchColor TriggerType = "switchColor" // TriggerSwitchSides switch sides/goals (onPositiveHalf) TriggerSwitchSides TriggerType = "switchSides" // TriggerUndo undo last action TriggerUndo TriggerType = "undo" // TriggerContinue continues based on the current game event TriggerContinue TriggerType = "continue" )
type UiProtocolEntry ¶ added in v0.16.0
type UiProtocolEntry struct { Timestamp int64 `json:"timestamp"` StageTime time.Duration `json:"stageTime"` Type UiProtocolType `json:"type"` Name string `json:"name"` Team Team `json:"team"` Description string `json:"description"` }
UiProtocolEntry represents a single protocol entry as should be displayed in the UI table
type UiProtocolType ¶ added in v0.16.0
type UiProtocolType string
UiProtocolType represents the type of a protocol entry
const ( // UiProtocolCommand represents an issued referee command UiProtocolCommand UiProtocolType = "command" // UiProtocolStage represents a changed stage UiProtocolStage UiProtocolType = "stage" // UiProtocolCard represents an issued card UiProtocolCard UiProtocolType = "card" // UiProtocolTime represents an elapsed time, like stage time or card time UiProtocolTime UiProtocolType = "time" // UiProtocolGameEvent represents an issued game event UiProtocolGameEvent UiProtocolType = "gameEvent" // UiProtocolGameEventIgnored represents a detected game event that was not issued UiProtocolGameEventIgnored UiProtocolType = "ignoredGameEvent" // UiProtocolModify represents a manual modification on the state UiProtocolModify UiProtocolType = "modify" // UiProtocolTeamAction represents an action from a team UiProtocolTeamAction UiProtocolType = "teamAction" // UiProtocolHint represents a hint to the human game-controller operator UiProtocolHint UiProtocolType = "hint" )