summaryrefslogtreecommitdiff
path: root/include/tak.c
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2020-12-29 22:48:53 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit0a3b2d825077b5e6c5f1cf4a0dcb13fdfffc0be6 (patch)
tree08b71fbf1810806e628bbf7f8d7b121d9b7c8443 /include/tak.c
parente57746530836b24b6d8d20e41239e955fa9e20d4 (diff)
Working on the big wrapper for everything
Diffstat (limited to 'include/tak.c')
-rw-r--r--include/tak.c29
1 files changed, 29 insertions, 0 deletions
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;
+}