Index

ncurses-minesweeper / d83acc5

Terminal game of Minesweeper, implemented in C with ncurses.

Latest Commit

{#}TimeHashSubjectAuthor#(+)(-)GPG?
2117 Sep 2020 21:34d83acc5Rewrite and finish game and renderer codeJosh Stockin151109G

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

text/plain1490 bytesdownload raw
1/* ncurses-minesweeper Copyright (c) 2020 Joshua 'joshuas3' Stockin
2 * <https://joshstock.in>
3 * <https://github.com/JoshuaS3/lognestmonster>
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 'r':
28 case 'R': {
29 reset_board(board);
30 break;
31 }
32 case 'j':
33 case 'J': {
34 constrain_down(board);
35 break;
36 }
37 case 'k':
38 case 'K': {
39 constrain_up(board);
40 break;
41 }
42 case 'h':
43 case 'H': {
44 constrain_left(board);
45 break;
46 }
47 case 'l':
48 case 'L': {
49 constrain_right(board);
50 break;
51 }
52 case 'f':
53 case 'F': {
54 flag_current_cell(board);
55 break;
56 }
57 case 10:
58 case ' ': {
59 open_cell(board);
60 check_done(board);
61 break;
62 }
63 }
64}
65