]> git.gir.st - minesVIiper.git/commitdiff
add compile time flag 'FLAGALL_ON_CHOORD' master github/master
authorgirst <girst@users.noreply.github.com>
Fri, 27 Oct 2023 15:52:17 +0000 (17:52 +0200)
committergirst <girst@users.noreply.github.com>
Fri, 27 Oct 2023 15:52:17 +0000 (17:52 +0200)
when choording on an open cell, which has exactly the amount of closed
cells around it as it has mines next to it, flag all of them.

this is inspired by Lucas Nunes' Antimine.

mines.c
mines.h

diff --git a/mines.c b/mines.c
index 68c01ecc80253186623a757164056d8860aead45..837cbf9417e52f66275df007c84aca3d4f6ca168 100644 (file)
--- a/mines.c
+++ b/mines.c
@@ -284,6 +284,13 @@ int wait_mouse_up (int l, int c) {
        return ((l2 == l) && (c2 == c));
 }
 
+void flagall_square (int line, int col) {
+       AROUND(line,col)
+               if (AR_CELL.f != FLAG) {
+                       flag_square(ROW, COL);
+               }
+}
+
 int choord_square (int line, int col) {
        AROUND(line,col)
                if (AR_CELL.f != FLAG) {
@@ -358,6 +365,10 @@ int do_uncover (int* is_newgame, int actor) {
                if (uncover_square (g.p[0], g.p[1])) return GAME_LOST;
        } else if (get_neighbours (g.p[0], g.p[1], 1) == 0) {
                if (choord_square (g.p[0], g.p[1])) return GAME_LOST;
+#ifdef FLAGALL_ON_CHOORD
+       } else if (HI_CELL.n == closed_neighbours(g.p[0], g.p[1])) {
+               flagall_square(g.p[0], g.p[1]);
+#endif
        } else if (actor != MOUSE) {
                show_stomp(1, g.p[0], g.p[1]);
 
@@ -676,6 +687,16 @@ int get_neighbours (int line, int col, int reduced_mode) {
        return count;
 }
 
+int closed_neighbours (int line, int col) {
+       /* counts closed cells surrounding a square */
+
+       int count = 0;
+       AROUND(line, col) {
+               count += !AR_CELL.o;
+       }
+       return count;
+}
+
 void interactive_resize(void) {
        unsigned char buf[3];
        int old_w = f.w;
diff --git a/mines.h b/mines.h
index f4e86cec1252d589fd55ed1ce13bd19c12802f90..dc4a162d7bce8cecb85c8b596bba849df91e512f 100644 (file)
--- a/mines.h
+++ b/mines.h
@@ -83,9 +83,11 @@ void show_minefield (int);
 void show_stomp (int, int, int);
 void wait_keypress (int);
 int get_neighbours (int, int, int);
+int closed_neighbours (int, int);
 int uncover_square (int, int);
 void flag_square (int, int);
 void quesm_square (int, int);
+void flagall_square (int, int);
 int choord_square (int, int);
 int do_uncover (int*, int);
 int grand_opening (int*);
Imprint / Impressum