snengame/card.go

32 lines
372 B
Go

package main
type Card int
const (
Valk Card = iota
Ace
Two
Three
Four
Five
Six
Seven
Eight
Nine
Ten
Jack
Queen
King
)
func (c Card) String() string {
return []string{"V", "A", "2", "3", "4", "5", "6", "7", "8", "9", "T", "J", "Q", "K"}[c]
}
func (c Card) CanAttack(src, dest int) bool {
if c == Eight || src != dest {
return false
}
return true
}