diff --git a/src/chess.c b/src/chess.c index 573f838..e68d209 100644 --- a/src/chess.c +++ b/src/chess.c @@ -1,5 +1,31 @@ #include "chess.h" +#include "util.h" bool init_board(board_t *board) { -} \ No newline at end of file +} + +void select_player(player_e *player, unsigned int round_count) { + if (round_count == 1) { + *player = WHITE; + return; + } + + if (*player == WHITE) { + *player = BLACK; + return; + } + + if (*player == BLACK) { + *player = WHITE; + return; + } +} + +bool get_move(move_t *move); + +bool perform_move(player_e player, move_t move); + +end_condition_e check_edge_cases(board_t board); + +void announce_results(player_e player); \ No newline at end of file diff --git a/src/chess.h b/src/chess.h index 046ec17..4ee5157 100644 --- a/src/chess.h +++ b/src/chess.h @@ -67,4 +67,21 @@ typedef enum { // initializes the board with the default configuration of pieces bool init_board(board_t *board); +// selects the player to currently play +// if it is the first round, it selects white +void select_player(player_e *player, unsigned int round_count); + +// listens for a command to make a move by the currently playing player +bool get_move(move_t *move); + +// performs the move if is it possible +bool perform_move(player_e player, move_t move); + +// checks for captures, prommotions and mates +end_condition_e check_edge_cases(board_t board); + +// if there is one of the mates, end the game and show who has won +void announce_results(player_e player); + + #endif // CHESS_H \ No newline at end of file diff --git a/src/main.c b/src/main.c index cccb8e4..6bc615f 100644 --- a/src/main.c +++ b/src/main.c @@ -20,6 +20,7 @@ int main() { board_t board; move_t move; player_e player; + unsigned int round_count = 0; end_condition_e end_condition; bool running = true; @@ -28,8 +29,9 @@ int main() { init_board(&board); while (running) { + round_count++; - select_player(&player); + select_player(&player, round_count); get_move(&move);