X-Git-Url: https://git.piment-noir.org/?p=Project_algorithmic_C.git;a=blobdiff_plain;f=src%2Fmain.c;h=4f5e61da73ac243a7b194b937f9ccb08ec3d4e5d;hp=195bdbe1ef51644bf83d737bb6d42c148cadcfa3;hb=54f1c58cef6764fdd611eedc267e7491e777c09b;hpb=74e2b93b658575fa792ada51c3bf1cdc3cfde247 diff --git a/src/main.c b/src/main.c index 195bdbe..4f5e61d 100644 --- a/src/main.c +++ b/src/main.c @@ -5,6 +5,7 @@ #include "ui.h" #include "othello.h" +#include "debug.h" int main() { int row = 0, col = 0; @@ -13,6 +14,8 @@ int main() { bool exit_condition = false; unsigned int nb_white = 0, nb_black = 0; + LIST_HEAD(shots_list); + char* player_msg; unsigned int pawns[board_size][board_size] = {{}}; @@ -26,6 +29,7 @@ int main() { } start_color(); getmaxyx(stdscr, row, col); + /* FIXME: fail if the screen size is too small */ //noecho(); echo(); curs_set(0); @@ -41,7 +45,7 @@ int main() { print_board(board_center_y, board_center_x); print_pawns(board_center_y, board_center_x, pawns); - char* title_msg = "Jeu othello"; + char* title_msg = "Jeu Othello"; mvprintw(center_y - 26/2 - 4, (center_x - strlen(title_msg)/2), title_msg); nb_white = count_pawn_type(pawns, white); @@ -67,21 +71,26 @@ int main() { do { y = 0; x = ""; - char* prompt_msg = "Prochain pion ? - ligne colonne (chiffre lettre):"; - prompt_values(stdscr, center_y + 26/2 + 1, center_x - strlen(prompt_msg)/2, prompt_msg, &y, &x); - /* FIXME: separate the tests to permit to print explicit error messages */ - if (((y > 0 && y < board_size + 1) || \ - (map_col_letter_to_int(x) > 0 && map_col_letter_to_int(x) < board_size + 1)) \ - && is_box_type(y, x, pawns, empty)) { + 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); + if (is_valid_input(y, map_col_letter_to_int(x), pawns) && prmt_rt == 1) { input_ok = true; } } while (!input_ok); pawns[board_size][board_size] = set_pawn(y, map_col_letter_to_int(x), player, pawns); + struct shots_list shot_current; + shot_current.pawn_array_member = &pawns[y-1][x-1]; + //list_add(shot_current.list, shots_list.list); round++; /* increment the round count */ refresh(); + if (is_board_full(pawns) || round == 60) { + /* print the winnner and the restart possibility */ + exit_condition = true; + } + } while (!exit_condition); endwin();