You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
21 lines
362 B
21 lines
362 B
package cribbage |
|
|
|
import "code.rocketnine.space/tslocum/joker" |
|
|
|
// Value returns the cribbage value of a card. |
|
func Value(c joker.Card) int { |
|
v := int(c.Face) |
|
if v > 10 { |
|
v = 10 |
|
} |
|
return v |
|
} |
|
|
|
// Sum returns the total cribbage value of the supplied cards. |
|
func Sum(c joker.Cards) int { |
|
var v int |
|
for _, card := range c { |
|
v += Value(card) |
|
} |
|
return v |
|
}
|
|
|