From e6449a2013f12385ff4a9a37cd220c4197a9a337 Mon Sep 17 00:00:00 2001 From: Yorick Barbanneau Date: Thu, 7 Oct 2021 22:46:46 +0200 Subject: [PATCH] Determine if inner_ttt case is free in is_move_valid() --- src/model.c | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/src/model.c b/src/model.c index c8112f8..939031b 100644 --- a/src/model.c +++ b/src/model.c @@ -134,18 +134,27 @@ 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? 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; } + // the outer position is correct? if ( get_next_outer_position(p_uttt) != FREE && get_next_outer_position(p_uttt) != p_move->outer_position) { 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; }