X-Git-Url: https://git.piment-noir.org/?p=Project_algorithmic_C.git;a=blobdiff_plain;f=src%2Fmain.c;fp=src%2Fmain.c;h=3ed7991b2229685cdc40c975a1937b38f3709f32;hp=a86a7efd94f125123d6aca435bfb62fdde7599b8;hb=3243371edb8b286cf832c512e63f302dad6e1de2;hpb=9240af1ae3159c7ba2f1ff1152089efd7fa5e38e diff --git a/src/main.c b/src/main.c index a86a7ef..3ed7991 100644 --- a/src/main.c +++ b/src/main.c @@ -79,7 +79,6 @@ int main() { build_playable_shots_list(player, &playable_shots, pawns); print_shots_list(board_center_y, board_center_x, &playable_shots); - free_shots_list(&playable_shots); display_array(1, 1, pawns); @@ -93,8 +92,9 @@ int main() { const char* prompt_msg = "Prochain pion ? (ligne colonne - chiffre lettre):"; int prmt_rt = prompt_values(stdscr, center_y + 26/2 + 1, (center_x - strlen(prompt_msg)/2), prompt_msg, &y, &x_char); int x = map_col_letter_to_index(x_char); - nb_pawns_reversed = valid_shot(y, x, player, pawns); - if (nb_pawns_reversed > 0 && prmt_rt == 1) { + /* TODO: a comparaison to the linked list of playable shots is better */ + if (is_legal_shot(y, x, player, pawns) && prmt_rt == 1) { + nb_pawns_reversed = valid_shot(y, x, player, pawns); input_ok = true; clear(); } else { @@ -102,6 +102,8 @@ int main() { } } while (!input_ok); + free_shots_list(&playable_shots); + round++; /* increment the round count */ /* here are all the end of the game conditions */