#include "ui.h"
#include "othello.h"
+#include "debug.h"
int main() {
int row = 0, col = 0;
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] = {{}};
}
start_color();
getmaxyx(stdscr, row, col);
+ /* FIXME: fail if the screen size is too small */
//noecho();
echo();
curs_set(0);
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);
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();