diff options
author | Frederick Yin <fkfd@fkfd.me> | 2022-06-01 18:40:01 +0800 |
---|---|---|
committer | Frederick Yin <fkfd@fkfd.me> | 2022-06-01 18:40:01 +0800 |
commit | d3058d7617e134d0ff645de1fc01ffe94d7dcc79 (patch) | |
tree | 773329ca64e683cf22684fa119c80e606a3b9520 /sirtet.c | |
parent | 3b8ecc1d1864f4368e1621284b482996ed87b72f (diff) |
When switching, coerce piece inside boundary
Diffstat (limited to 'sirtet.c')
-rw-r--r-- | sirtet.c | 9 |
1 files changed, 9 insertions, 0 deletions
@@ -158,6 +158,11 @@ void sirtet(int H, int W, int P) { pc_idx = (pc_idx + P - 1) % P; if (hand[pc_idx] != NULL) { pc = hand[pc_idx]; + // move piece inside boundary if necessary + if (row + (pc->h) > H) + row = H - pc->h; + if (col + (pc->w) > W) + col = W - pc->w; break; } } @@ -168,6 +173,10 @@ void sirtet(int H, int W, int P) { pc_idx = (pc_idx + 1) % P; if (hand[pc_idx] != NULL) { pc = hand[pc_idx]; + if (row + (pc->h) > H) + row = H - pc->h; + if (col + (pc->w) > W) + col = W - pc->w; break; } } |