poker

package module
v0.0.0-...-cac5a17 Latest Latest
Warning

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

Go to latest
Published: Dec 26, 2020 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

View Source
const BadPlayerInputErrMsg = "Bad value received for number of players, please try again with a number"
View Source
const BadWinnerErrMsg = "Bad value received for winner, please enter in the specified format"
View Source
const PlayerPrompt = "Please enter the number of players: "

Variables

This section is empty.

Functions

func AssertContentType

func AssertContentType(t *testing.T, response *httptest.ResponseRecorder)

func AssertDeepEqual

func AssertDeepEqual(t *testing.T, a interface{}, b interface{})

func AssertEqual

func AssertEqual(t *testing.T, a interface{}, b interface{})

func AssertEqualIntegers

func AssertEqualIntegers(t *testing.T, a int, b int)

func AssertFileCreation

func AssertFileCreation(t *testing.T, err error)

func AssertLeague

func AssertLeague(t *testing.T, response *httptest.ResponseRecorder, wantedLeague []Player)

func AssertNoError

func AssertNoError(t *testing.T, err error)

func AssertPlayerInStore

func AssertPlayerInStore(t *testing.T, store []string, c struct {
	player string
	score  int
})

func AssertPlayerWin

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

func AssertStatus

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

func ErrorFileCreation

func ErrorFileCreation(err error) error

func ErrorFileOpening

func ErrorFileOpening(err error, fileName string) error

func ErrorListenAndServe

func ErrorListenAndServe(err error) error

func ErrorParseLeague

func ErrorParseLeague(err error) error

func StdOutAlerter

func StdOutAlerter(duration time.Duration, amount int)

Types

type Alert

type Alert struct {
	ScheduledAt time.Duration
	Amount      int
}

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 (b BlindAlerterFunc) ScheduleAlertAt(duration time.Duration, amount int)

type Cli

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

func NewCli

func NewCli(input io.Reader, output io.Writer, game Game) *Cli

func (*Cli) PlayPoker

func (c *Cli) PlayPoker()

type FileSystemPlayerStore

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

func FileSystemPlayerStoreFromFile

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

func NewFileSystemPlayerStore

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

func (*FileSystemPlayerStore) GetLeague

func (i *FileSystemPlayerStore) GetLeague() League

func (*FileSystemPlayerStore) RecordWin

func (i *FileSystemPlayerStore) RecordWin(player string)

type Game

type Game interface {
	Start(players int)
	Finish(input string)
}

type Holdem

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

func NewHoldem

func NewHoldem(store PlayerStore, alerter BlindAlerter) *Holdem

func (*Holdem) Finish

func (g *Holdem) Finish(input string)

func (*Holdem) Start

func (g *Holdem) Start(players int)

type InMemoryPlayerStore

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

func NewInMemoryPlayerStore

func NewInMemoryPlayerStore() *InMemoryPlayerStore

func (*InMemoryPlayerStore) GetLeague

func (i *InMemoryPlayerStore) GetLeague() League

func (*InMemoryPlayerStore) RecordWin

func (i *InMemoryPlayerStore) RecordWin(player string)

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
	Wins int
}

type PlayerServer

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

func NewPlayerServer

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

type PlayerStore

type PlayerStore interface {
	RecordWin(player string)
	GetLeague() League
	// contains filtered or unexported methods
}

type SpyBlindAlerter

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

func (*SpyBlindAlerter) Alerts

func (s *SpyBlindAlerter) Alerts() []Alert

func (*SpyBlindAlerter) ScheduleAlertAt

func (s *SpyBlindAlerter) ScheduleAlertAt(duration time.Duration, amount int)

type SpyGame

type SpyGame struct {
	StartCalled bool
	StartedWith int

	FinishedCalled bool
	FinishedWith   string
}

func (*SpyGame) Finish

func (s *SpyGame) Finish(input string)

func (*SpyGame) Start

func (s *SpyGame) Start(players int)

type StubPlayerStore

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

func (*StubPlayerStore) GetLeague

func (s *StubPlayerStore) GetLeague() League

func (*StubPlayerStore) RecordWin

func (s *StubPlayerStore) RecordWin(player string)

type Tape

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

func (*Tape) Write

func (t *Tape) Write(p []byte) (n int, err error)

Directories

Path Synopsis
cmd
cli

Jump to

Keyboard shortcuts

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