poker

package module
v0.0.0-...-7bd352f Latest Latest
Warning

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

Go to latest
Published: May 26, 2021 License: GPL-3.0 Imports: 13 Imported by: 0

Documentation

Index

Constants

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

Variables

This section is empty.

Functions

func AssertContentType

func AssertContentType(t testing.TB, response *httptest.ResponseRecorder, want string)

func AssertLeague

func AssertLeague(t testing.TB, got, want []Player)

func AssertPlayerWin

func AssertPlayerWin(t testing.TB, store *StubPlayerStore, winner string)

func AssertResponseBody

func AssertResponseBody(t testing.TB, got, want string)

func AssertStatus

func AssertStatus(t testing.TB, got, want int)

func NewGetScoreRequest

func NewGetScoreRequest(name string) *http.Request

func NewLeagueRequest

func NewLeagueRequest() *http.Request

func NewPostWinRequest

func NewPostWinRequest(name string) *http.Request

func StdOutAlerter

func StdOutAlerter(duration time.Duration, amount int)

Types

type BlindAlerter

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

type BlindAlerterFunc

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

func (BlindAlerterFunc) ScheduleAlertAt

func (a BlindAlerterFunc) ScheduleAlertAt(duration time.Duration, amount 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 FileSystemPlayerStore

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

func FileSystemPlayerStoreFromFile

func FileSystemPlayerStoreFromFile(path string) (*FileSystemPlayerStore, func(), error)

func NewFileSystemPlayerStore

func NewFileSystemPlayerStore(file *os.File) (*FileSystemPlayerStore, error)

func (*FileSystemPlayerStore) GetLeague

func (f *FileSystemPlayerStore) GetLeague() League

func (*FileSystemPlayerStore) GetPlayerScore

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

func (*FileSystemPlayerStore) RecordWin

func (f *FileSystemPlayerStore) RecordWin(name string)

type Game

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

func NewGame

func NewGame(alerter BlindAlerter, store PlayerStore) *Game

func (*Game) Finish

func (p *Game) Finish(winner string)

func (*Game) Start

func (p *Game) Start(numberOfPlayers int)

type League

type League []Player

func NewLeague

func NewLeague(rdr io.Reader) (League, error)

func (League) Find

func (l League) Find(name string) *Player

type Player

type Player struct {
	Name string
	Win  int
}

func GetLeagueFromResponse

func GetLeagueFromResponse(t testing.TB, body io.Reader) (got []Player)

type PlayerServer

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

func NewPlayerServer

func NewPlayerServer(store PlayerStore) *PlayerServer

type PlayerStore

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

type StubPlayerStore

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

func (*StubPlayerStore) GetLeague

func (s *StubPlayerStore) GetLeague() League

func (*StubPlayerStore) GetPlayerScore

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

func (*StubPlayerStore) RecordWin

func (s *StubPlayerStore) RecordWin(name string)

Directories

Path Synopsis
cmd
cli

Jump to

Keyboard shortcuts

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