summaryrefslogtreecommitdiff
path: root/include/tak.c
diff options
context:
space:
mode:
authortslil <tslil@posteo.de>2021-01-12 21:42:35 -0500
committertslil <tslil@posteo.de>2026-08-28 19:37:41 +0100
commit4ad67ac92de26b12cbf6cd671de689e7d11ebebb (patch)
tree49ced293e408b4cdf2ba389f019cfe4d131a5070 /include/tak.c
parentf33d6fc3b09ade5b57b9438b54519e36e4261362 (diff)
Well it works, and it's bad. Many bugs fixed in interim
Diffstat (limited to 'include/tak.c')
-rw-r--r--include/tak.c14
1 files changed, 10 insertions, 4 deletions
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;
};
};