Removed all move_t stuff because it was not implemented and anything other than putting got broken in the previous commit

This commit is contained in:
AnnaSnoeijs 2025-06-06 21:31:59 +02:00
parent 8810175693
commit 355c79bac4
7 changed files with 39 additions and 156 deletions

View file

@ -69,31 +69,16 @@ void initBoard( const board_t board ){
void updateBoard(
const wins_t wins,
const board_t board,
const move_t move,
const int column
){
int height = board.height [ column ];
switch( move ){
case PUT: // Only print the put one
printf(
"\033[%dA\033[%dC%c\033[%dB",
height + 3,
column * 3 + 4,
'0' + !!( board.player ),
height + 1
);
break;
default: // Print all the pieces in the column and the air above
printf( "\033[%dA", height + 4 );
if( height < board.rows ) printf( "\033[%dC ", column * 3 + 4 );
else printf( "\033[%dC", column * 3 + 5 );
for( int row = height; row --> 0; )
printf(
"\033[B\033[D%c",
'0' + !!( board.column [ column ] & ( 1 << row ) )
);
printf( "\033[2B" );
}
printf(
"\033[%dA\033[%dC%c\033[%dB",
height + 3,
column * 3 + 4,
'0' + !!( board.player ),
height + 1
);
printf(
"\r\033[7A\033[%dC"
"%3d │%3d\033[B\033[8D"
@ -112,18 +97,11 @@ void updateBoard(
}
int askColumn(
const board_t board,
const move_t move
const board_t board
){
int column;
for(;;){
switch( move ){
case PUT: printf( "Wher player %d put? ", board.player );
break;
case POP: printf( "Wher player %d pop? ", board.player );
break;
default: printf( "Wher player %d do the thing? ", board.player );
}
printf( "Wher player %d put? ", board.player );
printf( "\033[K" ); // clear everything after cursor
fflush( stdout );
column = -1;
@ -141,32 +119,15 @@ int askColumn(
}
column -= FIRST_NUMBER;
if( column >= 0 && column < board.columns )
switch( move ){
case PUT:
if( board.height [ column ] < board.rows )
return column;
else printf( "\033[2Apls enter a column that ain't full" );
break;
case POP:
if( board.height [ column ] != 0 )
return column;
else printf( "\033[2Apls enter a column that ain't empty" );
break;
default:
return column;
}
if( board.height [ column ] < board.rows )
return column;
else printf( "\033[2Apls enter a column that ain't full" );
else
printf( "\033[2Apls enter valid column" );
printf( "\033[K\n" );
}
}
move_t askMove( void ){
move_t move = PUT;
// TODO: actually ask what move
return move;
}
#undef BOARD_WIDTH_CHARS
#undef SCOREBOARD_OFFSET
#undef SCOREBOARD_WIDTH