-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathhand.h
More file actions
33 lines (28 loc) · 680 Bytes
/
Copy pathhand.h
File metadata and controls
33 lines (28 loc) · 680 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#ifndef _HAND_H
#define _HAND_H
#include "card.h"
#define CARD_BASE 13
#define HAND_NUM 7
#define CARD_NUM 5
typedef card_t *hand_t;
typedef enum hand_level_s {
HIGH_CARD,
ONE_PAIR,
TWO_PAIR,
THREE_OF_A_KIND,
STRAIGHT,
FLUSH,
FULL_HORSE,
FOUR_OF_A_KIND,
STRAIGHT_FLUSH,
} hand_level_t;
#define SET_RANK(score, rank) ((score) |= ((rank) << 20))
#define GET_RANK(score) ((score) >> 20)
typedef struct hand_rank_s {
unsigned int score;
unsigned int mask;
} hand_rank_t;
const char *level_to_string(hand_level_t);
hand_rank_t calc_rank(hand_t hand);
int hand_to_string(card_t *cards, hand_rank_t rank, char *buffer, int size);
#endif