Re-add winner test for outer_ttt in is_move_valid()
This commit is contained in:
parent
e6449a2013
commit
0e8fb22424
1 changed files with 16 additions and 6 deletions
22
src/model.c
22
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) {
|
e_status is_move_valid(s_utictactoe *p_uttt, s_move *p_move) {
|
||||||
|
// Get back thois simple test
|
||||||
// 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?
|
// 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;
|
||||||
|
@ -151,11 +149,23 @@ e_status is_move_valid(s_utictactoe *p_uttt, s_move *p_move) {
|
||||||
return NO;
|
return NO;
|
||||||
}
|
}
|
||||||
|
|
||||||
// position in the inner position is free?
|
if ( p_uttt->inception_level == 1 ) {
|
||||||
if ( p_uttt->inner_tictactoes[p_move->outer_position]->content[p_move->inner_position] != NOBODY ) {
|
if ( p_uttt->outer_tictactoe->content[p_move->outer_position] != NOBODY ) {
|
||||||
return NO;
|
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;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue