arena

package module
v1.1.1 Latest Latest
Warning

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

Go to latest
Published: Nov 17, 2019 License: GPL-3.0 Imports: 3 Imported by: 5

README

Lugo - Arena

GoDoc Go Report Card

Lugo - Arena is a Go module that provides some shareable features between the game server and the clients of Lugo game. This module is meant to be used by the Client Player implemented in Go. However, you may implement another client and use this module as well.

If you wish to use part of this lib for any other project, please let me know if you find bugs, I will fix as soon as I can.

Notes:

  1. Most part of this library code is not tested at the current version (1.1.0). And there is no plans to improve its tests.
  2. This module uses Lugo version 1.* constant values (distance, time, speed). Please, read the game documentation at the Official website for further information about all units.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var AwayTeamGoal = Goal{
	Place:      HomeTeam,
	Center:     physics.Point{PosX: units.FieldWidth, PosY: units.FieldHeight / 2},
	TopPole:    physics.Point{PosX: units.FieldWidth, PosY: units.GoalMaxY},
	BottomPole: physics.Point{PosX: units.FieldWidth, PosY: units.GoalMinY},
}

AwayTeamGoal works as a constant value to help to retrieve a Goal struct with the values of the Away team goal

View Source
var FieldCenter = physics.Point{units.FieldWidth / 2, units.FieldHeight / 2}

FieldCenter works as a constant value to help to retrieve a Point struct with the values of the center of the court

View Source
var HomeTeamGoal = Goal{
	Place:      HomeTeam,
	Center:     physics.Point{PosX: 0, PosY: units.FieldHeight / 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

func RegisterCleaner(name string, callback func(bool))

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"
	//Ready game state when the game server is ready to start
	Ready GameState = "ready"
	//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 MsgType

type MsgType string

MsgType define strings acceptable as types of game msg

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 NewTask

func NewTask(task func(*Task)) *Task

NewTask creates a new task

func (*Task) IsRunning

func (t *Task) IsRunning() bool

IsRunning returns true if the task it still running

func (*Task) RequestStop

func (t *Task) RequestStop()

RequestStop send a stop request to the task

func (*Task) Start

func (t *Task) Start()

Start starts the task

func (*Task) StopRequested

func (t *Task) StopRequested() bool

StopRequested returns true when the task was requested to stop

type TeamPlace

type TeamPlace string

TeamPlace defines a side of the team during the game (left for home team, and right for the away team)

const AwayTeam TeamPlace = "away"

AwayTeam identify the home team

const HomeTeam TeamPlace = "home"

HomeTeam identify the home team

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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