Index

ncurses-minesweeper / 7eb2a2e

Terminal game of Minesweeper, implemented in C with ncurses.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
3119 Sep 2020 12:587eb2a2eFix some thingsJosh Stockin110G

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

text/plain1511 bytesdownload raw
1/* ncurses-minesweeper Copyright (c) 2020 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#include "constrain_movement.h"
16#include "done.h"
17#include "flag.h"
18#include "nearest_cells.h"
19#include "new.h"
20#include "open.h"
21#include "reset.h"
22
23
24void game(game_state *state, int ch) {
25 game_board *board = state->board;
26 switch (ch) {
27 case 0:
28 case 'r':
29 case 'R': {
30 reset_board(board);
31 break;
32 }
33 case 'j':
34 case 'J': {
35 constrain_down(board);
36 break;
37 }
38 case 'k':
39 case 'K': {
40 constrain_up(board);
41 break;
42 }
43 case 'h':
44 case 'H': {
45 constrain_left(board);
46 break;
47 }
48 case 'l':
49 case 'L': {
50 constrain_right(board);
51 break;
52 }
53 case 'f':
54 case 'F': {
55 flag_current_cell(board);
56 break;
57 }
58 case 10:
59 case ' ': {
60 open_cell(board);
61 check_done(board);
62 break;
63 }
64 }
65}
66