Skip to content

Commit

Permalink
format code
Browse files Browse the repository at this point in the history
  • Loading branch information
Judro committed Nov 25, 2024
1 parent a9ec70d commit afb392b
Show file tree
Hide file tree
Showing 5 changed files with 20 additions and 24 deletions.
2 changes: 1 addition & 1 deletion src/controls.c
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ int cmove(GameInstance g, WINDOW *window) {
case 'q':
return -1;
case 'f':
flag_cell(g);
flag_cell(g);
case 's':
unveil_cell(g);
case 'e':
Expand Down
5 changes: 1 addition & 4 deletions src/display.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@
#include <stdlib.h>
#include <time.h>



char *generate_top_margin(unsigned int l) {
if (l > 1000)
l = 1;
Expand Down Expand Up @@ -35,8 +33,7 @@ void print_left_margin(unsigned int terminal_x, unsigned int game_x) {
free(lm);
}

void print_header(GameView view, unsigned int terminal_x,
unsigned int game_x) {
void print_header(GameView view, unsigned int terminal_x, unsigned int game_x) {
print_left_margin(terminal_x, game_x);
printw("│");
int mtw = 15;
Expand Down
17 changes: 8 additions & 9 deletions src/game.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ typedef enum GameState {
Lost,
} GameState;

typedef enum CellType {
typedef enum CellType {
UNTOUCHED,
UNVEILED,
FALSE_FLAG,
Expand All @@ -30,15 +30,14 @@ typedef enum CellType {
EIGHT,
} CellType;


typedef struct GameView {
CellType *cells;
Cord player;
unsigned width;
unsigned height;
GameState state;
unsigned mines;
time_t time;
CellType *cells;
Cord player;
unsigned width;
unsigned height;
GameState state;
unsigned mines;
time_t time;
} *GameView;

GameState game_state(GameInstance);
Expand Down
2 changes: 1 addition & 1 deletion src/menu.c
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ GameInstance select_mode(unsigned int terminal_width,
if (ret == -1)
return NULL;
if (menu.selected == 1) {
last_selected = menu.pos;
last_selected = menu.pos;
switch (menu.pos) {
case 0:
return createGameInstance(20, 5, 7);
Expand Down
18 changes: 9 additions & 9 deletions src/mines.c
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ void print_game(GameInstance game, WINDOW *window) {
erase();
print_top_margin(getmaxy(window), field_height(game) + 2);
GameView view;
if(game_state(game) == Lost) {
if (game_state(game) == Lost) {
view = createViewGameover(game);
} else {
view = createView(game);
Expand Down Expand Up @@ -64,16 +64,16 @@ int main(int argc, char *argv[]) {
validate_flags(game);
if (cmove(game, window) == -1)
break;
switch (game_state(game)){
case Playing:
break;
case Lost:
case Won:
switch (game_state(game)) {
case Playing:
break;
case Lost:
case Won:
print_game(game, window);
while (1) {
if (cmove(game, window) == -1)
goto new_game;
limit_fps();
if (cmove(game, window) == -1)
goto new_game;
limit_fps();
}
}
limit_fps();
Expand Down

0 comments on commit afb392b

Please sign in to comment.