Determine if inner_ttt case is free
in is_move_valid()
This commit is contained in:
parent
7e7502dcec
commit
e6449a2013
1 changed files with 9 additions and 0 deletions
|
@ -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) {
|
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 ) {
|
if ( p_uttt->outer_tictactoe->winner != NOBODY ) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// this is the awaited player that played?
|
||||||
if ( get_next_player_to_play(p_uttt) != p_move->player ) {
|
if ( get_next_player_to_play(p_uttt) != p_move->player ) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the outer position is correct?
|
||||||
if ( get_next_outer_position(p_uttt) != FREE
|
if ( get_next_outer_position(p_uttt) != FREE
|
||||||
&& get_next_outer_position(p_uttt) != p_move->outer_position) {
|
&& get_next_outer_position(p_uttt) != p_move->outer_position) {
|
||||||
return NO;
|
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;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue