mirror of
git://git.tartarus.org/simon/puzzles.git
synced 2025-04-21 16:05:44 -07:00
Now _this_ is what Undo ought to be doing in a Minesweeper clone.
Rather than revealing the entire mine layout when you die, we now only reveal the one mine that killed you. You can then Undo and continue playing, without having spoiled the rest of the grid for yourself. The number of times you've died is counted in the status line (and is not reduced by Undo :-). Amusingly, I think this in itself is quite a good way of dealing with ambiguous sections in a Minesweeper grid: they no longer _completely_ spoil your enjoyment of the game, because you can still play the remainder of the grid even if you haven't got a completely clean sweep. Just my luck that I should invent the idea when I've already arranged for ambiguous sections to be absent :-) [originally from svn r5886]
This commit is contained in:
30
mines.c
30
mines.c
@ -2142,22 +2142,11 @@ static int open_square(game_state *state, int x, int y)
|
|||||||
|
|
||||||
if (state->layout->mines[y*w+x]) {
|
if (state->layout->mines[y*w+x]) {
|
||||||
/*
|
/*
|
||||||
* The player has landed on a mine. Bad luck. Expose all
|
* The player has landed on a mine. Bad luck. Expose the
|
||||||
* the mines.
|
* mine that killed them, but not the rest (in case they
|
||||||
|
* want to Undo and carry on playing).
|
||||||
*/
|
*/
|
||||||
state->dead = TRUE;
|
state->dead = TRUE;
|
||||||
for (yy = 0; yy < h; yy++)
|
|
||||||
for (xx = 0; xx < w; xx++) {
|
|
||||||
if (state->layout->mines[yy*w+xx] &&
|
|
||||||
(state->grid[yy*w+xx] == -2 ||
|
|
||||||
state->grid[yy*w+xx] == -3)) {
|
|
||||||
state->grid[yy*w+xx] = 64;
|
|
||||||
}
|
|
||||||
if (!state->layout->mines[yy*w+xx] &&
|
|
||||||
state->grid[yy*w+xx] == -1) {
|
|
||||||
state->grid[yy*w+xx] = 66;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
state->grid[y*w+x] = 65;
|
state->grid[y*w+x] = 65;
|
||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
@ -2439,6 +2428,7 @@ static char *game_text_format(game_state *state)
|
|||||||
struct game_ui {
|
struct game_ui {
|
||||||
int hx, hy, hradius; /* for mouse-down highlights */
|
int hx, hy, hradius; /* for mouse-down highlights */
|
||||||
int flash_is_death;
|
int flash_is_death;
|
||||||
|
int deaths;
|
||||||
};
|
};
|
||||||
|
|
||||||
static game_ui *new_ui(game_state *state)
|
static game_ui *new_ui(game_state *state)
|
||||||
@ -2446,6 +2436,7 @@ static game_ui *new_ui(game_state *state)
|
|||||||
game_ui *ui = snew(game_ui);
|
game_ui *ui = snew(game_ui);
|
||||||
ui->hx = ui->hy = -1;
|
ui->hx = ui->hy = -1;
|
||||||
ui->hradius = 0;
|
ui->hradius = 0;
|
||||||
|
ui->deaths = 0;
|
||||||
ui->flash_is_death = FALSE; /* *shrug* */
|
ui->flash_is_death = FALSE; /* *shrug* */
|
||||||
return ui;
|
return ui;
|
||||||
}
|
}
|
||||||
@ -2522,6 +2513,8 @@ static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds,
|
|||||||
ret = dup_game(from);
|
ret = dup_game(from);
|
||||||
ret->just_used_solve = FALSE;
|
ret->just_used_solve = FALSE;
|
||||||
open_square(ret, cx, cy);
|
open_square(ret, cx, cy);
|
||||||
|
if (ret->dead)
|
||||||
|
ui->deaths++;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2554,6 +2547,8 @@ static game_state *make_move(game_state *from, game_ui *ui, game_drawstate *ds,
|
|||||||
(ret->grid[(cy+dy)*ret->w+(cx+dx)] == -2 ||
|
(ret->grid[(cy+dy)*ret->w+(cx+dx)] == -2 ||
|
||||||
ret->grid[(cy+dy)*ret->w+(cx+dx)] == -3))
|
ret->grid[(cy+dy)*ret->w+(cx+dx)] == -3))
|
||||||
open_square(ret, cx+dx, cy+dy);
|
open_square(ret, cx+dx, cy+dy);
|
||||||
|
if (ret->dead)
|
||||||
|
ui->deaths++;
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -2931,15 +2926,18 @@ static void game_redraw(frontend *fe, game_drawstate *ds, game_state *oldstate,
|
|||||||
{
|
{
|
||||||
char statusbar[512];
|
char statusbar[512];
|
||||||
if (state->dead) {
|
if (state->dead) {
|
||||||
sprintf(statusbar, "GAME OVER!");
|
sprintf(statusbar, "DEAD!");
|
||||||
} else if (state->won) {
|
} else if (state->won) {
|
||||||
if (state->used_solve)
|
if (state->used_solve)
|
||||||
sprintf(statusbar, "Auto-solved.");
|
sprintf(statusbar, "Auto-solved.");
|
||||||
else
|
else
|
||||||
sprintf(statusbar, "COMPLETED!");
|
sprintf(statusbar, "COMPLETED!");
|
||||||
} else {
|
} else {
|
||||||
sprintf(statusbar, "Mines marked: %d / %d", markers, mines);
|
sprintf(statusbar, "Marked: %d / %d", markers, mines);
|
||||||
}
|
}
|
||||||
|
if (ui->deaths)
|
||||||
|
sprintf(statusbar + strlen(statusbar),
|
||||||
|
" Deaths: %d", ui->deaths);
|
||||||
status_bar(fe, statusbar);
|
status_bar(fe, statusbar);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
14
puzzles.but
14
puzzles.but
@ -880,9 +880,19 @@ turn, and so on if any of them also has no surrounding mines. This
|
|||||||
will be done for you automatically; so sometimes when you uncover a
|
will be done for you automatically; so sometimes when you uncover a
|
||||||
square, a whole new area will open up to be explored.
|
square, a whole new area will open up to be explored.
|
||||||
|
|
||||||
(All the actions described in \k{common-actions} are also available.
|
All the actions described in \k{common-actions} are also available.
|
||||||
|
|
||||||
Even Undo is available, although you might consider it cheating to
|
Even Undo is available, although you might consider it cheating to
|
||||||
use it!)
|
use it. If you step on a mine, the program will only reveal the mine
|
||||||
|
in question (unlike most other implementations, which reveal all of
|
||||||
|
them). You can then Undo your fatal move and continue playing if you
|
||||||
|
like. The program will track the number of times you died (and Undo
|
||||||
|
will not reduce that counter), so when you get to the end of the
|
||||||
|
game you know whether or not you did it without making any errors.
|
||||||
|
|
||||||
|
(If you really want to know the full layout of the grid, which other
|
||||||
|
implementations will show you after you die, you can always use the
|
||||||
|
Solve menu option.)
|
||||||
|
|
||||||
\H{mines-parameters} \I{parameters, for Mines}Mines parameters
|
\H{mines-parameters} \I{parameters, for Mines}Mines parameters
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user