11 unsigned int round
= 0;
12 unsigned int player
= player_one
; /* first player is black */
13 bool exit_condition
= false;
14 unsigned int nb_white
= 0, nb_black
= 0;
18 unsigned int pawns
[board_size
][board_size
] = {{}};
19 pawns
[board_size
][board_size
] = init_pawns(pawns
);
22 if (has_colors() == false) {
24 printf("Votre terminal ne supporte pas les couleurs\n");
28 getmaxyx(stdscr
, row
, col
);
36 /* base coordinates to center the board */
37 int board_center_y
= center_y
- 26/2;
38 int board_center_x
= center_x
- 42/2;
41 print_board(board_center_y
, board_center_x
);
42 print_pawns(board_center_y
, board_center_x
, pawns
);
44 char* title_msg
= "Jeu othello";
45 mvprintw(center_y
- 26/2 - 4, (center_x
- strlen(title_msg
)/2), title_msg
);
47 nb_white
= count_pawn_type(pawns
, white
);
48 nb_black
= count_pawn_type(pawns
, black
);
50 char* score_white_msg
= "Pions blancs: %d";
51 mvprintw(center_y
, center_x
- 42/2 - strlen(score_white_msg
) - 2, score_white_msg
, nb_white
);
52 char* score_black_msg
= "Pions noirs: %d";
53 mvprintw(center_y
, center_x
+ 42/2 + 2, score_black_msg
, nb_black
);
55 player
= current_player(round
);
57 if (player
== player_one
) {
58 player_msg
= "Joueur un (noir) joue !";
60 player_msg
= "Joueur deux (blanc) joue !";
62 mvprintw(center_y
- 26/2 - 2, (center_x
- strlen(player_msg
)/2), player_msg
);
66 bool input_ok
= false;
70 char* prompt_msg
= "Prochain pion ? - ligne colonne (chiffre lettre):";
71 prompt_values(stdscr
, center_y
+ 26/2 + 1, center_x
- strlen(prompt_msg
)/2, prompt_msg
, &y
, &x
);
72 /* FIXME: separate the tests to permit to print explicit error messages */
73 if (((y
> 0 && y
< board_size
+ 1) || \
74 (map_col_letter_to_int(x
) > 0 && map_col_letter_to_int(x
) < board_size
+ 1)) \
75 && is_box_type(y
, x
, pawns
, empty
)) {
79 pawns
[board_size
][board_size
] = set_pawn(y
, map_col_letter_to_int(x
), player
, pawns
);
81 round
++; /* increment the round count */
85 } while (!exit_condition
);