From 115acbee60c8dbd7e01e7cd2421af3ae98149362 Mon Sep 17 00:00:00 2001 From: girst Date: Thu, 1 Nov 2018 16:39:26 +0100 Subject: [PATCH] 'p': stomp adjacent stopgap feature for HJKL/^H^J^K^L; does the common action of choording around a cell after flagging it --- README.md | 1 + mines.c | 13 +++++++++++-- mines.h | 2 ++ 3 files changed, 14 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 4501c22..c9481fa 100644 --- a/README.md +++ b/README.md @@ -18,6 +18,7 @@ Complete documentation and screenshots can be found on the | `^`/`G`/`g`/`$` | move to the very left / bottom / top / right | | `i` | flag / unflag | | `o` | open / chord | +| `p` | chord all open adjacent cells | | space | modeful, either open or flag | | `s` | toggle mode for space (open/flag) | | `r` | restart game | diff --git a/mines.c b/mines.c index 14018f1..8cd384f 100644 --- a/mines.c +++ b/mines.c @@ -162,6 +162,7 @@ int minesviiper(void) { flag_cell: case CTRSEQ_MOUSE_RIGHT: case 'i': flag_square (g.p[0], g.p[1]); break; + case 'p':if(choord_around(g.p[0],g.p[1]))return GAME_LOST;break; quesm_cell: case '?':quesm_square (g.p[0], g.p[1]); break; case CTRSEQ_CURSOR_LEFT: @@ -278,7 +279,6 @@ int wait_mouse_up (int l, int c) { } int choord_square (int line, int col) { - if (uncover_square (line, col)) return 1; AROUND(line,col) if (AR_CELL.f != FLAG) { if (uncover_square (ROW, COL)) @@ -288,6 +288,15 @@ int choord_square (int line, int col) { return 0; } +int choord_around(int row, int col) { + AROUND(g.p[0], g.p[1]) { + if (AR_CELL.o == OPENED && get_neighbours (ROW, COL, 1) == 0) { + if (choord_square (ROW, COL)) return GAME_LOST; + } + } + return GAME_INPROGRESS; +} + int uncover_square (int l, int c) { if (f.c[l][c].o == OPENED) return 0; /* nothing to do */ @@ -340,7 +349,7 @@ int do_uncover (int* is_newgame, int actor) { timer_setup(1); } - if (HI_CELL.f == FLAG ) return GAME_INPROGRESS; + if (HI_CELL.f == FLAG ) return GAME_INPROGRESS; //TODO: could choord? if (HI_CELL.o == CLOSED) { if (uncover_square (g.p[0], g.p[1])) return GAME_LOST; } else if (get_neighbours (g.p[0], g.p[1], 1) == 0) { diff --git a/mines.h b/mines.h index 4aca95b..cc9924e 100644 --- a/mines.h +++ b/mines.h @@ -23,6 +23,7 @@ " z :center cursor on minefield\n" \ " o :open/choord\n" \ " i :flag/unflag\n" \ + " p :choord around\n" \ " space:modeful cursor (either open or flag)\n" \ " s :toggle mode for space (open/flag)\n" \ " mX :set a mark for letter X\n" \ @@ -87,6 +88,7 @@ int uncover_square (int, int); void flag_square (int, int); void quesm_square (int, int); int choord_square (int, int); +int choord_around(int, int); int do_uncover (int*, int); int ex_cmd(void); void set_mark(void); -- 2.39.3