controller

package
v0.15.1 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2018 License: GPL-3.0 Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Stages include all available stages, ordered

Functions

This section is empty.

Types

type ApiServer

type ApiServer struct {
	Consumer EventConsumer
	// contains filtered or unexported fields
}

func (*ApiServer) PublishRefereeEvents added in v0.6.0

func (a *ApiServer) PublishRefereeEvents(events []RefereeEvent)

func (*ApiServer) PublishState

func (a *ApiServer) PublishState(state State)

func (*ApiServer) PublishWrapper added in v0.3.0

func (a *ApiServer) PublishWrapper(wrapper MessageWrapper)

func (*ApiServer) WsHandler

func (a *ApiServer) WsHandler(w http.ResponseWriter, r *http.Request)

WsHandler handles incoming web socket connections

type CardModification

type CardModification struct {
	CardID   int           `json:"cardId"`
	TimeLeft time.Duration `json:"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 CardType

type CardType string

CardType is one of yellow or red

const (
	// CardTypeYellow yellow card
	CardTypeYellow CardType = "yellow"
	// CardTypeRed red card
	CardTypeRed CardType = "red"
)

type Engine

type Engine struct {
	State         *State
	RefereeEvents []RefereeEvent
	StageTimes    map[Stage]time.Duration

	TimeProvider func() time.Time
	History      History
	Geometry     config.Geometry
	// contains filtered or unexported fields
}

func NewEngine

func NewEngine(config config.Game) (e Engine)

func (*Engine) AddGameEvent added in v0.8.0

func (e *Engine) AddGameEvent(gameEvent GameEvent)

func (*Engine) BallPlacementPos added in v0.8.0

func (e *Engine) BallPlacementPos() *Location

BallPlacementPos determines the ball placement position based on the primary game event

func (*Engine) CardNumberIncremented added in v0.9.0

func (e *Engine) CardNumberIncremented(team Team)

func (*Engine) CommandForEvent added in v0.9.0

func (e *Engine) CommandForEvent(event *GameEvent) (command RefCommand, forTeam Team, err error)

func (*Engine) Continue added in v0.4.0

func (e *Engine) Continue()

func (*Engine) FoulCounterIncremented added in v0.9.0

func (e *Engine) FoulCounterIncremented(team Team)

func (*Engine) LastGameStartCommand added in v0.8.0

func (e *Engine) LastGameStartCommand() (RefCommand, error)

func (*Engine) LogCard added in v0.6.0

func (e *Engine) LogCard(card *EventCard)

func (*Engine) LogCommand added in v0.3.0

func (e *Engine) LogCommand()

func (*Engine) LogGameEvent added in v0.3.0

func (e *Engine) LogGameEvent(event GameEvent)

func (*Engine) LogIgnoredGameEvent added in v0.10.0

func (e *Engine) LogIgnoredGameEvent(event GameEvent)

func (*Engine) LogModify added in v0.9.0

func (e *Engine) LogModify(m EventModifyValue)

func (*Engine) LogStage added in v0.6.0

func (e *Engine) LogStage(stage Stage)

func (*Engine) LogTime added in v0.6.0

func (e *Engine) LogTime(description string, forTeam Team)

func (*Engine) PlacementFailuresIncremented added in v0.9.0

func (e *Engine) PlacementFailuresIncremented(team Team)

func (*Engine) Process

func (e *Engine) Process(event Event) error

func (*Engine) ResetGame

func (e *Engine) ResetGame()

func (*Engine) SendCommand added in v0.4.0

func (e *Engine) SendCommand(command RefCommand, forTeam Team)

func (*Engine) Tick

func (e *Engine) Tick(delta time.Duration)

Tick updates the times of the state and removes cards, if necessary

func (*Engine) UndoLastAction

func (e *Engine) UndoLastAction()

UndoLastAction restores the last state from internal history

type Event

type Event struct {
	Card      *EventCard        `json:"card"`
	Command   *EventCommand     `json:"command"`
	Modify    *EventModifyValue `json:"modify"`
	Stage     *EventStage       `json:"stage"`
	Trigger   *EventTrigger     `json:"trigger"`
	GameEvent *GameEvent        `json:"gameEvent"`
}

Event holds all possible events. Only one at a time can be applied

func (Event) String

func (e Event) String() string

type EventCard

type EventCard struct {
	ForTeam      Team             `json:"forTeam"`
	Type         CardType         `json:"cardType"`
	Operation    CardOperation    `json:"operation"`
	Modification CardModification `json:"modification"`
}

EventCard is an event that can be applied

type EventCommand

type EventCommand struct {
	ForTeam *Team      `json:"forTeam"`
	Type    RefCommand `json:"commandType"`
}

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"`
	Duration string `json:"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"`
	GameEventBehavior GameEventBehavior `json:"gameEventBehavior"`
}

EventModifyGameEventBehavior holds the type to behavior mapping

type EventModifyValue

type EventModifyValue struct {
	ForTeam Team `json:"forTeam,omitempty"`

	Goals                 *int                          `json:"goals,omitempty"`
	Goalie                *int                          `json:"goalie,omitempty"`
	YellowCards           *int                          `json:"yellowCards,omitempty"`
	YellowCardTime        *EventModifyCardTime          `json:"yellowCardTime,omitempty"`
	RedCards              *int                          `json:"redCards,omitempty"`
	TimeoutsLeft          *int                          `json:"timeoutsLeft,omitempty"`
	TimeoutTimeLeft       *string                       `json:"timeoutTimeLeft,omitempty"`
	OnPositiveHalf        *bool                         `json:"onPositiveHalf,omitempty"`
	TeamName              *string                       `json:"teamName,omitempty"`
	FoulCounter           *int                          `json:"foulCounter,omitempty"`
	BallPlacementFailures *int                          `json:"ballPlacementFailures,omitempty"`
	CanPlaceBall          *bool                         `json:"canPlaceBall,omitempty"`
	Division              *config.Division              `json:"division,omitempty"`
	AutoContinue          *bool                         `json:"autoContinue,omitempty"`
	GameEventBehavior     *EventModifyGameEventBehavior `json:"gameEventBehavior,omitempty"`
	BotSubstitutionIntend *bool                         `json:"botSubstitutionIntend,omitempty"`
}

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"`
}

EventStage is an event that can be applied

type EventTrigger

type EventTrigger struct {
	Type TriggerType `json:"triggerType"`
}

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
	Engine        Engine

	Mutex          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)

func (*GameController) ProcessAutoRefRequests added in v0.8.0

func (c *GameController) ProcessAutoRefRequests(id string, request refproto.AutoRefToControllerRequest) 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.TeamToControllerRequest) 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"`
}

GameEvent combines the type of a game event with the corresponding detail structures

func (GameEvent) AddsRedCard added in v0.8.0

func (e GameEvent) AddsRedCard() bool

AddsRedCard checks if this game event causes a red card

func (GameEvent) AddsYellowCard added in v0.8.0

func (e GameEvent) AddsYellowCard() bool

AddsYellowCard checks if this game event causes a yellow card

func (GameEvent) ByTeam added in v0.8.0

func (e GameEvent) ByTeam() Team

ByTeam extracts the `ByTeam` attribute from the game event details

func (GameEvent) IncrementsBallPlacementFailureCounter added in v0.9.0

func (e GameEvent) IncrementsBallPlacementFailureCounter() bool

func (GameEvent) IncrementsFoulCounter added in v0.8.0

func (e GameEvent) IncrementsFoulCounter() bool

IncrementsFoulCounter checks if the game event increments the foul counter

func (GameEvent) IsContinueGame added in v0.9.0

func (e GameEvent) IsContinueGame() bool

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

func (e GameEvent) IsSecondary() bool

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

func (e GameEvent) IsSkipped() bool

IsSkipped checks if the game event is was continued (not stopped) based on the decision of a team

func (GameEvent) String added in v0.9.0

func (e GameEvent) String() string

func (GameEvent) ToProto added in v0.8.0

func (e GameEvent) ToProto() *refproto.GameEvent

type GameEventBehavior added in v0.10.0

type GameEventBehavior string
const (
	GameEventBehaviorOn       GameEventBehavior = "on"
	GameEventBehaviorMajority GameEventBehavior = "majority"
	GameEventBehaviorOff      GameEventBehavior = "off"
)

type GameEventDetails added in v0.8.0

type GameEventDetails struct {
	BallLeftFieldTouchLine         *refproto.GameEvent_BallLeftFieldEvent             `json:"ballLeftFieldTouchLine,omitempty"`
	BallLeftFieldGoalLine          *refproto.GameEvent_BallLeftFieldEvent             `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"`
	PlacementFailedByTeamInFavor   *refproto.GameEvent_PlacementFailedByTeamInFavor   `json:"placementFailedByTeamInFavor,omitempty"`
	PlacementFailedByOpponent      *refproto.GameEvent_PlacementFailedByOpponent      `json:"placementFailedByOpponent,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 NewGameEventDetails added in v0.8.0

func NewGameEventDetails(event refproto.GameEvent) (d GameEventDetails)

func (GameEventDetails) Description added in v0.8.0

func (d GameEventDetails) Description() string

func (GameEventDetails) EventType added in v0.8.0

func (d GameEventDetails) EventType() GameEventType

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"
	GameEventPlacementFailedByTeamInFavor GameEventType = "placementFailedByTeamInFavor"
	GameEventPlacementFailedByOpponent    GameEventType = "placementFailedByOpponent"
	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

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
	RefereeEvents []RefereeEvent
}

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) 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 Location added in v0.8.0

type Location struct {
	X float64
	Y float64
}

Location is a two-dimensional coordinate

type MessageWrapper added in v0.3.0

type MessageWrapper struct {
	State         *State          `json:"state"`
	RefereeEvents *[]RefereeEvent `json:"gameEvents"`
}

type Publisher

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

Publisher can publish state and commands to the teams

func NewPublisher

func NewPublisher(address string) (publisher Publisher, err error)

NewPublisher creates a new publisher that publishes referee messages via UDP to the teams

func (*Publisher) Publish

func (p *Publisher) Publish(state *State)

Publish the state and command

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

type RefMessage added in v0.8.0

type RefMessage struct {
	// 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 RefereeEvent added in v0.3.0

type RefereeEvent struct {
	Timestamp   int64            `json:"timestamp"`
	StageTime   time.Duration    `json:"stageTime"`
	Type        RefereeEventType `json:"type"`
	Name        string           `json:"name"`
	Team        Team             `json:"team"`
	Description string           `json:"description"`
}

type RefereeEventType added in v0.3.0

type RefereeEventType string
const (
	RefereeEventCommand          RefereeEventType = "command"
	RefereeEventStage            RefereeEventType = "stage"
	RefereeEventCard             RefereeEventType = "card"
	RefereeEventTime             RefereeEventType = "time"
	RefereeEventGameEvent        RefereeEventType = "gameEvent"
	RefereeEventGameEventIgnored RefereeEventType = "ignoredGameEvent"
	RefereeEventModify           RefereeEventType = "modify"
)

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 (s Stage) IsPausedStage() bool

func (Stage) IsPreStage

func (s Stage) IsPreStage() bool

func (Stage) Next

func (s Stage) Next() Stage

func (Stage) Previous

func (s Stage) Previous() Stage

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"`
	Command            RefCommand                          `json:"command"`
	CommandFor         Team                                `json:"commandForTeam"`
	GameEvents         []*GameEvent                        `json:"gameEvents"`
	StageTimeElapsed   time.Duration                       `json:"stageTimeElapsed"`
	StageTimeLeft      time.Duration                       `json:"stageTimeLeft"`
	MatchTimeStart     time.Time                           `json:"matchTimeStart"`
	MatchDuration      time.Duration                       `json:"matchDuration"`
	TeamState          map[Team]*TeamInfo                  `json:"teamState"`
	Division           config.Division                     `json:"division"`
	PlacementPos       *Location                           `json:"placementPos"`
	AutoContinue       bool                                `json:"autoContinue"`
	NextCommand        RefCommand                          `json:"nextCommand"`
	NextCommandFor     Team                                `json:"nextCommandFor"`
	AutoRefsConnected  []string                            `json:"autoRefsConnected"`
	GameEventBehavior  map[GameEventType]GameEventBehavior `json:"gameEventBehavior"`
	GameEventProposals []*GameEventProposal                `json:"gameEventProposals"`
}

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 (s State) BotSubstitutionIntend() Team

func (State) DeepCopy added in v0.14.0

func (s State) DeepCopy() (c State)

func (State) GameState

func (s State) GameState() GameState

func (State) PrimaryGameEvent added in v0.14.0

func (s State) PrimaryGameEvent() (e *GameEvent)

func (State) String

func (s State) String() string

func (*State) TeamByName added in v0.8.0

func (s *State) TeamByName(teamName string) Team

type Team

type Team string

Team is one of Yellow or Blue

const (
	// TeamYellow is the yellow team
	TeamYellow Team = "Yellow"
	// TeamBlue is the blue team
	TeamBlue Team = "Blue"
	// TeamUnknown is an unknown team
	TeamUnknown Team = ""
	// TeamBoth are both teams
	TeamBoth = "Both"
)

func NewTeam added in v0.8.0

func NewTeam(team refproto.Team) Team

NewTeam creates a team from a protobuf team

func (Team) Known added in v0.4.0

func (t Team) Known() bool

Known returns true if the team is blue or yellow

func (Team) Opposite

func (t Team) Opposite() Team

Opposite returns the other team if the team is not Yellow or Blue, return the same team

func (Team) Unknown

func (t Team) Unknown() bool

Unknown returns true if the team is not blue or yellow

type TeamChoice added in v0.8.0

type TeamChoice struct {
	Team      Team
	Event     Event
	IssueTime time.Time
}

type TeamInfo

type TeamInfo struct {
	Name                  string          `json:"name"`
	Goals                 int             `json:"goals"`
	Goalie                int             `json:"goalie"`
	YellowCards           int             `json:"yellowCards"`
	YellowCardTimes       []time.Duration `json:"yellowCardTimes"`
	RedCards              int             `json:"redCards"`
	TimeoutsLeft          int             `json:"timeoutsLeft"`
	TimeoutTimeLeft       time.Duration   `json:"timeoutTimeLeft"`
	OnPositiveHalf        bool            `json:"onPositiveHalf"`
	FoulCounter           int             `json:"foulCounter"`
	BallPlacementFailures int             `json:"ballPlacementFailures"`
	CanPlaceBall          bool            `json:"canPlaceBall"`
	MaxAllowedBots        int             `json:"maxAllowedBots"`
	Connected             bool            `json:"connected"`
	BotSubstitutionIntend bool            `json:"botSubstitutionIntend"`
}

TeamInfo about a team

func (TeamInfo) DeepCopy added in v0.14.0

func (t TeamInfo) DeepCopy() (c TeamInfo)

func (TeamInfo) String

func (t TeamInfo) String() string

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"
)

Jump to

Keyboard shortcuts

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