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
This commit is contained in:
mehbark 2023-12-24 14:23:41 -05:00
parent 3adeee7333
commit 91ef2ca22a

View file

@ -559,6 +559,15 @@
(length (filter square-mine? (game-around game x y))))) (length (filter square-mine? (game-around game x y)))))
game)) 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 ; as feared, make-vector references the same thing
(define (new-game mines width height) (define (new-game mines width height)
@ -573,7 +582,8 @@
(define square (game-square-at game x y)) (define square (game-square-at game x y))
(unless (square-revealed? square) (unless (square-revealed? square)
(if (square-mine? 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) (begin (square-revealed?-set! square #t)
(when (zero? (square-num-adjacent square)) (when (zero? (square-num-adjacent square))
(game-map-around game-reveal! game x y)))))) (game-map-around game-reveal! game x y))))))