Removed ONLYPUT
This commit is contained in:
parent
4f25f66495
commit
89712fc9dc
8 changed files with 25 additions and 53 deletions
16
ui_vt100.c
16
ui_vt100.c
|
|
@ -72,10 +72,8 @@ void updateBoard(
|
|||
const int column
|
||||
){
|
||||
int height = board.height [ column ];
|
||||
#ifndef ONLYPUT
|
||||
switch( move ){
|
||||
case PUT: // Only print the put one
|
||||
#endif /* ! ONLYPUT */
|
||||
printf(
|
||||
"\033[%dA\033[%dC%c\033[%dB",
|
||||
height + 3,
|
||||
|
|
@ -83,7 +81,6 @@ void updateBoard(
|
|||
'0' + !!( board.player ),
|
||||
height + 1
|
||||
);
|
||||
#ifndef ONLYPUT
|
||||
break;
|
||||
default: // Print all the pieces in the column and the air above
|
||||
printf( "\033[%dA", height + 4 );
|
||||
|
|
@ -96,7 +93,6 @@ void updateBoard(
|
|||
);
|
||||
printf( "\033[2B" );
|
||||
}
|
||||
#endif /* ! ONLYPUT */
|
||||
printf(
|
||||
"\r\033[7A\033[%dC"
|
||||
"%3d │%3d\033[B\033[8D"
|
||||
|
|
@ -116,21 +112,15 @@ void updateBoard(
|
|||
|
||||
int askColumn(
|
||||
const board_t board
|
||||
#ifndef ONLYPUT
|
||||
,const move_t move
|
||||
#endif /* ONLYPUT */
|
||||
){
|
||||
int column;
|
||||
for(;;){
|
||||
#ifndef ONLYPUT
|
||||
switch( move ){
|
||||
case PUT: printf( "Wher player %d put? ", board.player );
|
||||
break;
|
||||
case POP: printf( "Wher player %d pop? ", board.player );
|
||||
}
|
||||
#else /* ONLYPUT */
|
||||
printf( "Wher player %d put? ", board.player );
|
||||
#endif /* ONLYPUT */
|
||||
printf( "\033[K" ); // clear everything after cursor
|
||||
fflush( stdout );
|
||||
column = -1;
|
||||
|
|
@ -148,34 +138,28 @@ int askColumn(
|
|||
}
|
||||
column -= FIRST_NUMBER;
|
||||
if( column >= 0 && column < BOARD_WIDTH )
|
||||
#ifndef ONLYPUT
|
||||
switch( move ){
|
||||
case PUT:
|
||||
#endif /* ! ONLYPUT */
|
||||
if( board.height [ column ] < BOARD_HEIGHT )
|
||||
return column;
|
||||
else printf( "\033[2Apls enter a column that ain't full" );
|
||||
#ifndef ONLYPUT
|
||||
break;
|
||||
case POP:
|
||||
if( board.height [ column ] != 0 )
|
||||
return column;
|
||||
else printf( "\033[2Apls enter a column that ain't empty" );
|
||||
}
|
||||
#endif /* ! ONLYPUT */
|
||||
else
|
||||
printf( "\033[2Apls enter valid column" );
|
||||
printf( "\033[K\n" );
|
||||
}
|
||||
}
|
||||
|
||||
#ifndef ONLYPUT
|
||||
move_t askMove( void ){
|
||||
move_t move = PUT;
|
||||
// TODO: actually ask what move
|
||||
return move;
|
||||
}
|
||||
#endif /* ! ONLYPUT */
|
||||
|
||||
#undef BOARD_WIDTH_CHARS
|
||||
#undef SCOREBOARD_OFFSET
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue