Documentation
¶
Index ¶
- Variables
- type Answer
- type Bet
- type BettingRound
- type BettingStates
- type Game
- func (g *Game) ActionablePlayers() []*Player
- func (g *Game) ActivePlayers() []*Player
- func (g *Game) AddNewPlayer(name string) *Player
- func (g *Game) AddNewQuestionRound()
- func (g *Game) BigBlind() int
- func (g *Game) BigBlindPlayer() *Player
- func (g *Game) CurrentQuestionRound() *QuestionRound
- func (g *Game) Dealer() *Player
- func (g *Game) FindPlayer(id string) *Player
- func (g *Game) HasStarted() bool
- func (g *Game) InPlayers() []*Player
- func (g *Game) IsFinished() bool
- func (g *Game) OutPlayers() ([]*Player, []string)
- func (g *Game) Participants() []string
- func (g *Game) PlayerIds() []string
- func (g *Game) RecentQuestionRound() *QuestionRound
- func (g *Game) RemovePlayer(playerID string)
- func (g *Game) Save(ctx context.Context, client *firestore.Client) error
- func (g *Game) SmallBlind() int
- func (g *Game) SmallBlindPlayer() *Player
- type GeoCoordinate
- type Guess
- type Player
- func (p *Player) FindNextActionablePlayer() *Player
- func (p *Player) FindNextInPlayer() *Player
- func (p *Player) HasFolded() bool
- func (p *Player) IsActionable() bool
- func (p *Player) IsActive() bool
- func (p *Player) IsAllIn() bool
- func (p *Player) IsOutGame() bool
- func (p *Player) MoneyInBettingRound() int
- func (p *Player) MoneyInQuestionRound() int
- type Question
- type QuestionRound
- func (q *QuestionRound) AddNewBettingRound()
- func (q *QuestionRound) CurrentBettingRound() *BettingRound
- func (q *QuestionRound) DistributePot()
- func (q *QuestionRound) Fold(playerID string)
- func (q *QuestionRound) IsFinished() bool
- func (q *QuestionRound) PlaceBlinds()
- func (q *QuestionRound) Rank() [][]string
- type QuestionRoundResult
- type QuestionTypes
Constants ¶
This section is empty.
Variables ¶
var AllBettingStates = []BettingStates{ BettingStatesChecked, BettingStatesCalled, BettingStatesRaised, }
Functions ¶
This section is empty.
Types ¶
type Answer ¶
type Answer struct { Numerical *float64 `firestore:"numerical"` Geo *GeoCoordinate `firestore:"geo"` }
type BettingRound ¶
type BettingRound struct { QuestionRound *QuestionRound `firestore:"questionRound,omitempty"` Bets []*Bet `firestore:"bets"` CurrentPlayer *Player `firestore:"currentPlayer"` }
func (*BettingRound) AddBet ¶
func (b *BettingRound) AddBet(bet *Bet, isBlind bool)
AddBet processes the bet
func (*BettingRound) AmountToCall ¶
func (b *BettingRound) AmountToCall() int
AmountToCall returns the amount to call in the current betting round
func (*BettingRound) IsFinished ¶
func (b *BettingRound) IsFinished() bool
IsFinished returns true if the betting round is over
func (*BettingRound) MoveToNextPlayer ¶
func (b *BettingRound) MoveToNextPlayer()
MoveToNextPlayer sets the current player ID. Warning: It expects the current player to still be in the game!
func (*BettingRound) Start ¶
func (b *BettingRound) Start()
Start sets current player id to next active player of dealer and resets all player states to nil
type BettingStates ¶
type BettingStates string
const ( BettingStatesChecked BettingStates = "CHECKED" BettingStatesCalled BettingStates = "CALLED" BettingStatesRaised BettingStates = "RAISED" )
type Game ¶
type Game struct { ID string `firestore:"id,omitempty"` Players []*Player `firestore:"players"` QuestionRounds []*QuestionRound `firestore:"questionRounds"` DealerID string `firestore:"dealerId"` Questions []*Question `firestore:"questions"` IsOver bool `firestore:"isOver"` SetNames []string `firestore:"setNames"` TTL time.Time `firestore:"ttl,omitempty"` }
func (*Game) ActionablePlayers ¶
ActionablePlayers returns the players that are in the game, have not folded in current QR and are not all in
func (*Game) ActivePlayers ¶
ActivePlayers returns the players that are in the game and have not folded in current QR
func (*Game) AddNewPlayer ¶
AddNewPlayer adds a new player
func (*Game) AddNewQuestionRound ¶
func (g *Game) AddNewQuestionRound()
AddNewQuestionRound adds a new question round
func (*Game) BigBlindPlayer ¶
BigBlindPlayer returns the dealer player object
func (*Game) CurrentQuestionRound ¶
func (g *Game) CurrentQuestionRound() *QuestionRound
CurrentQuestionRound returns the last element of the game's QuestionRounds slice
func (*Game) FindPlayer ¶
func (*Game) HasStarted ¶
HasStarted returns true if there are 1 or more question rounds already
func (*Game) IsFinished ¶
IsFinished returns true if there is only one player left in the game
func (*Game) OutPlayers ¶
OutPlayers returns the players that are no longer in the game
func (*Game) Participants ¶
Participants returns a slice of all player names
func (*Game) RecentQuestionRound ¶
func (g *Game) RecentQuestionRound() *QuestionRound
RecentQuestionRound returns the last played question round If the game is over then this is the same as the current question round
func (*Game) RemovePlayer ¶ added in v0.0.4
RemovePlayer adds a new player
func (*Game) SmallBlind ¶
SmallBlind returns the amout of the small blind depending on the env variable and the number of question rounds
func (*Game) SmallBlindPlayer ¶
SmallBlindPlayer returns the dealer player object
type GeoCoordinate ¶
type Guess ¶
type Guess struct { Guess *Answer `firestore:"guess"` PlayerID string `firestore:"playerId"` Difference *float64 `firestore:"difference,omitempty"` }
func (*Guess) GetGeoDistance ¶
GetGeoDistance returns the distance between the geo guess and answer in km
type Player ¶
type Player struct { ID string `firestore:"id"` Money int `firestore:"money"` Name string `firestore:"name"` Game *Game `firestore:"game,omitempty"` IsDead bool `firestore:"isDead"` BettingState *BettingStates `firestore:"bettingState,omitempty"` }
func FindPlayer ¶
FindPlayer finds player by ID in given player slice
func (*Player) FindNextActionablePlayer ¶
FindNextActionablePlayer returns the next neighbour that is actionable
func (*Player) FindNextInPlayer ¶
FindNextInPlayer returns the next neighbor that is active
func (*Player) HasFolded ¶
HasFolded returns true if the player in included in the FoldedPlayerId list of the current QR
func (*Player) IsActionable ¶
IsActionable returns true if the player can still place bets in current QR
func (*Player) IsAllIn ¶
IsAllIn returns true if the player has no money left but money in current QR and has not folded
func (*Player) IsOutGame ¶
IsOutGame returns true if the player has no more money left and has no chance of winning some in the current question round
func (*Player) MoneyInBettingRound ¶
MoneyInBettingRound returns the amount that the player has in the pot of the current betting round
func (*Player) MoneyInQuestionRound ¶
MoneyInQuestionRound returns the amount that the player has in the pot of the current question round
type Question ¶
type Question struct { ID string `firestore:"id,omitempty"` Type QuestionTypes `firestore:"type"` Question string `firestore:"question"` Answer *Answer `firestore:"answer"` Alternatives []string `firestore:"alternatives,omitempty"` HiddenAlternatives []string `firestore:"hiddenAlternatives,omitempty"` Hints []string `firestore:"hints,omitempty"` Explanation *string `firestore:"explanation,omitempty"` }
func DrawQuestion ¶
DrawQuestion draws the next Question and removes it from the slice
func (*Question) GetHiddenAlternative ¶
GetHiddenAlternative returns one of the incorrect alternatives that is not yet hidden
type QuestionRound ¶
type QuestionRound struct { Game *Game `firestore:"game,omitempty"` Question *Question `firestore:"question"` Guesses []*Guess `firestore:"guesses"` DeadPlayerGuesses []*Guess `firestore:"deadPlayerGuesses"` BettingRounds []*BettingRound `firestore:"bettingRounds"` FoldedPlayerIds []string `firestore:"foldedPlayerIds"` IsOver bool `firestore:"isOver"` IsShowdown bool `firestore:"isShowdown"` Results []*QuestionRoundResult `firestore:"results"` RevealedGuesses []string `firestore:"revealedGuesses"` }
func (*QuestionRound) AddNewBettingRound ¶
func (q *QuestionRound) AddNewBettingRound()
AddNewBettingRound adds a new betting round
func (*QuestionRound) CurrentBettingRound ¶
func (q *QuestionRound) CurrentBettingRound() *BettingRound
CurrentBettingRound returns the last element of the game's QuestionRounds slice
func (*QuestionRound) DistributePot ¶
func (q *QuestionRound) DistributePot()
DistributePot determines winner(s), allocates money accordingly
func (*QuestionRound) Fold ¶
func (q *QuestionRound) Fold(playerID string)
Fold adds a player to the FoldedPlayerId List of the question round
func (*QuestionRound) IsFinished ¶
func (q *QuestionRound) IsFinished() bool
IsFinished returns true if the current betting round is finished and all hints are already revealed or all players are all in or only one player is still active WARNING: this assumes the the current betting round is also finished
func (*QuestionRound) PlaceBlinds ¶
func (q *QuestionRound) PlaceBlinds()
PlaceBlinds places the small and big blind of the QR
func (*QuestionRound) Rank ¶
func (q *QuestionRound) Rank() [][]string
Rank determines who has won the question round
type QuestionRoundResult ¶
type QuestionTypes ¶
type QuestionTypes string
const ( QuestionTypesNumerical QuestionTypes = "NUMERICAL" QuestionTypesMultipleChoice QuestionTypes = "MULTIPLE_CHOICE" QuestionTypesDate QuestionTypes = "DATE" QuestionTypesGeo QuestionTypes = "GEO" )