diff options
Diffstat (limited to 'include/tak.c')
| -rw-r--r-- | include/tak.c | 14 |
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; }; }; |
