Removed ONLYPUT

This commit is contained in:
AnnaSnoeijs 2025-06-06 21:31:59 +02:00
parent 4f25f66495
commit 89712fc9dc
8 changed files with 25 additions and 53 deletions

View file

@ -206,9 +206,7 @@ void updateBoard(
int askColumn(
const board_t board
#ifndef ONLYPUT
,const move_t move
#endif /* ONLYPUT */
){
int column = 0;
#ifdef ARROWS
@ -233,15 +231,32 @@ int askColumn(
case KEY_DOWN:
return column;
}
for(; board.height[ column ] >= BOARD_HEIGHT; ) switch( ch ){
case KEY_RIGHT:
if( column >= BOARD_WIDTH ) ch = KEY_LEFT;
else column++;
switch( move ){
case PUT:
for(; board.height[ column ] >= BOARD_HEIGHT; ) switch( ch ){
case KEY_RIGHT:
if( column >= BOARD_WIDTH ) ch = KEY_LEFT;
else column++;
break;
case KEY_LEFT:
if( column == 0 ) ch = KEY_RIGHT;
else column--;
break;
}
break;
case KEY_LEFT:
if( column == 0 ) ch = KEY_RIGHT;
else column--;
case POP:
for(; board.height[ column ] <= 0; ) switch( ch ){
case KEY_RIGHT:
if( column >= BOARD_WIDTH ) ch = KEY_LEFT;
else column++;
break;
case KEY_LEFT:
if( column == 0 ) ch = KEY_RIGHT;
else column--;
break;
}
break;
// Do nothing
}
}
#else /* !ARROWS */
@ -253,16 +268,12 @@ int askColumn(
);
if( board.player ) addstr( "1" );
else addstr( "0" );
#ifndef ONLYPUT
switch( move ){
case PUT:
#endif /* ONLYPUT */
addstr( " put the piece? " );
#ifndef ONLYPUT
case POP:
addstr( " pop a piece? " );
}
#endif /* ONLYPUT */
clrtoeol();
refresh();
scanw( " %d", &column );
@ -273,33 +284,27 @@ int askColumn(
);
clrtoeol();
if( column >= 0 && column < BOARD_WIDTH )
#ifndef ONLYPUT
switch( move ){
case PUT:
#endif /* ! ONLYPUT */
if( board.height [ column ] < BOARD_HEIGHT )
return column;
else addstr( "Pls enter a column that ain't full" );
#ifndef ONLYPUT
break;
case POP:
if( board.height [ column ] != 0 )
return column;
else addstr( "Pls enter a column that ain't empty" );
}
#endif /* ! ONLYPUT */
else addstr( "Pls enter a column that exists" );
}
#endif /* ! ARROWS */
}
#ifndef ONLYPUT
move_t askMove( void ){
move_t move = PUT;
// TODO: actually ask what move
return move;
}
#endif /* ! ONLYPUT */
#undef INPUT_X
#undef INPUT_Y