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) {
|
||||
|
||||
// the party is not over?
|
||||
// Get back thois simple test
|
||||
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;
|
||||
|
@ -151,9 +149,21 @@ e_status is_move_valid(s_utictactoe *p_uttt, s_move *p_move) {
|
|||
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;
|
||||
if ( p_uttt->inception_level == 1 ) {
|
||||
if ( p_uttt->outer_tictactoe->content[p_move->outer_position] != NOBODY ) {
|
||||
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;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue