aboutsummaryrefslogtreecommitdiff
path: root/include/tak.h
blob: c7135abdf76569da669d1b8c2bf60d8584d7a3b8 (plain)
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
#include <stdlib.h>
#include <stdint.h>

static uint8_t board_size = 5;

typedef uint16_t colour_stack_t;
typedef uint8_t data_t;

enum COLOUR         { C_WHITE, C_BLACK };
enum STONE_VARIANT  { STONE_FLAT, STONE_STANDING, STONE_CAPSTONE };
enum MOVE_DIRECTION { M_UP, M_DOWN, M_LEFT, M_RIGHT };
enum ACTION_RESULT  { A_OK, A_ILLEGAL, A_OVERFLOW };
enum WIN_RESULT     { W_NONE, W_ROAD_WHITE, W_ROAD_BLACK, W_FLAT_WHITE, W_FLAT_BLACK };

static colour_stack_t *colours = 0;
static data_t *celldat = 0;
static uint8_t white_flats, black_flats, white_caps, black_caps, turn;

uint8_t init_game(void);
void reset_game(void);
void free_game(void);

enum ACTION_RESULT
try_place(const int8_t location, const enum COLOUR colour,
          const enum STONE_VARIANT stone);

enum ACTION_RESULT
try_move(const int8_t location, const enum MOVE_DIRECTION direction,
         const uint8_t steps, const uint8_t * const drops);

enum WIN_RESULT
check_win(const enum COLOUR colour);