...

Source file src/gitlab.com/tslocum/joker/card_face.go

Documentation: gitlab.com/tslocum/joker

     1  package joker
     2  
     3  // CardFace defines a card face.
     4  type CardFace int
     5  
     6  // Card faces
     7  const (
     8  	FaceAce   CardFace = 1
     9  	Face2     CardFace = 2
    10  	Face3     CardFace = 3
    11  	Face4     CardFace = 4
    12  	Face5     CardFace = 5
    13  	Face6     CardFace = 6
    14  	Face7     CardFace = 7
    15  	Face8     CardFace = 8
    16  	Face9     CardFace = 9
    17  	Face10    CardFace = 10
    18  	FaceJack  CardFace = 11
    19  	FaceQueen CardFace = 12
    20  	FaceKing  CardFace = 13
    21  	FaceJoker CardFace = 14
    22  )
    23  
    24  // StandardFaces is a slice of all faces except Jokers.
    25  var StandardFaces = []CardFace{
    26  	FaceAce,
    27  	Face2,
    28  	Face3,
    29  	Face4,
    30  	Face5,
    31  	Face6,
    32  	Face7,
    33  	Face8,
    34  	Face9,
    35  	Face10,
    36  	FaceJack,
    37  	FaceQueen,
    38  	FaceKing,
    39  }
    40  
    41  // AllFaces is a slice of all faces.
    42  var AllFaces = []CardFace{
    43  	FaceAce,
    44  	Face2,
    45  	Face3,
    46  	Face4,
    47  	Face5,
    48  	Face6,
    49  	Face7,
    50  	Face8,
    51  	Face9,
    52  	Face10,
    53  	FaceJack,
    54  	FaceQueen,
    55  	FaceKing,
    56  	FaceJoker,
    57  }
    58  
    59  // Name returns the card face name.
    60  func (f CardFace) Name() string {
    61  	switch f {
    62  	case FaceAce:
    63  		return "Ace"
    64  	case Face2:
    65  		return "2"
    66  	case Face3:
    67  		return "3"
    68  	case Face4:
    69  		return "4"
    70  	case Face5:
    71  		return "5"
    72  	case Face6:
    73  		return "6"
    74  	case Face7:
    75  		return "7"
    76  	case Face8:
    77  		return "8"
    78  	case Face9:
    79  		return "9"
    80  	case Face10:
    81  		return "10"
    82  	case FaceJack:
    83  		return "Jack"
    84  	case FaceQueen:
    85  		return "Queen"
    86  	case FaceKing:
    87  		return "King"
    88  	case FaceJoker:
    89  		return "Joker"
    90  	default:
    91  		return Invalid
    92  	}
    93  }
    94  
    95  // String returns the card face name.
    96  func (f CardFace) String() string {
    97  	return f.Name()
    98  }
    99  

View as plain text