From 0a3b2d825077b5e6c5f1cf4a0dcb13fdfffc0be6 Mon Sep 17 00:00:00 2001 From: tslil Date: Tue, 29 Dec 2020 22:48:53 -0500 Subject: Working on the big wrapper for everything --- include/tak.c | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 include/tak.c (limited to 'include/tak.c') diff --git a/include/tak.c b/include/tak.c new file mode 100644 index 0000000..85d04d4 --- /dev/null +++ b/include/tak.c @@ -0,0 +1,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; +} -- cgit v1.3.1