Documentation ¶
Index ¶
- func TalkerSetup(mainCtx GamerCtx, config *Configuration, initialPos physics.Point) (context.Context, talk.Talker, error)
- type Ball
- type Configuration
- type Controller
- type GameInfo
- type GameMessage
- type Gamer
- type GamerCtx
- type Player
- func (p *Player) CreateCatchOrder() orders.Order
- func (p *Player) CreateJumpOrder(target physics.Point, speed float64) (orders.Order, error)
- func (p *Player) CreateKickOrder(ball Ball, target physics.Point, speed float64) (orders.Order, error)
- func (p *Player) CreateMoveOrder(target physics.Point, speed float64) (orders.Order, error)
- func (p *Player) CreateMoveOrderMaxSpeed(target physics.Point) (orders.Order, error)
- func (p *Player) CreateStopOrder(direction physics.Vector) orders.Order
- func (p *Player) DefenseGoal() arena.Goal
- func (p *Player) FindOpponentPlayer(status GameInfo, playerNumber arena.PlayerNumber) *Player
- func (p *Player) GetMyTeamStatus(gameInfo GameInfo) Team
- func (p *Player) GetOpponentPlace() arena.TeamPlace
- func (p *Player) GetOpponentTeam(status GameInfo) Team
- func (p *Player) ID() string
- func (p *Player) IHoldTheBall(ball Ball) bool
- func (p *Player) IsGoalkeeper() bool
- func (p *Player) OpponentGoal() arena.Goal
- type PlayerMessage
- type Responder
- type Team
- type TurnContext
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Ball ¶
type Ball struct { physics.Element // Holder identifies the player who is holding the ball Holder *Player }
Ball is the ball :-)
type Configuration ¶
type Configuration struct { // TeamPlace must be "home" or "away" and identifies the side of the field that the team is going to play TeamPlace arena.TeamPlace // PlayerNumber must be a number between 1-11 that identifies this player in his team PlayerNumber arena.PlayerNumber LogLevel logrus.Level // UUID is the match UUID. It will be always local for local games UUID string // WSHost is the hostname of the game server (only HTTP for now) WSHost string // WSPort is the port used by the game server WSPort string // Token is passed to the game server to bind the player to specific process, and avoid cheating Token string }
Configuration is the set of values expected as a initial configuration of the player
func (*Configuration) ParseFromFlags ¶
func (c *Configuration) ParseFromFlags()
ParseFromFlags sets the flag that will allows us to change the default config
type Controller ¶
type Controller interface { SendOrders(place arena.TeamPlace, number arena.PlayerNumber, orderList []orders.Order) //ToggleDebugMode() NextTurn() (newState GameMessage, err error) LoadArrangement(name string) (newState GameMessage, err error) SetBallProperties(v physics.Velocity, position physics.Point) (newState GameMessage, err error) SetPlayerPos(place arena.TeamPlace, number arena.PlayerNumber, position physics.Point) (newState GameMessage, err error) SetGameTurn(turn int) (newState GameMessage, err error) ResetScore() (newState GameMessage, err error) SetFrameInterval(time time.Duration) GetGamerCtx(place arena.TeamPlace, number arena.PlayerNumber) (ctx TurnContext, err error) }
func NewTestController ¶
func NewTestController(ctx context.Context, confg Configuration) (context.Context, Controller, error)
type GameInfo ¶
type GameInfo struct { State arena.GameState `json:"state"` // Turn is the sequential number of turns. Read the game documentation to understand what a turn is Turn int `json:"turn"` Ball Ball `json:"ball"` HomeTeam Team `json:"home"` AwayTeam Team `json:"away"` }
GameInfo is the set of values that defines the current game state
type GameMessage ¶
type GameMessage struct { Type arena.MsgType `json:"type"` GameInfo GameInfo `json:"info"` State arena.GameState `json:"state"` Data map[string]interface{} `json:"data"` // Message is quite useless, but could help the developers to debug the game server messages Message string `json:"message"` }
GameMessage is the message sent from the game server to the player
func (*GameMessage) Ball ¶
func (g *GameMessage) Ball() Ball
func (*GameMessage) ForEachPlayByTeam ¶
func (g *GameMessage) ForEachPlayByTeam(place arena.TeamPlace, callback func(index int, player *Player))
func (*GameMessage) Turn ¶
func (g *GameMessage) Turn() int
type Gamer ¶
type Gamer struct { OnMessage func(msg GameMessage) OnAnnouncement func(turnTx TurnContext) LogLevel logrus.Level Talker talk.Talker LastMsg GameMessage // contains filtered or unexported fields }
func (*Gamer) SendOrders ¶
SendOrders sends a list of orders to the game server, and includes a message to them (only displayed in the game server log)
func (*Gamer) StopToPlay ¶
StopToPlay stop the player to play
type GamerCtx ¶
type GamerCtx interface { context.Context Logger() *logrus.Entry CreateTurnContext(msg GameMessage) TurnContext }
func NewGamerContext ¶
func NewGamerContext(ctx context.Context, config *Configuration) (GamerCtx, context.CancelFunc)
type Player ¶
type Player struct { physics.Element Id string `json:"id"` Number arena.PlayerNumber `json:"number"` TeamPlace arena.TeamPlace `json:"team_place"` }
func (*Player) CreateCatchOrder ¶
CreateCatchOrder creates the catch order
func (*Player) CreateJumpOrder ¶
CreateJumpOrder creates a jump order (only allowed to goal keeper
func (*Player) CreateKickOrder ¶
func (p *Player) CreateKickOrder(ball Ball, target physics.Point, speed float64) (orders.Order, error)
CreateKickOrder creates a kick order and try to find the best vector to reach the target
func (*Player) CreateMoveOrder ¶
CreateMoveOrder creates a move order
func (*Player) CreateMoveOrderMaxSpeed ¶
CreateMoveOrderMaxSpeed creates a move order with max speed allowed
func (*Player) CreateStopOrder ¶
CreateStopOrder creates a move order with speed zero
func (*Player) DefenseGoal ¶
DefenseGoal returns the player team goal
func (*Player) FindOpponentPlayer ¶
func (p *Player) FindOpponentPlayer(status GameInfo, playerNumber arena.PlayerNumber) *Player
FindOpponentPlayer retrieve a specific opponent player status from the game server message
func (*Player) GetMyTeamStatus ¶
GetMyTeamStatus retrieve the player team status from the game server message
func (*Player) GetOpponentPlace ¶
func (*Player) GetOpponentTeam ¶
GetOpponentTeam retrieve the opponent team status from the game server message
func (*Player) IHoldTheBall ¶
IHoldTheBall returns true when the player is holding the ball
func (*Player) IsGoalkeeper ¶
IsGoalkeeper returns true if the player is the goalkeeper
func (*Player) OpponentGoal ¶
OpponentGoal returns the Goal os the opponent
type PlayerMessage ¶
type PlayerMessage struct { Type arena.MsgType `json:"type"` Orders []orders.Order `json:"orders"` // Debug is a message the will be only visible in the game server log (used for debugging purposes) Debug string `json:"message"` }
PlayerMessage is the message sent from a player to the game server
type Team ¶
type Team struct { Name arena.TeamPlace `json:"name"` Score int `json:"score"` Players []*Player `json:"players"` }
Team groups the player team info based on the status sent by the game server