[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[elpa] externals/mines 9b07cb6 33/43: Do not uncover flagged cells if th
From: |
Stefan Monnier |
Subject: |
[elpa] externals/mines 9b07cb6 33/43: Do not uncover flagged cells if the user dont want that |
Date: |
Mon, 30 Nov 2020 18:44:19 -0500 (EST) |
branch: externals/mines
commit 9b07cb6deae160ef5aaff617102001f28bb55a5f
Author: Tino Calancha <tino.calancha@gmail.com>
Commit: Tino Calancha <tino.calancha@gmail.com>
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.
---
mines.el | 35 ++++++++++++++++++++---------------
1 file changed, 20 insertions(+), 15 deletions(-)
diff --git a/mines.el b/mines.el
index 63096a3..b82fa71 100644
--- a/mines.el
+++ b/mines.el
@@ -5,7 +5,7 @@
;; Author: Tino Calancha <tino.calancha@gmail.com>
;; 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
- [elpa] externals/mines 2241dcd 36/43: * mines/mines.el: Various minor changes, wave 1, (continued)
- [elpa] externals/mines 2241dcd 36/43: * mines/mines.el: Various minor changes, wave 1, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 3308a99 38/43: * packages/mines/mines.el: Keep flag in mines-state, Stefan Monnier, 2020/11/30
- [elpa] externals/mines e090a90 40/43: * mines.el: Make sure the first move is successful, Stefan Monnier, 2020/11/30
- [elpa] externals/mines bea3ad8 42/43: * packages/mines/mines.el (mines-auto-flag): New custom var, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 97e0a05 43/43: * mines.el: Adjust docs for the @ => SPC change, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 92399df 29/43: * packages/mines/mines.el: Bump version to 1.2, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 868e9b9 35/43: * mines.el: Bump version to v1.6, Stefan Monnier, 2020/11/30
- [elpa] externals/mines e127c84 30/43: Add fallback function for read-multiple-choice, Stefan Monnier, 2020/11/30
- [elpa] externals/mines bf577b0 31/43: Sort the score file from better to worst results, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 179ed77 32/43: Dont prompt user when updating the score file, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 9b07cb6 33/43: Do not uncover flagged cells if the user dont want that,
Stefan Monnier <=
- [elpa] externals/mines 34d088c 34/43: Reimplement mines-end-p, Stefan Monnier, 2020/11/30
- [elpa] externals/mines 5920f2d 37/43: * mines/mines.el (mines-grid): Use `bomb` instead of t, Stefan Monnier, 2020/11/30
- [elpa] externals/mines f11e546 41/43: * mines.el (mines-mode-map): Add mouse bindings, Stefan Monnier, 2020/11/30