Add BOTH in set_tictactoe_winner

This commit is contained in:
Yorick Barbanneau 2021-10-01 16:50:18 +02:00
parent c342b2c416
commit 09754638de

View file

@ -110,6 +110,7 @@ e_player get_next_player_to_play(s_utictactoe *p_uttt) {
if ( p_uttt->outer_tictactoe->winner != NOBODY ) { if ( p_uttt->outer_tictactoe->winner != NOBODY ) {
return NOBODY; return NOBODY;
} }
if ( p_uttt->history->last_move->player == PLAYER_O || if ( p_uttt->history->last_move->player == PLAYER_O ||
p_uttt->history->last_move == NULL ) { p_uttt->history->last_move == NULL ) {
return PLAYER_X; return PLAYER_X;
@ -241,6 +242,18 @@ void set_tictactoe_winner(s_tictactoe *p_ttt){
} }
} }
} }
// check if a move could be done, if not retuen BOTH (no winner)
find = false;
for (int i = 0; i < TICTACTOE_SIZE; i++){
if ( p_ttt->content[i] == NOBODY ) {
find = true;
break;
}
}
if ( find == false )
p_ttt->winner = BOTH;
}
} }
} }