From 09754638deda93421ef561060a882c1412f80885 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Fri, 1 Oct 2021 16:50:18 +0200 Subject: [PATCH] Add BOTH in set_tictactoe_winner --- src/model.c | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/src/model.c b/src/model.c index 40ba735..90a0bbd 100644 --- a/src/model.c +++ b/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; + } } }