Documentation ¶
Index ¶
- func AssertCurrents(t *testing.T, state *common.GameState, p, d int)
- func AssertEquals(t *testing.T, expected, actual interface{})
- func AssertError(t *testing.T, err error, expected string)
- func AssertGameState(t *testing.T, state *common.GameState, expected common.State)
- func AssertName(t *testing.T, ps common.PlayerState, name string)
- func AssertRank(t *testing.T, ps common.PlayerState, target int)
- func AssertScore(t *testing.T, ps common.PlayerState, target int)
- type BaseGame
- type CountUp
- type Cricket
- type Game
- type Gamex01
- type Highest
- type OptionCountUp
- type OptionCricket
- type OptionHighest
- type Optionx01
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AssertCurrents ¶
AssertCurrents assertion on currentPlayer and CurrentDart
func AssertEquals ¶
AssertEquals classical assertEquals
func AssertError ¶
AssertError assert the error content
func AssertGameState ¶
AssertGameState assert the GameState is as exepcetd
func AssertName ¶
func AssertName(t *testing.T, ps common.PlayerState, name string)
AssertName assert the name is what expected
func AssertRank ¶
func AssertRank(t *testing.T, ps common.PlayerState, target int)
AssertRank assert the ranking is what expected
func AssertScore ¶
func AssertScore(t *testing.T, ps common.PlayerState, target int)
AssertScore assert the score is what expected
Types ¶
type BaseGame ¶
type BaseGame struct { DisplayStyle string // contains filtered or unexported fields }
BaseGame common Game struct
func (*BaseGame) BoardHasLeft ¶
BoardHasLeft is call to notify the game a board has been disconnected. It returns true if the game continues despite this event.
type CountUp ¶
type CountUp struct { BaseGame // contains filtered or unexported fields }
CountUp is a highscore Game, winner is the first to obtain a given score or more
func NewGameCountUp ¶
func NewGameCountUp(opt OptionCountUp) *CountUp
NewGameCountUp : GameCountUp constructor using a OptionCountUp
func (*CountUp) HandleDart ¶
HandleDart the implementation has to handle the Dart regarding the current player, the rules, and the context. Return a GameState
func (*CountUp) HoldOrNextPlayer ¶
func (game *CountUp) HoldOrNextPlayer()
HoldOrNextPlayer switch game state between ONHOLD and PLAYING
type Cricket ¶
type Cricket struct { BaseGame // contains filtered or unexported fields }
Cricket is a cricket series Game (Cricket, Cut-throat)
func NewGameCricket ¶
func NewGameCricket(opt OptionCricket) *Cricket
NewGameCricket : GameCricket constructor using a OptionCricket
func (*Cricket) HandleDart ¶
HandleDart the implementation has to handle the Dart regarding the current player, the cricket rules, and the context. Return a GameState
func (*Cricket) HoldOrNextPlayer ¶
func (game *Cricket) HoldOrNextPlayer()
HoldOrNextPlayer switch game state between ONHOLD and PLAYING
type Game ¶
type Game interface { // Start start the game, Darts will be handled Start() error // AddPlayer add a new player to the game AddPlayer(board string, name string) error // HandleDart the implementation has to handle the Dart regarding the current player, the rules, and the context. Return a GameState HandleDart(sector common.Sector) (*common.GameState, error) // GetState, get the current GameState State() *common.GameState // BoardHasLeft is call to notify the game a board has been disconnected. Returns true if the game continues despite this event BoardHasLeft(board string) bool // HoldOrNextPlayer switch game state between ONHOLD and PLAYING with side effects according to game implementation HoldOrNextPlayer() // contains filtered or unexported methods }
Game interface, should be implemented by all game (rules) implems
type Gamex01 ¶
type Gamex01 struct { BaseGame // contains filtered or unexported fields }
Gamex01 is a x01 series Game (301, 501-Double-Out, ...)
func (*Gamex01) HandleDart ¶
HandleDart the implementation has to handle the Dart regarding the current player, the rules of x01, and the context. Return a GameState
func (*Gamex01) HoldOrNextPlayer ¶
func (game *Gamex01) HoldOrNextPlayer()
HoldOrNextPlayer switch game state between ONHOLD and PLAYING
type Highest ¶
type Highest struct { BaseGame // contains filtered or unexported fields }
Highest is a highscore Game, within a fixed number of visit, winner is the highest score
func NewGameHighest ¶
func NewGameHighest(opt OptionHighest) *Highest
NewGameHighest : GameHighest constructor using a OptionHighest
func (*Highest) HandleDart ¶
HandleDart the implementation has to handle the Dart regarding the current player, the rules, and the context. Return a GameState
func (*Highest) HoldOrNextPlayer ¶
func (game *Highest) HoldOrNextPlayer()
HoldOrNextPlayer switch game state between ONHOLD and PLAYING
type OptionCountUp ¶
type OptionCountUp struct {
Target int
}
OptionCountUp is the struct to handle GameCountUp parameters
type OptionCricket ¶
OptionCricket is the struct to handle GameCricket parameters
type OptionHighest ¶
type OptionHighest struct {
Rounds int
}
OptionHighest is the struct to handle GameHighest parameters