Index

ncurses-minesweeper / 13c4747

Terminal game of Minesweeper, implemented in C with ncurses.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
4612 Oct 2021 15:4630e93feUpdate copyright year to 2021Josh Stockin111G

Blob @ ncurses-minesweeper / src / game / flag.c

text/plain875 bytesdownload raw
1/* ncurses-minesweeper Copyright (c) 2021 Joshua 'joshuas3' Stockin
2 * <https://joshstock.in>
3 * <https://github.com/JoshuaS3/ncurses-minesweeper>
4 *
5 * This software is licensed and distributed under the terms of the MIT License.
6 * See the MIT License in the LICENSE file of this project's root folder.
7 *
8 * This comment block and its contents, including this disclaimer, MUST be
9 * preserved in all copies or distributions of this software's source.
10 */
11
12#include <ncurses.h>
13
14#include "../state.h"
15
16void flag_current_cell(game_board *board) {
17 game_board_cell *cell = &board->cells[board->current_cell];
18 int delta = cell->flagged * 2 - 1;
19 if (!cell->opened) {
20 if (board->status == Playing && (board->mines_left + delta) >= 0) {
21 board->mines_left += delta;
22 cell->flagged = !cell->flagged;
23 }
24 } else
25 beep();
26}
27