12 unsigned int round
= 0;
13 unsigned int player
= player_one
; /* first player is black */
14 bool exit_condition
= false;
15 unsigned int nb_white
= 0, nb_black
= 0;
17 LIST_HEAD(shots_list
);
21 unsigned int pawns
[board_size
][board_size
] = {{}};
22 pawns
[board_size
][board_size
] = init_pawns(pawns
);
25 if (has_colors() == false) {
27 printf("Votre terminal ne supporte pas les couleurs\n");
31 getmaxyx(stdscr
, row
, col
);
32 /* FIXME: fail if the screen size is too small */
40 /* base coordinates to center the board */
41 int board_center_y
= center_y
- 26/2;
42 int board_center_x
= center_x
- 42/2;
45 print_board(board_center_y
, board_center_x
);
46 print_pawns(board_center_y
, board_center_x
, pawns
);
48 char* title_msg
= "Jeu Othello";
49 mvprintw(center_y
- 26/2 - 4, (center_x
- strlen(title_msg
)/2), title_msg
);
51 nb_white
= count_pawn_type(pawns
, white
);
52 nb_black
= count_pawn_type(pawns
, black
);
54 char* score_white_msg
= "Pions blancs: %d";
55 mvprintw(center_y
, center_x
- 42/2 - strlen(score_white_msg
) - 2, score_white_msg
, nb_white
);
56 char* score_black_msg
= "Pions noirs: %d";
57 mvprintw(center_y
, center_x
+ 42/2 + 2, score_black_msg
, nb_black
);
59 player
= current_player(round
);
61 if (player
== player_one
) {
62 player_msg
= "Joueur un (noir) joue !";
64 player_msg
= "Joueur deux (blanc) joue !";
66 mvprintw(center_y
- 26/2 - 2, (center_x
- strlen(player_msg
)/2), player_msg
);
70 bool input_ok
= false;
74 char* prompt_msg
= "Prochain pion ? (ligne colonne - chiffre lettre):";
75 int prmt_rt
= prompt_values(stdscr
, center_y
+ 26/2 + 1, center_x
- strlen(prompt_msg
)/2, prompt_msg
, &y
, &x
);
76 if (is_valid_input(y
, map_col_letter_to_int(x
), pawns
) && prmt_rt
== 1) {
80 pawns
[board_size
][board_size
] = set_pawn(y
, map_col_letter_to_int(x
), player
, pawns
);
81 struct shots_list shot_current
;
82 shot_current
.pawn_array_member
= &pawns
[y
-1][x
-1];
83 //list_add(shot_current.list, shots_list.list);
85 round
++; /* increment the round count */
89 if (is_board_full(pawns
) || round
== 60) {
90 /* print the winnner and the restart possibility */
91 exit_condition
= true;
94 } while (!exit_condition
);