Example #1
0
File: game.go Project: notnil/joker
func (g *studGame) FormHighHand(holeCards []*hand.Card, board []*hand.Card) *hand.Hand {
	cards := append(board, holeCards...)
	if g.IsRazz {
		return hand.New(cards, hand.AceToFiveLow)
	}
	return hand.New(cards)
}
Example #2
0
File: game.go Project: notnil/joker
func (g *studGame) FormLowHand(holeCards []*hand.Card, board []*hand.Card) *hand.Hand {
	cards := append(board, holeCards...)
	hand := hand.New(cards, hand.AceToFiveLow)
	if hand.CompareTo(eightOrBetter) <= 0 {
		return hand
	}
	return nil
}
Example #3
0
File: game.go Project: notnil/joker
func (g *holdemGame) FormHighHand(holeCards []*hand.Card, board []*hand.Card) *hand.Hand {
	if !g.IsOmaha {
		cards := append(board, holeCards...)
		return hand.New(cards)
	}

	opts := func(c *hand.Config) {}
	hands := omahaHands(holeCards, board, opts)
	hands = hand.Sort(hand.SortingHigh, hand.DESC, hands...)
	return hands[0]
}
Example #4
0
File: game.go Project: notnil/joker
func omahaHands(holeCards []*hand.Card, board []*hand.Card, opts func(*hand.Config)) []*hand.Hand {
	hands := []*hand.Hand{}
	selected := make([]*hand.Card, 2)
	for _, indexes := range util.Combinations(4, 2) {
		for j, i := range indexes {
			selected[j] = holeCards[i]
		}
		cards := append(board, selected...)
		hands = append(hands, hand.New(cards, opts))
	}
	return hands
}
Example #5
0
File: game.go Project: notnil/joker
func (g *studGame) RoundStartSeat(holeCards holeCards, r round) int {
	exposed := exposedCards(holeCards)
	f := func(holeCards []*hand.Card, board []*hand.Card) *hand.Hand {
		return hand.New(holeCards)
	}

	sorting := hand.SortingLow
	if (r != thirdSt && !g.IsRazz) || (r == thirdSt && g.IsRazz) {
		sorting = hand.SortingHigh
	}
	hands := newHands(exposed, []*hand.Card{}, f)
	hands = hands.winningHands(sorting)

	for seat := range hands {
		return seat
	}
	panic("unreachable")
}
Example #6
0
package table

import (
	"encoding/json"
	"testing"

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

var (
	holdemFunc = func(holeCards []*hand.Card, board []*hand.Card) *hand.Hand {
		cards := append(board, holeCards...)
		return hand.New(cards)
	}

	omahaHiFunc = func(holeCards []*hand.Card, board []*hand.Card) *hand.Hand {
		opts := func(c *hand.Config) {}
		hands := omahaHands(holeCards, board, opts)
		hands = hand.Sort(hand.SortingHigh, hand.DESC, hands...)
		return hands[0]
	}

	omahaLoFunc = func(holeCards []*hand.Card, board []*hand.Card) *hand.Hand {
		hands := omahaHands(holeCards, board, hand.AceToFiveLow)
		hands = hand.Sort(hand.SortingLow, hand.DESC, hands...)
		if hands[0].CompareTo(eightOrBetter) <= 0 {
			return hands[0]
		}
		return nil
	}
Example #7
0
File: game.go Project: notnil/joker
		}
		exposed[seat] = eCards
	}
	return exposed
}

type round int

const (
	preflop round = 0
	flop    round = 1
	turn    round = 2
	river   round = 3

	thirdSt   round = 0
	fourthSt  round = 1
	fifthSt   round = 2
	sixthSt   round = 3
	seventhSt round = 4
)

var (
	eightOrBetter = hand.New([]*hand.Card{
		hand.EightSpades,
		hand.SevenSpades,
		hand.SixSpades,
		hand.FiveSpades,
		hand.FourSpades,
	}, hand.AceToFiveLow)
)