From 2d1145858613fcaea69688fe6f9ad3d81c292cf3 Mon Sep 17 00:00:00 2001 From: AnnaSnoeijs Date: Fri, 6 Jun 2025 21:31:59 +0200 Subject: [PATCH] Expanded move_t type with QUIT and added MOVECOUNT --- logic.c | 1 + types.h | 4 +++- ui_ncurses.c | 5 +++++ ui_vt100.c | 9 +++++++-- 4 files changed, 16 insertions(+), 3 deletions(-) diff --git a/logic.c b/logic.c index 21a251f..8651e2b 100644 --- a/logic.c +++ b/logic.c @@ -52,6 +52,7 @@ void playMove( case POP: // Pop out the lowest and make all above fall down boardptr->column [ column ] >>= 1; boardptr->height [ column ]--; + default: // Do nothing } } diff --git a/types.h b/types.h index 54d2d7b..b55d6d6 100644 --- a/types.h +++ b/types.h @@ -5,8 +5,10 @@ #include "config.h" typedef enum { + QUIT=0, PUT, - POP + POP, + MOVECOUNT } move_t; typedef struct { diff --git a/ui_ncurses.c b/ui_ncurses.c index 31d535f..6f71f5b 100644 --- a/ui_ncurses.c +++ b/ui_ncurses.c @@ -269,6 +269,7 @@ int askColumn( break; } break; + default: // Do nothing } } @@ -286,6 +287,8 @@ int askColumn( addstr( " put the piece? " ); case POP: addstr( " pop a piece? " ); + default: + addstr( " Undefined move a thingy? " ); } clrtoeol(); refresh(); @@ -307,6 +310,8 @@ int askColumn( if( board.height [ column ] != 0 ) return column; else addstr( "Pls enter a column that ain't empty" ); + default: + return column; } else addstr( "Pls enter a column that exists" ); } diff --git a/ui_vt100.c b/ui_vt100.c index 2a54a15..7598f18 100644 --- a/ui_vt100.c +++ b/ui_vt100.c @@ -118,9 +118,11 @@ int askColumn( int column; for(;;){ switch( move ){ - case PUT: printf( "Wher player %d put? ", board.player ); + case PUT: printf( "Wher player %d put? ", board.player ); break; - case POP: printf( "Wher player %d pop? ", board.player ); + case POP: printf( "Wher player %d pop? ", board.player ); + break; + default: printf( "Wher player %d do the thing? ", board.player ); } printf( "\033[K" ); // clear everything after cursor fflush( stdout ); @@ -149,6 +151,9 @@ int askColumn( if( board.height [ column ] != 0 ) return column; else printf( "\033[2Apls enter a column that ain't empty" ); + break; + default: + return column; } else printf( "\033[2Apls enter valid column" );