Expanded move_t type with QUIT and added MOVECOUNT
This commit is contained in:
parent
7bbd877fb5
commit
2d11458586
4 changed files with 16 additions and 3 deletions
1
logic.c
1
logic.c
|
|
@ -52,6 +52,7 @@ void playMove(
|
||||||
case POP: // Pop out the lowest and make all above fall down
|
case POP: // Pop out the lowest and make all above fall down
|
||||||
boardptr->column [ column ] >>= 1;
|
boardptr->column [ column ] >>= 1;
|
||||||
boardptr->height [ column ]--;
|
boardptr->height [ column ]--;
|
||||||
|
default: // Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
4
types.h
4
types.h
|
|
@ -5,8 +5,10 @@
|
||||||
#include "config.h"
|
#include "config.h"
|
||||||
|
|
||||||
typedef enum {
|
typedef enum {
|
||||||
|
QUIT=0,
|
||||||
PUT,
|
PUT,
|
||||||
POP
|
POP,
|
||||||
|
MOVECOUNT
|
||||||
} move_t;
|
} move_t;
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
|
|
||||||
|
|
@ -269,6 +269,7 @@ int askColumn(
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
default:
|
||||||
// Do nothing
|
// Do nothing
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -286,6 +287,8 @@ int askColumn(
|
||||||
addstr( " put the piece? " );
|
addstr( " put the piece? " );
|
||||||
case POP:
|
case POP:
|
||||||
addstr( " pop a piece? " );
|
addstr( " pop a piece? " );
|
||||||
|
default:
|
||||||
|
addstr( " Undefined move a thingy? " );
|
||||||
}
|
}
|
||||||
clrtoeol();
|
clrtoeol();
|
||||||
refresh();
|
refresh();
|
||||||
|
|
@ -307,6 +310,8 @@ int askColumn(
|
||||||
if( board.height [ column ] != 0 )
|
if( board.height [ column ] != 0 )
|
||||||
return column;
|
return column;
|
||||||
else addstr( "Pls enter a column that ain't empty" );
|
else addstr( "Pls enter a column that ain't empty" );
|
||||||
|
default:
|
||||||
|
return column;
|
||||||
}
|
}
|
||||||
else addstr( "Pls enter a column that exists" );
|
else addstr( "Pls enter a column that exists" );
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -118,9 +118,11 @@ int askColumn(
|
||||||
int column;
|
int column;
|
||||||
for(;;){
|
for(;;){
|
||||||
switch( move ){
|
switch( move ){
|
||||||
case PUT: printf( "Wher player %d put? ", board.player );
|
case PUT: printf( "Wher player %d put? ", board.player );
|
||||||
break;
|
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
|
printf( "\033[K" ); // clear everything after cursor
|
||||||
fflush( stdout );
|
fflush( stdout );
|
||||||
|
|
@ -149,6 +151,9 @@ int askColumn(
|
||||||
if( board.height [ column ] != 0 )
|
if( board.height [ column ] != 0 )
|
||||||
return column;
|
return column;
|
||||||
else printf( "\033[2Apls enter a column that ain't empty" );
|
else printf( "\033[2Apls enter a column that ain't empty" );
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
return column;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
printf( "\033[2Apls enter valid column" );
|
printf( "\033[2Apls enter valid column" );
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue