Fist version of play_move()

This commit is contained in:
Yorick Barbanneau 2021-10-08 15:17:11 +02:00
parent 0e8fb22424
commit 514e9f397f

View file

@ -271,12 +271,26 @@ void set_tictactoe_winner(s_tictactoe *p_ttt){
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;
list_element_s_move *value = (list_element_s_move*)
malloc(sizeof(list_element_s_move));
value->last_move = p_move;
if ( p_uttt->history == NULL ){
value->next = NULL;
}
else {
value->next = p_uttt->history;
}
p_uttt->history = value;
}
else {
return NO;
}
if ( p_uttt->inception_level == 1 ) {
}
else {
set_tictactoe_winner(p_uttt->inner_tictactoes[p_move->inner_position]);
}
set_tictactoe_winner(p_uttt->outer_tictactoe);
return YES;
}