From 514e9f397f284b8a1876eb83daa6c3fb09d2daff Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Fri, 8 Oct 2021 15:17:11 +0200 Subject: [PATCH] Fist version of play_move() --- src/model.c | 22 ++++++++++++++++++---- 1 file changed, 18 insertions(+), 4 deletions(-) diff --git a/src/model.c b/src/model.c index f7b6499..2eaf771 100644 --- a/src/model.c +++ b/src/model.c @@ -260,7 +260,7 @@ void set_tictactoe_winner(s_tictactoe *p_ttt){ if ( p_ttt->content[i] == NOBODY ) { find = true; break; - } + } } if ( find == false ) { p_ttt->winner = BOTH; @@ -271,12 +271,26 @@ void set_tictactoe_winner(s_tictactoe *p_ttt){ e_status play_move(s_utictactoe *p_uttt, s_move *p_move) { if (is_move_valid(p_uttt, p_move) == YES) { // we can process things - if ( p_uttt->inception_level == 1 ) { - p_uttt->outer_tictactoe->content[p_move->outer_position] = p_move->player; + p_uttt->outer_tictactoe->content[p_move->outer_position] = p_move->player; + list_element_s_move *value = (list_element_s_move*) + malloc(sizeof(list_element_s_move)); + value->last_move = p_move; + if ( p_uttt->history == NULL ){ + value->next = NULL; } else { - + value->next = p_uttt->history; } + p_uttt->history = value; } + else { + return NO; + } + if ( p_uttt->inception_level == 1 ) { + } + else { + set_tictactoe_winner(p_uttt->inner_tictactoes[p_move->inner_position]); + } + set_tictactoe_winner(p_uttt->outer_tictactoe); return YES; }