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:
parent
3adeee7333
commit
91ef2ca22a
1 changed files with 11 additions and 1 deletions
12
main.scm
12
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))))))
|
||||
|
|
Loading…
Reference in a new issue