game

package
v0.0.0-...-c992307 Latest Latest
Warning

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

Go to latest
Published: Apr 6, 2015 License: GPL-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AvailableInstruments

func AvailableInstruments() map[InstrumentType]string

Types

type ConnectedPlayer

type ConnectedPlayer struct {
	*Player
	// contains filtered or unexported fields
}

func NewConnectedPlayer

func NewConnectedPlayer(ws *websocket.Conn, player *Player, room *Room) *ConnectedPlayer

func (*ConnectedPlayer) SendMessage

func (cp *ConnectedPlayer) SendMessage(msg string)

type Drums

type Drums struct {
}

func (*Drums) Name

func (d *Drums) Name() string

func (*Drums) Play

func (d *Drums) Play(command string) (string, error)

func (*Drums) Type

func (d *Drums) Type() InstrumentType

type Instrument

type Instrument interface {
	// Returns audio file name
	Play(command string) (string, error)
	Name() string
	Type() InstrumentType
}

func CreateInstrument

func CreateInstrument(t InstrumentType) Instrument

Factory for create instrument

type InstrumentType

type InstrumentType string
const (
	UKULELE InstrumentType = "1"
	DRUMS   InstrumentType = "2"

	DEFAULT_INSTRUMENT = UKULELE
)

type Player

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

func NewPlayer

func NewPlayer(name string, instrument Instrument) *Player

func (*Player) Action

func (p *Player) Action() string

func (*Player) Name

func (p *Player) Name() string

func (*Player) PlayedAudio

func (p *Player) PlayedAudio() (string, error)

func (*Player) SetAction

func (p *Player) SetAction(action string)

type Room

type Room struct {

	// New action added.
	AddAction chan *ConnectedPlayer

	// Register requests from the connections.
	Join chan *ConnectedPlayer

	// Unregister requests from connections.
	Leave chan *ConnectedPlayer
	// contains filtered or unexported fields
}

func NewRoom

func NewRoom(name string) *Room

func (*Room) GetFreeInstruments

func (r *Room) GetFreeInstruments() map[InstrumentType]string

func (*Room) Name

func (r *Room) Name() string

func (*Room) OnActionAdded

func (r *Room) OnActionAdded(p *ConnectedPlayer)

func (*Room) OnPlayerJoined

func (r *Room) OnPlayerJoined(newPlayer *ConnectedPlayer)

func (*Room) OnPlayerLeave

func (r *Room) OnPlayerLeave(newPlayer *ConnectedPlayer)

type Ukulele

type Ukulele struct {
}

func (*Ukulele) Name

func (u *Ukulele) Name() string

func (*Ukulele) Play

func (u *Ukulele) Play(command string) (string, error)

func (*Ukulele) Type

func (u *Ukulele) Type() InstrumentType

Jump to

Keyboard shortcuts

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