diff options
| author | tslil <tslil@posteo.de> | 2021-01-12 21:42:35 -0500 |
|---|---|---|
| committer | tslil <tslil@posteo.de> | 2021-01-12 21:42:35 -0500 |
| commit | 539b9c9a875f1014fb1f9971272aa43bc220ac77 (patch) | |
| tree | 49ced293e408b4cdf2ba389f019cfe4d131a5070 /include/tak.c | |
| parent | 0feeb0e9f9abc0c7d0ea0324bb3be73e0be371b2 (diff) | |
Well it works, and it's bad. Many bugs fixed in interim
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; }; }; |
