Documentation ¶
Index ¶
- Constants
- func AssertPlayerWin(t testing.TB, store *StubPlayerStore, winner string)
- func StdOutAlerter(duration time.Duration, amount int)
- type BlindAlerter
- type BlindAlerterFunc
- type CLI
- type FileSystemPlayerStore
- type Game
- type League
- type Player
- type PlayerServer
- type PlayerStore
- type ScheduledAlert
- type SpyBlindAlerter
- type StubPlayerStore
- type TexasHoldem
Constants ¶
const BadPlayerInputErrMsg = "Bad value received for number of players, please try again with a number"
BadPlayerInputErrMsg is the text telling the user they did bad things.
const BadWinnerInputMsg = "invalid winner input, expect format of 'PlayerName wins'"
BadWinnerInputMsg is the text telling the user they declared the winner wrong.
const PlayerPrompt = "Please enter the number of players: "
PlayerPrompt is the text asking the user for the number of players.
Variables ¶
This section is empty.
Functions ¶
func AssertPlayerWin ¶
func AssertPlayerWin(t testing.TB, store *StubPlayerStore, winner string)
AssertPlayerWin allows you to spy on the store's calls to RecordWin.
func StdOutAlerter ¶
StdOutAlerter will schedule alerts and print them to os.Stdout.
Types ¶
type BlindAlerter ¶
BlindAlerter schedules alerts for blind amounts.
type BlindAlerterFunc ¶
BlindAlerterFunc allows you to implement BlindAlerter with a function.
func (BlindAlerterFunc) ScheduleAlertAt ¶
func (a BlindAlerterFunc) ScheduleAlertAt(duration time.Duration, amount int)
ScheduleAlertAt is BlindAlerterFunc implementation of BlindAlerter.
type CLI ¶
type CLI struct {
// contains filtered or unexported fields
}
CLI helps players through a game of poker.
type FileSystemPlayerStore ¶
type FileSystemPlayerStore struct {
// contains filtered or unexported fields
}
FileSystemPlayerStore stores players in the filesystem.
func FileSystemPlayerStoreFromFile ¶
func FileSystemPlayerStoreFromFile(path string) (*FileSystemPlayerStore, func(), error)
FileSystemPlayerStoreFromFile creates a PlayerStore from the contents of a JSON file found at path.
func NewFileSystemPlayerStore ¶
func NewFileSystemPlayerStore(file *os.File) (*FileSystemPlayerStore, error)
NewFileSystemPlayerStore creates a FileSystemPlayerStore initialising the store if needed.
func (*FileSystemPlayerStore) GetLeague ¶
func (f *FileSystemPlayerStore) GetLeague() League
GetLeague returns the Scores of all the players.
func (*FileSystemPlayerStore) GetPlayerScore ¶
func (f *FileSystemPlayerStore) GetPlayerScore(name string) int
GetPlayerScore retrieves a player's score.
func (*FileSystemPlayerStore) RecordWin ¶
func (f *FileSystemPlayerStore) RecordWin(name string)
RecordWin will store a win for a player, incrementing wins if already known.
type League ¶
type League []Player
League stores a collection of players.
type PlayerServer ¶
PlayerServer is a HTTP interface for player information.
func NewPlayerServer ¶
func NewPlayerServer(store PlayerStore) (*PlayerServer, error)
NewPlayerServer creates a PlayerServer with routing configured.
type PlayerStore ¶
type PlayerStore interface { GetPlayerScore(name string) int RecordWin(name string) GetLeague() League }
PlayerStore stores score information about players.
type ScheduledAlert ¶
ScheduledAlert holds information about when an alert is scheduled.
func (ScheduledAlert) String ¶
func (s ScheduledAlert) String() string
type SpyBlindAlerter ¶
type SpyBlindAlerter struct {
Alerts []ScheduledAlert
}
SpyBlindAlerter allows you to spy on ScheduleAlertAt calls.
func (*SpyBlindAlerter) ScheduleAlertAt ¶
func (s *SpyBlindAlerter) ScheduleAlertAt(at time.Duration, amount int)
ScheduleAlertAt records alerts that have been scheduled.
type StubPlayerStore ¶
StubPlayerStore implements PlayerStore for testing purposes.
func (*StubPlayerStore) GetLeague ¶
func (s *StubPlayerStore) GetLeague() League
GetLeague returns League.
func (*StubPlayerStore) GetPlayerScore ¶
func (s *StubPlayerStore) GetPlayerScore(name string) int
GetPlayerScore returns a score from Scores.
func (*StubPlayerStore) RecordWin ¶
func (s *StubPlayerStore) RecordWin(name string)
RecordWin will record a win to WinCalls.
type TexasHoldem ¶
type TexasHoldem struct {
// contains filtered or unexported fields
}
TexasHoldem manages a game of poker.
func NewTexasHoldem ¶
func NewTexasHoldem(alerter BlindAlerter, store PlayerStore) *TexasHoldem
NewTexasHoldem returns a new game.
func (*TexasHoldem) Finish ¶
func (p *TexasHoldem) Finish(winner string)
Finish ends the game, recording the winner.
func (*TexasHoldem) Start ¶
func (p *TexasHoldem) Start(numberOfPlayers int)
Start will schedule blind alerts dependant on the number of players.