...

Source file src/gitlab.com/tslocum/joker-cribbage/card.go

Documentation: gitlab.com/tslocum/joker-cribbage

     1  package cribbage
     2  
     3  import "gitlab.com/tslocum/joker"
     4  
     5  // Value returns the cribbage value of a card.
     6  func Value(c joker.Card) int {
     7  	v := int(c.Face)
     8  	if v > 10 {
     9  		v = 10
    10  	}
    11  	return v
    12  }
    13  
    14  // Sum returns the total cribbage value of the supplied cards.
    15  func Sum(c joker.Cards) int {
    16  	var v int
    17  	for _, card := range c {
    18  		v += Value(card)
    19  	}
    20  	return v
    21  }
    22  

View as plain text