From 0e8fb2242477965d85a7adb32a799739334cf8cf Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Thu, 7 Oct 2021 23:23:18 +0200 Subject: [PATCH] Re-add winner test for outer_ttt in is_move_valid() --- src/model.c | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/src/model.c b/src/model.c index 939031b..f7b6499 100644 --- a/src/model.c +++ b/src/model.c @@ -134,12 +134,10 @@ e_location get_next_outer_position(s_utictactoe *p_uttt) { } e_status is_move_valid(s_utictactoe *p_uttt, s_move *p_move) { - - // the party is not over? + // Get back thois simple test if ( p_uttt->outer_tictactoe->winner != NOBODY ) { return NO; } - // this is the awaited player that played? if ( get_next_player_to_play(p_uttt) != p_move->player ) { return NO; @@ -151,11 +149,23 @@ e_status is_move_valid(s_utictactoe *p_uttt, s_move *p_move) { return NO; } - // position in the inner position is free? - if ( p_uttt->inner_tictactoes[p_move->outer_position]->content[p_move->inner_position] != NOBODY ) { - return NO; + if ( p_uttt->inception_level == 1 ) { + if ( p_uttt->outer_tictactoe->content[p_move->outer_position] != NOBODY ) { + return NO; + } } + else { + // Already winned inner TTT + if ( p_uttt->inner_tictactoes[p_move->outer_position]->winner != NOBODY ) { + return NO; + } + // position in the inner position is free? + if ( p_uttt->inner_tictactoes[p_move->outer_position]->content[p_move->inner_position] != NOBODY ) { + return NO; + } + } + return YES; }