Determine if inner_ttt case is free

in is_move_valid()
This commit is contained in:
Yorick Barbanneau 2021-10-07 22:46:46 +02:00
parent 7e7502dcec
commit e6449a2013

View file

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