tron

package
v0.0.0-...-c8d16f4 Latest Latest
Warning

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

Go to latest
Published: Apr 4, 2016 License: MIT Imports: 25 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Board

type Board [][]ID

Board represents a board in a game. Each player has a board, which are used to send board deltas.

func NewBoard

func NewBoard(width, height uint8) (Board, error)

NewBoard returns an initialized Board.

type Bot

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

type Config

type Config struct {
	Port         int           `help:"Port to listen for TCP connections on" env:"PORT"`
	Width        int           `help:"Width of the game world" min:"32" max:"256"`
	Height       int           `help:"Height of the game world" min:"32" max:"256"`
	MaxPlayers   int           `help:"Maximum number of simultaneous players"`
	GameSpeed    time.Duration `help:"Game tick interval, basically controls how fast each player moves"`
	RespawnDelay time.Duration `help:"The time a player must wait before being able to respawn"`
	DBLocation   string        `help:"Location of tron.db, stores game score and config"`
	DBReset      bool          `help:"Reset all scores in the database"`
	JoinAddress  string        `help:"A friendly DNS address to present to users"`
	SlackToken   string        `help:"Slack chatroom API token" env:"SLACK_TOKEN"`
	SlackChannel string        `help:"Slack chatroom channel" env:"SLACK_CHANNEL"`
}

type Database

type Database struct {
	*bolt.DB
}

store is a storage mechanism for various game structs. disk or memory.

func NewDatabase

func NewDatabase(loc string, reset bool) (*Database, error)

func (*Database) GetPrivateKey

func (db *Database) GetPrivateKey(s *Server) error

type Direction

type Direction byte

func (Direction) String

func (d Direction) String() string

type Game

type Game struct {
	Config
	// contains filtered or unexported fields
}

func NewGame

func NewGame(c Config) (*Game, error)

NewGame returns an initialized Game according to the input arguments. The main() function should call the Play() method on this Game.

func (*Game) Play

func (g *Game) Play()

type ID

type ID uint16

type Player

type Player struct {
	SSHName, Name string

	Kills, Deaths int // score
	// contains filtered or unexported fields
}

A Player represents a live TCP connection from a client

func NewPlayer

func NewPlayer(id ID, sshName, name, hash string, conn ssh.Channel) *Player

NewPlayer returns an initialized Player.

type Server

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

func NewServer

func NewServer(db *Database, port int, idPool <-chan ID) (*Server, error)

Jump to

Keyboard shortcuts

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