From 4ad67ac92de26b12cbf6cd671de689e7d11ebebb Mon Sep 17 00:00:00 2001 From: tslil Date: Tue, 12 Jan 2021 21:42:35 -0500 Subject: Well it works, and it's bad. Many bugs fixed in interim --- include/tak.c | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) (limited to 'include/tak.c') diff --git a/include/tak.c b/include/tak.c index bb06a16..47a9cc6 100644 --- a/include/tak.c +++ b/include/tak.c @@ -132,22 +132,28 @@ try_move(const int8_t location, const enum MOVE_DIRECTION direction, switch (direction) { case M_UP: { delta = +board_size; - if (location + delta * steps > NUM_SQUARES) return ACT_ILLEGAL; + if (location + delta * steps > NUM_SQUARES) + return ACT_ILLEGAL; break; }; case M_DOWN: { delta = -board_size; - if (location + delta * steps < 0) return ACT_ILLEGAL; + if (location + delta * steps < 0) + return ACT_ILLEGAL; break; }; case M_RIGHT: { delta = +1; - if (location + delta * steps > NUM_SQUARES) return ACT_ILLEGAL; + if ((location + steps * delta) / board_size + > location / board_size) + return ACT_ILLEGAL; break; }; case M_LEFT: { delta = -1; - if (location + delta * steps < 0) return ACT_ILLEGAL; + if ((location + steps * delta) / board_size + < location / board_size) + return ACT_ILLEGAL; break; }; }; -- cgit v1.2.3