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