Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
var AwayTeamGoal = Goal{ Place: HomeTeam, Center: physics.Point{PosX: units.CourtWidth, PosY: units.CourtHeight / 2}, TopPole: physics.Point{PosX: units.CourtWidth, PosY: units.GoalMaxY}, BottomPole: physics.Point{PosX: units.CourtWidth, PosY: units.GoalMinY}, }
AwayTeamGoal works as a constant value to help to retrieve a Goal struct with the values of the Away team goal
var CourtCenter = physics.Point{units.CourtWidth / 2, units.CourtHeight / 2}
CourtCenter works as a constant value to help to retrieve a Point struct with the values of the center of the court
var HomeTeamGoal = Goal{ Place: HomeTeam, Center: physics.Point{PosX: 0, PosY: units.CourtHeight / 2}, TopPole: physics.Point{PosX: 0, PosY: units.GoalMaxY}, BottomPole: physics.Point{PosX: 0, PosY: units.GoalMinY}, }
HomeTeamGoal works as a constant value to help to retrieve a Goal struct with the values of the Home team goal
Functions ¶
func Cleanup ¶
func Cleanup(interrupted bool)
Cleanup executes all cleaner functions in the stack passing the arg that tells if the process was interrupted or not
func RegisterCleaner ¶
RegisterCleaner creates a stack of call back functions to be executed when the main process ends
Types ¶
type Cleaner ¶
type Cleaner struct {
// contains filtered or unexported fields
}
Cleaner binds a callback function and a label to help us to identify the tasks that are executed during the cleaning stack
type GameState ¶
type GameState string
GameState is a game state
const ( //WaitingTeams game state when the game server is waiting for both team's players connections WaitingTeams GameState = "waiting" //Listening game state when the game server is listening the player for orders Listening GameState = "listening" //Playing game state when the game server is executing the orders sent during the last `listening` state Playing GameState = "playing" //Pause game state when the game server is paused by a debug command and waiting for the `next step` signal Pause GameState = "pause" //Results game state when the game server is announcing the score change Results GameState = "results" //Over game state when the game server is is announcing the end of the game Over GameState = "game-over" )
type Goal ¶
type Goal struct {
// Center the is coordinate of the center of the goal
Center physics.Point
// Place identifies the team of this goal (the team that should defend this goal)
Place TeamPlace
// TopPole is the coordinates of the pole with a higher Y coordinate
TopPole physics.Point
// BottomPole is the coordinates of the pole with a lower Y coordinate
BottomPole physics.Point
}
Goal is a set of value about a goal from a team
type JumpOrderData ¶
JumpOrderData is the expected format of the data field of an order when it's type is Jump
type KickOrderData ¶
KickOrderData is the expected format of the data field of an order when it's type is KICK
type MoveOrderData ¶
MoveOrderData is the expected format of the data field of an order when it's type is MOVE
type MsgType ¶
type MsgType string
MsgType define strings acceptable as types of game msg
const ( // ORDER is the msg sent from the player to the game server ORDER MsgType = "order" // ANNOUNCEMENT is sent from the game server to the players and to the web clients to update them with a new game state ANNOUNCEMENT MsgType = "announcement" // DEBUG is a message sent by http POST request from the web client to the game server (debug mode must be on) DEBUG MsgType = "debug" // SCORE is a message sent by the game server when the score was changed SCORE MsgType = "score" // RIP is a message sent by the game server when the game server crashes RIP MsgType = "rip" // WELCOME is a message sent by the game server to each player when the new websocket connection is accepted. WELCOME MsgType = "welcome" )
type Order ¶
type Order struct {
Type OrderType `json:"order"`
Data interface{} `json:"data"`
}
Order is a orders sent by the player to the game server during the LISTENING state
func NewCatchOrder ¶
func NewCatchOrder() Order
func NewJumpOrder ¶
func NewKickOrder ¶
func NewMoveOrder ¶
func (*Order) GetJumpOrderData ¶
func (o *Order) GetJumpOrderData() JumpOrderData
GetJumpOrderData returns the Data order field in JumpOrderData format
func (*Order) GetKickOrderData ¶
func (o *Order) GetKickOrderData() KickOrderData
GetKickOrderData returns the Data order field in KickOrderData format
func (*Order) GetMoveOrderData ¶
func (o *Order) GetMoveOrderData() MoveOrderData
GetMoveOrderData returns the Data order field in MoveOrderData format
func (*Order) UnmarshalJSON ¶
UnmarshalJSON implements the UnmarshalJSON interface for orders
type OrderType ¶
type OrderType string
OrderType identifies types of orders that are acceptable by the game server
const ( // MOVE is order to change the direction and speed of the player MOVE OrderType = "MOVE" // KICK is the order sent by the ball holder to release the ball and changes its direction and speed // the current ball direction will be summed with the new direction set by the order KICK OrderType = "KICK" // CATCH is an order to try to catch the ball, that has to being touched by the player CATCH OrderType = "CATCH" // JUMP is an action executed only by goal keepers! It allow the goal keeper to use extra speed during a short interval JUMP OrderType = "JUMP" )
type PlayerNumber ¶
type PlayerNumber string
PlayerNumber identifies values for players number
const ( // GoalkeeperNumber defines the goalkeeper number GoalkeeperNumber PlayerNumber = "1" )
type PlayerSpecifications ¶
type PlayerSpecifications struct {
// Number identifies the number of the player in its team
Number PlayerNumber `json:"number"`
// InitialCoords identifies where default initial player's position is
InitialCoords physics.Point `json:"initial_coords"`
// Token should be passed as an argument to the player to ensure that the connection is being openned by the expected process
Token string `json:"token"`
// ProtocolVersion identifies the game server communication version the player is compatible with (e.g. 1.0)
ProtocolVersion string `json:"protocol_version"`
}
PlayerSpecifications is the object that should be present in the HTTP websocket headers connection open by the player with the game server
type Task ¶
type Task struct {
OnStop func(*Task)
// contains filtered or unexported fields
}
Task allow us to create a task in background
func (*Task) StopRequested ¶
StopRequested returns true when the task was requested to stop