added more tests, cleaned up example app
This commit is contained in:
@@ -2,6 +2,7 @@ package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
"git.eeqj.de/sneak/pokercore"
|
||||
@@ -12,10 +13,9 @@ var delayTime = 2 * time.Second
|
||||
var playerCount = 8
|
||||
|
||||
type Player struct {
|
||||
Hand pokercore.Cards
|
||||
ScoredHand *pokercore.PokerHand
|
||||
Position int
|
||||
CommunityCardsAvailable pokercore.Cards
|
||||
Hand pokercore.Cards
|
||||
ScoredHand *pokercore.PokerHand
|
||||
Position int
|
||||
}
|
||||
|
||||
type Game struct {
|
||||
@@ -25,15 +25,38 @@ type Game struct {
|
||||
Street int
|
||||
}
|
||||
|
||||
func NewGame(seed int) *Game {
|
||||
func suspense() {
|
||||
fmt.Printf("########################################\n")
|
||||
if os.Getenv("NO_LAG") == "" {
|
||||
time.Sleep(delayTime)
|
||||
}
|
||||
}
|
||||
|
||||
func NewGame() *Game {
|
||||
|
||||
// this "randomly chosen" seed somehow deals pocket queens, pocket kings, and pocket aces to three players.
|
||||
// what are the odds? lol
|
||||
//g := NewGame(1337))
|
||||
|
||||
// nothing up my sleeve:
|
||||
seed := 3141592653
|
||||
|
||||
g := &Game{}
|
||||
g.Street = 0
|
||||
|
||||
g.Deck = pokercore.NewDeck()
|
||||
g.SpreadCards()
|
||||
|
||||
fmt.Printf("Shuffle up and deal!\n")
|
||||
time.Sleep(delayTime)
|
||||
suspense()
|
||||
fmt.Printf("Shuffling...\n")
|
||||
g.Deck.ShuffleDeterministically(3141592653)
|
||||
|
||||
if os.Getenv("RANDOM_SHUFFLE") != "" {
|
||||
g.Deck.ShuffleRandomly()
|
||||
} else {
|
||||
fmt.Printf("Using deterministic shuffle seed: %d\n", seed)
|
||||
g.Deck.ShuffleDeterministically(int64(seed))
|
||||
}
|
||||
return g
|
||||
}
|
||||
|
||||
@@ -121,32 +144,25 @@ func (g *Game) ShowWinner() {
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
// this "randomly chosen" seed somehow deals pocket queens, pocket kings, and pocket aces to three players.
|
||||
// what are the odds? lol
|
||||
//g := NewGame(1337))
|
||||
|
||||
// nothing up my sleeve:
|
||||
g := NewGame(3141592653)
|
||||
g := NewGame()
|
||||
|
||||
g.ShowGameStatus()
|
||||
|
||||
g.DealPlayersIn()
|
||||
suspense()
|
||||
|
||||
g.ShowGameStatus()
|
||||
|
||||
g.DealFlop()
|
||||
suspense()
|
||||
|
||||
g.ShowGameStatus()
|
||||
|
||||
g.DealTurn()
|
||||
suspense()
|
||||
|
||||
g.ShowGameStatus()
|
||||
|
||||
g.DealRiver()
|
||||
suspense()
|
||||
|
||||
g.ShowGameStatus()
|
||||
|
||||
g.ShowWinner()
|
||||
|
||||
fmt.Printf("What a strange game. The only winning move is to bet really big.\n")
|
||||
|
||||
Reference in New Issue
Block a user