[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] master 8d079d3: Do not uncover flagged cells if the user dont wan
From: |
Tino Calancha |
Subject: |
[elpa] master 8d079d3: Do not uncover flagged cells if the user dont want that |
Date: |
Sat, 13 Jan 2018 23:13:13 -0500 (EST) |
branch: master
commit 8d079d3afbba1c66bf8d034297142cf809654719
Author: Tino Calancha <address@hidden>
Commit: Tino Calancha <address@hidden>
Do not uncover flagged cells if the user dont want that
If the user ask to uncover a flagged cell, we ask for
confirmation; then, the user might change his mind or
go ahead and uncover the cell.
There is a bug in the logic and the cell is uncovered even
after the user cancel this action. This commit fix that.
Bump version to 1.5
* mines.el (mines-dig): Do not uncover one flagged cell if the
user cancel this action.
---
packages/mines/mines.el | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/packages/mines/mines.el b/packages/mines/mines.el
index 63096a3..b82fa71 100644
--- a/packages/mines/mines.el
+++ b/packages/mines/mines.el
@@ -5,7 +5,7 @@
;; Author: Tino Calancha <address@hidden>
;; Created: 2017-10-28
;; Keywords: games
-;; Version: 1.4
+;; Version: 1.5
;; Package-Requires: ((emacs "24.4") (cl-lib "0.5"))
;; url: https://github.com/calancha/Minesweeper
@@ -545,6 +545,15 @@ If called again then unflag it."
(done nil) ; Already updated.
(t
(let ((elt (aref mines-grid idx)))
+ (cl-flet ((game-end-fn
+ ()
+ ;; Check for end of game.
+ (cond ((and (not show-mines) (eq elt
t))
+ ;; We lost the game; show all
the mines.
+ (mines-game-over))
+ (t
+ (when (and (not show-mines)
(mines-end-p))
+ (mines-game-completed))))))
;; Don't end the game in the first trial when
;; `mines-protect-first-move' is non-nil.
(when (and (eq elt t) mines-protect-first-move
(mines-first-move-p))
@@ -565,21 +574,17 @@ If called again then unflag it."
(mines-set-numbers)
;; Update current element.
(setq elt (aref mines-grid idx))))
- ;; If the cell is flagged ask for confirmation.
- (if (and (not show-mines) (eq (following-char)
mines-flagged-cell-char))
- (if (yes-or-no-p "This cell is flagged as
having a bomb. Uncover it? ")
- (progn ; Unflag first.
- (mines--update-cell idx
mines-uncover-cell-char 'unflag)
- (mines--update-cell idx elt))
- (message "OK, canceled"))
- (mines--update-cell idx elt))
- ;; Check for end of game.
- (cond ((and (not show-mines) (eq elt t))
- ;; We lost the game; show all the mines.
- (mines-game-over))
+ (cond ((and (not show-mines) (eq
(following-char) mines-flagged-cell-char))
+ ;; If the cell is flagged ask for
confirmation.
+ (cond ((yes-or-no-p "This cell is flagged
as having a bomb. Uncover it? ")
+ ;; Unflag first.
+ (mines--update-cell idx
mines-uncover-cell-char 'unflag)
+ (mines--update-cell idx elt)
+ (game-end-fn))
+ (t (message "OK, canceled"))))
(t
- (when (and (not show-mines) (mines-end-p))
- (mines-game-completed))))))))))
+ (mines--update-cell idx elt)
+ (game-end-fn))))))))))
(uncover-fn)
(when mines-undone-neighbours
(while mines-undone-neighbours
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- [elpa] master 8d079d3: Do not uncover flagged cells if the user dont want that,
Tino Calancha <=