Exemplo n.º 1
0
// FollowSuit tests whether a given hand of cards *can* follow either suit on a card that has been led.
func FollowSuit(card *decktet.DecktetCard, hand ...*decktet.DecktetCard) bool {
	for _, s := range card.Suits() {
		for _, c := range hand {
			if c.HasSuit(s) {
				return true
			}
		}
	}
	return false
}
Exemplo n.º 2
0
// did the player win the hand?
func testWin(dc, pc, ace *decktet.DecktetCard) bool {
	trump := ace.Suits()[0]
	switch {
	case dc.HasSuit(trump) && !pc.HasSuit(trump):
		return false
	case pc.HasSuit(trump) && !dc.HasSuit(trump):
		return true
	default: // both have trump or neither does
		return pc.Rank() > dc.Rank()
	}
}