Fist version of play_move()
This commit is contained in:
parent
0e8fb22424
commit
514e9f397f
1 changed files with 18 additions and 4 deletions
18
src/model.c
18
src/model.c
|
@ -271,12 +271,26 @@ void set_tictactoe_winner(s_tictactoe *p_ttt){
|
||||||
e_status play_move(s_utictactoe *p_uttt, 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) {
|
if (is_move_valid(p_uttt, p_move) == YES) {
|
||||||
// we can process things
|
// we can process things
|
||||||
if ( p_uttt->inception_level == 1 ) {
|
|
||||||
p_uttt->outer_tictactoe->content[p_move->outer_position] = p_move->player;
|
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 {
|
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;
|
return YES;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue