From 91ef2ca22a32d0302b5c0fc64213f59c80c5934f Mon Sep 17 00:00:00 2001 From: mehbark Date: Sun, 24 Dec 2023 14:23:41 -0500 Subject: [PATCH] don't game over if you click on a mine before revealing squares not as good as what you're supposed to do but oh well --- main.scm | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/main.scm b/main.scm index 01f91be..b5bc7f7 100644 --- a/main.scm +++ b/main.scm @@ -559,6 +559,15 @@ (length (filter square-mine? (game-around game x y))))) game)) +; slow but who cares +(define (game-has-revealed-square? game) + (define yeah? #f) + (vector-for-each + (lambda (square) + (when (square-revealed? square) + (set! yeah? #t))) + (game-squares game)) + yeah?) ; as feared, make-vector references the same thing (define (new-game mines width height) @@ -573,7 +582,8 @@ (define square (game-square-at game x y)) (unless (square-revealed? square) (if (square-mine? square) - (game-over?-set! game #t) + (when (game-has-revealed-square? game) + (game-over?-set! game #t)) (begin (square-revealed?-set! square #t) (when (zero? (square-num-adjacent square)) (game-map-around game-reveal! game x y))))))