summaryrefslogtreecommitdiff
path: root/include/tak.c
blob: 85d04d4e7515110bb1d1cc3c41aabe0721fa2659 (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
#include "tak.h"

enum E_RESULT
try_ptn(char *ptn) {

  enum E_RESULT res;
  uint8_t location;

  if (likely_move(ptn)) {
    uint8_t steps, drops[5];
    enum MOVE_DIRECTION direction;
    res = parse_move(board_size, ptn, &location,
                     &direction, &steps, drops);
    if (res == PTN_VALID)
      res = try_move(location, direction, steps, drops);
  } else {
    enum STONE_VARIANT stone;
    res = parse_place(board_size, ptn, &location, &stone);
    if (res == PTN_VALID)
      res = try_place(location, current_colour, stone);
  }

  if (res == A_OK) {
    next_turn();
    if (turn > 1) return check_win();
  }

   return res;
}