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; }