Beispiel #1
0
func TestHighLowPot(t *testing.T) {
	t.Parallel()

	p := newPot(3)
	p.contribute(0, 5)
	p.contribute(1, 5)
	p.contribute(2, 5)

	seatToHoleCards := map[int][]*hand.Card{
		0: []*hand.Card{
			hand.AceHearts,
			hand.TwoClubs,
			hand.SevenDiamonds,
			hand.KingHearts,
		},
		1: []*hand.Card{
			hand.AceDiamonds,
			hand.FourClubs,
			hand.ThreeDiamonds,
			hand.SixSpades,
		},
		2: []*hand.Card{
			hand.AceSpades,
			hand.TwoHearts,
			hand.JackDiamonds,
			hand.JackClubs,
		},
	}

	board := jokertest.Cards("7s", "Kd", "8h", "Jh", "5c")
	highHands := newHands(seatToHoleCards, board, omahaHiFunc)
	lowHands := newHands(seatToHoleCards, board, omahaLoFunc)
	payout := p.payout(highHands, lowHands, hand.SortingHigh, 0)

	if len(payout) < 3 {
		t.Errorf("pot.Payout() should have 3 results")
	}

	for seat, results := range payout {
		switch seat {
		case 0:
			if len(results) != 1 && total(results) != 4 {
				t.Errorf("seat 0 should win 4 chips")
			}
		case 1:
			if len(results) != 1 && total(results) != 8 {
				t.Errorf("seat 1 should win 8 chips")
			}
		case 2:
			if len(results) != 1 && total(results) != 3 {
				t.Errorf("seat 2 should 3 chips")
			}
		}
	}
}
Beispiel #2
0
func TestDeck(t *testing.T) {
	cards := jokertest.Cards("Qh", "Ks", "4s")
	actual := []*hand.Card{hand.QueenHearts, hand.KingSpades, hand.FourSpades}
	deck := jokertest.Dealer(cards).Deck()

	for i := 0; i < len(actual); i++ {
		card := deck.Pop()
		if actual[i] != card {
			t.Fatalf("Pop() = %s; want %s; i = %d", card, actual[i], i)
		}
	}
}
Beispiel #3
0
func TestHighPot(t *testing.T) {
	t.Parallel()

	p := newPot(3)
	p.contribute(0, 5)
	p.contribute(1, 10)
	p.contribute(2, 15)

	seatToHoleCards := map[int][]*hand.Card{
		0: []*hand.Card{
			hand.AceSpades,
			hand.AceHearts,
		},
		1: []*hand.Card{
			hand.QueenSpades,
			hand.QueenHearts,
		},
		2: []*hand.Card{
			hand.KingSpades,
			hand.KingHearts,
		},
	}

	board := jokertest.Cards("Ad", "Kd", "Qd", "2d", "2h")
	hands := newHands(seatToHoleCards, board, holdemFunc)
	payout := p.payout(hands, nil, hand.SortingHigh, 0)

	for seat, results := range payout {
		switch seat {
		case 0:
			if len(results) != 1 {
				t.Fatal("seat 0 should win one pot")
			}
		case 1:
			if len(results) != 0 {
				t.Fatal("seat 1 should win no pots")
			}
		case 2:
			if len(results) != 2 {
				t.Fatal("seat 2 should win two pots")
			}
		}
	}
}
Beispiel #4
0
	"testing"

	. "github.com/loganjspears/joker/hand"
	"github.com/loganjspears/joker/jokertest"
)

type testPair struct {
	cards       []*Card
	arrangement []*Card
	ranking     Ranking
	description string
}

var tests = []testPair{
	{
		jokertest.Cards("Ks", "Qs", "Js", "As", "9d"),
		jokertest.Cards("As", "Ks", "Qs", "Js", "9d"),
		HighCard,
		"high card ace high",
	},
	{
		jokertest.Cards("Ks", "Qh", "Qs", "Js", "9d"),
		jokertest.Cards("Qh", "Qs", "Ks", "Js", "9d"),
		Pair,
		"pair of queens",
	},
	{
		jokertest.Cards("2s", "Qh", "Qs", "Js", "2d"),
		jokertest.Cards("Qh", "Qs", "2s", "2d", "Js"),
		TwoPair,
		"two pair queens and twos",
Beispiel #5
0
	"github.com/loganjspears/joker/hand"
	"github.com/loganjspears/joker/jokertest"
)

var tests = []struct {
	G              Game
	Cards          []*hand.Card
	NumOfHoleCards int
	NumOfBoard     int
	HighRanking    hand.Ranking
	LowRanking     hand.Ranking
}{
	{
		G:              Holdem,
		Cards:          jokertest.Cards("Qh", "Ks", "4s", "3d", "4s", "8h", "2c", "Ah", "Kh"),
		NumOfHoleCards: 2,
		NumOfBoard:     5,
		HighRanking:    hand.Pair,
	},
	{
		G:              OmahaHiLo,
		Cards:          jokertest.Cards("Qh", "Ks", "4s", "3d", "4s", "8h", "2c", "Ah", "Kh"),
		NumOfHoleCards: 4,
		NumOfBoard:     5,
		HighRanking:    hand.TwoPair,
		LowRanking:     hand.HighCard,
	},
	{
		G:              StudHiLo,
		Cards:          jokertest.Cards("Ah", "Ks", "4s", "3d", "5s", "8h", "2c"),