game

package
v0.0.0-...-733c9a9 Latest Latest
Warning

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

Go to latest
Published: Jan 26, 2015 License: Apache-2.0 Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var RandomNames = []string{
	"Washington",
	"Harun al-Rashid",
	"Ashurbanipal",
	"Maria Theresa",
	"Montezuma",
	"Nebuchadnezzar II",
	"Pedro II",
	"Theodora",
	"Dido",
	"Boudicca",
	"Wu Zetian",
	"Harald Bluetooth",
	"Ramesses II",
	"Elizabeth",
	"Haile Selassie",
	"Napoleon",
	"Bismarck",
	"Alexander",
	"Attila",
	"Pachacuti",
	"Gandhi",
	"Gajah Mada",
	"Hiawatha",
	"Oda Nobunaga",
	"Sejong",
	"Pacal",
	"Genghis Khan",
	"Ahmad al-Mansur",
	"William",
	"Suleiman",
	"Darius I",
	"Casimir III",
	"Kamehameha",
	"Maria I",
	"Augustus Caesar",
	"Catherine",
	"Pocatello",
	"Ramkhamhaeng",
	"Askia",
	"Tercio",
	"Gustavus Adolphus",
	"Enrico Dandolo",
	"Shaka",
}
View Source
var Repository = &GameRepository{Games: Games{}, Mutex: sync.Mutex{}}
View Source
var SampleFiles []string

Functions

func NewId

func NewId() string

Types

type Client

type Client struct {
	Username string
	*websocket.Conn
}

func NewClient

func NewClient(username string, conn *websocket.Conn) *Client

type Clients

type Clients []*Client

func (Clients) Contains

func (clients Clients) Contains(c *Client) bool

func (Clients) Serialize

func (clients Clients) Serialize() string

type Game

type Game struct {
	Id string
	Status
	Clients
	MessageChannel
	KillChannel
	CodeFile string
}

func NewGame

func NewGame() *Game

func (*Game) Add

func (g *Game) Add(username string, conn *websocket.Conn) (int, error)

func (*Game) BroadCast

func (g *Game) BroadCast()

func (*Game) Code

func (g *Game) Code() string

func (*Game) KillBroadCast

func (g *Game) KillBroadCast()

func (*Game) Publish

func (g *Game) Publish(event string)

func (*Game) PublishClients

func (g *Game) PublishClients()

func (*Game) PublishFromUser

func (g *Game) PublishFromUser(userId int, char string)

func (*Game) PublishStart

func (g *Game) PublishStart()

func (*Game) RemoveClients

func (g *Game) RemoveClients(toRemove Clients)

func (*Game) Start

func (g *Game) Start()

type GameRepository

type GameRepository struct {
	Games
	sync.Mutex
}

func (*GameRepository) Create

func (gs *GameRepository) Create() *Game

func (*GameRepository) Delete

func (gs *GameRepository) Delete(g *Game)

func (*GameRepository) Find

func (gs *GameRepository) Find(id string) *Game

func (*GameRepository) RandomJoinable

func (gs *GameRepository) RandomJoinable() *Game

type Games

type Games []*Game

func (Games) Find

func (g Games) Find(id string) *Game

func (Games) Joinable

func (games Games) Joinable() Games

type KillChannel

type KillChannel chan bool

type MessageChannel

type MessageChannel chan string

type Status

type Status int
const (
	Created Status = iota
	Started
	Ended
)

type User

type User struct {
	Name string
}

func NewUser

func NewUser(name string) *User

func UserWithRandomName

func UserWithRandomName() *User

Jump to

Keyboard shortcuts

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