update is_move_valid

This commit is contained in:
Yorick Barbanneau 2021-10-01 16:19:21 +02:00
parent aa72f3bc30
commit 48c6360b0d

View file

@ -129,6 +129,27 @@ e_status is_move_valid(s_utictactoe *p_uttt, s_move *p_move){
if ( get_next_player_to_play(p_uttt) != p_move->player ) {
return NO;
}
if ( p_uttt->inception_level == 1 ) {
if ( p_uttt->outer_tictactoe->winner == NOBODY
&& p_uttt->outer_tictactoe->content[p_move->outer_position] == NOBODY) {
return YES;
}
else {
return NO;
}
}
else {
if (p_uttt->outer_tictactoe->winner == NOBODY
&& p_uttt->inner_tictactoes[p_move->outer_position]->content[p_move->inner_position] == NOBODY
&& p_uttt->inner_tictactoes[p_move->outer_position]->winner == NOBODY )
{
return YES;
}
else
{
return NO;
}
}
return YES;
}
@ -219,6 +240,15 @@ void set_tictactoe_winner(s_tictactoe *p_ttt){
}
}
e_status play_move(s_utictactoe *p_ttt, s_move *p_move) {
e_status play_move(s_utictactoe *p_uttt, s_move *p_move) {
if (is_move_valid(p_uttt, p_move) == YES) {
// we can process things
if ( p_uttt->inception_level == 1 ) {
p_uttt->outer_tictactoe->content[p_move->outer_position] = p_move->player;
}
else {
}
}
return YES;
}