poker

package
v0.0.0-...-2dce592 Latest Latest
Warning

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

Go to latest
Published: Sep 6, 2019 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

View Source
const PlayerPrompt = "Please enter number of players: "

Variables

This section is empty.

Functions

func Alerter

func Alerter(duration time.Duration, amount int, to io.Writer)

func AssertLeague

func AssertLeague(t *testing.T, server *PlayerServer, want Players)

func AssertResponseBody

func AssertResponseBody(t *testing.T, response *httptest.ResponseRecorder, want string)

func AssertStatus

func AssertStatus(t *testing.T, response *httptest.ResponseRecorder, want int)

func CreateTempFile

func CreateTempFile(t *testing.T, initialData string) (*os.File, func())

func FetchGameRequest

func FetchGameRequest() *http.Request

func FetchIndexScoreRequest

func FetchIndexScoreRequest() *http.Request

func FetchShowScoreRequest

func FetchShowScoreRequest(name string) *http.Request

func FetchUpdateScoreRequest

func FetchUpdateScoreRequest(name string) *http.Request

func NewTape

func NewTape(file *os.File) *tape

func RelativePath

func RelativePath(elem ...string) string

Types

type BlindAlerter

type BlindAlerter interface {
	ScheduleAlertAt(duration time.Duration, amount int, to io.Writer)
}

type BlindAlerterFunc

type BlindAlerterFunc func(duration time.Duration, amount int, to io.Writer)

func (BlindAlerterFunc) ScheduleAlertAt

func (a BlindAlerterFunc) ScheduleAlertAt(duration time.Duration, amount int, to io.Writer)

type ByWins

type ByWins Players

func (ByWins) Len

func (a ByWins) Len() int

func (ByWins) Less

func (a ByWins) Less(i, j int) bool

func (ByWins) Swap

func (a ByWins) Swap(i, j int)

type CLI

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

func NewCLI

func NewCLI(in io.Reader, out io.Writer, game Game) *CLI

func (*CLI) PlayPoker

func (cli *CLI) PlayPoker()

type DatabasePlayerStore

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

func NewDatabasePlayerStore

func NewDatabasePlayerStore(debugSync, debug bool) *DatabasePlayerStore

func (*DatabasePlayerStore) GetLeague

func (store *DatabasePlayerStore) GetLeague() (players Players)

func (*DatabasePlayerStore) GetPlayerScore

func (store *DatabasePlayerStore) GetPlayerScore(name string) int

func (*DatabasePlayerStore) RecordWin

func (store *DatabasePlayerStore) RecordWin(name string)

type FileSystemPlayerStore

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

func NewFileSystemPlayerStore

func NewFileSystemPlayerStore(file *os.File) *FileSystemPlayerStore

func NewFileSystemPlayerStoreFromFileName

func NewFileSystemPlayerStoreFromFileName(fileName string) (*FileSystemPlayerStore, func(), error)

func (*FileSystemPlayerStore) GetLeague

func (store *FileSystemPlayerStore) GetLeague() Players

func (*FileSystemPlayerStore) GetPlayerScore

func (store *FileSystemPlayerStore) GetPlayerScore(name string) int

func (*FileSystemPlayerStore) RecordWin

func (store *FileSystemPlayerStore) RecordWin(name string)

type Game

type Game interface {
	Start(numberOfPlayers int, alertsDestination io.Writer)
	Finish(winner string)
}

type InMemoryPlayerStore

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

func NewInMemoryPlayerStore

func NewInMemoryPlayerStore() *InMemoryPlayerStore

func (*InMemoryPlayerStore) GetLeague

func (store *InMemoryPlayerStore) GetLeague() (players Players)

func (*InMemoryPlayerStore) GetPlayerScore

func (store *InMemoryPlayerStore) GetPlayerScore(name string) int

func (*InMemoryPlayerStore) RecordWin

func (store *InMemoryPlayerStore) RecordWin(name string)

type Player

type Player struct {
	Id   int    `orm:"auto"`
	Name string `orm:"unique"`
	Wins int    `orm:"default(0)"`
}

func (*Player) TableIndex

func (player *Player) TableIndex() [][]string

type PlayerServer

type PlayerServer struct {
	http.Handler
	// contains filtered or unexported fields
}

func EnsurePlayerServer

func EnsurePlayerServer(t *testing.T, store PlayerStore, game Game) *PlayerServer

func NewPlayerServer

func NewPlayerServer(store PlayerStore, game Game) (*PlayerServer, error)

type PlayerStore

type PlayerStore interface {
	GetPlayerScore(name string) int
	RecordWin(name string)
	GetLeague() Players
}

type Players

type Players []Player

func (Players) Find

func (players Players) Find(name string) *Player

type SpyGame

type SpyGame struct {
	StartCalled    bool
	StartedWith    int
	FinishedCalled bool
	FinishedWith   string

	BlindAlert []byte
}

func (*SpyGame) Finish

func (game *SpyGame) Finish(finishedWith string)

func (*SpyGame) Start

func (game *SpyGame) Start(startedWith int, out io.Writer)

type StubPlayerStore

type StubPlayerStore struct {
	Players    Players
	CalledWith []string
}

func (*StubPlayerStore) GetLeague

func (store *StubPlayerStore) GetLeague() Players

func (*StubPlayerStore) GetPlayerScore

func (store *StubPlayerStore) GetPlayerScore(name string) int

func (*StubPlayerStore) RecordWin

func (store *StubPlayerStore) RecordWin(name string)

type TexasHoldemGame

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

func NewTexasHoldem

func NewTexasHoldem(alerter BlindAlerter, store PlayerStore) *TexasHoldemGame

func (TexasHoldemGame) Finish

func (game TexasHoldemGame) Finish(winner string)

func (*TexasHoldemGame) Start

func (game *TexasHoldemGame) Start(numberOfPlayers int, w io.Writer)

Directories

Path Synopsis
cmd
cli

Jump to

Keyboard shortcuts

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