示例#1
0
func promptPlayer(d deck.Deck, p *hand.Hand) bool {
	fmt.Print(promptOptions(p))

	// read from the player
	switch getUserInput() {
	case "h":
		c, _ := d.NextCard()
		p.AddCard(c)
		return false
	default: // case "s":
		return true
	}

}
示例#2
0
func dealerPlays(d deck.Deck, h *hand.Hand) {
	for !h.Busted() && h.Value() < 17 { // dealer must hit when <17
		c, _ := d.NextCard()
		h.AddCard(c)
	}
}