11 int min_y
= 26, min_x
= 42;
13 unsigned int round
= 0;
14 unsigned int player
= player_one
; /* first player is black */
15 bool exit_condition
= false;
16 unsigned int nb_white
= 0, nb_black
= 0;
18 LIST_HEAD(shots_list
);
20 char* title_msg
= "Jeu Othello";
21 char* score_white_msg
= "Pions blancs: %d";
22 char* score_black_msg
= "Pions noirs: %d";
23 char* player_msg
= "Joueur %d joue !";
24 char* winner_msg
= "Joueur %d gagne !";
25 char* draw_msg
= "Egalite !";
27 unsigned int pawns
[board_size
][board_size
] = {{}};
28 pawns
[board_size
][board_size
] = init_pawns(pawns
);
31 if (has_colors() == false) {
33 printf("Votre terminal ne supporte pas les couleurs\n");
37 getmaxyx(stdscr
, row
, col
);
38 /* FIXME: fail if the screen size is too small */
45 /* base coordinates to center the board */
46 int board_center_y
= center_y
- 26/2;
47 int board_center_x
= center_x
- 42/2;
50 print_board(board_center_y
, board_center_x
);
51 print_pawns(board_center_y
, board_center_x
, pawns
);
53 mvprintw(center_y
- 26/2 - 4, (center_x
- strlen(title_msg
)/2), title_msg
);
55 player
= current_player(round
);
57 mvprintw(center_y
- 26/2 - 2, (center_x
- strlen(player_msg
)/2), player_msg
, player
);
59 nb_white
= count_pawn_type(pawns
, white
);
60 nb_black
= count_pawn_type(pawns
, black
);
62 mvprintw(center_y
, center_x
- 42/2 - strlen(score_white_msg
) - 2, score_white_msg
, nb_white
);
63 mvprintw(center_y
, center_x
+ 42/2 + 2, score_black_msg
, nb_black
);
67 bool input_ok
= false;
71 char* prompt_msg
= "Prochain pion ? (ligne colonne - chiffre lettre):";
72 int prmt_rt
= prompt_values(stdscr
, center_y
+ 26/2 + 1, center_x
- strlen(prompt_msg
)/2, prompt_msg
, &y
, &x
);
73 if (is_valid_input(y
, map_col_letter_to_int(x
), pawns
) && prmt_rt
== 1) {
77 pawns
[board_size
][board_size
] = set_pawn(y
, map_col_letter_to_int(x
), player
, pawns
);
78 struct shots_list shot_current
;
79 shot_current
.pawn_array_member
= &pawns
[y
-1][x
-1];
80 //list_add(shot_current.list, shots_list.list);
82 round
++; /* increment the round count */
86 /* here are all the end of the game conditions */
87 //if (is_board_full(pawns) || round == 60) {
88 if (is_board_full(pawns
)) {
89 int winner
= eval_winner(nb_white
, nb_black
);
91 mvprintw(center_y
- 26/2 - 2, (center_x
- strlen(winner_msg
)/2), winner_msg
, winner
);
93 mvprintw(center_y
- 26/2 - 2, (center_x
- strlen(draw_msg
)/2), draw_msg
);
95 /* print and implement restart possibility */
96 exit_condition
= true;
99 } while (!exit_condition
);