Add BOTH in set_tictactoe_winner
This commit is contained in:
parent
c342b2c416
commit
09754638de
1 changed files with 13 additions and 0 deletions
13
src/model.c
13
src/model.c
|
@ -110,6 +110,7 @@ e_player get_next_player_to_play(s_utictactoe *p_uttt) {
|
|||
if ( p_uttt->outer_tictactoe->winner != NOBODY ) {
|
||||
return NOBODY;
|
||||
}
|
||||
|
||||
if ( p_uttt->history->last_move->player == PLAYER_O ||
|
||||
p_uttt->history->last_move == NULL ) {
|
||||
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;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue