From 0816eaae24c96593a75023b691c8a8fb8b3208ee Mon Sep 17 00:00:00 2001 From: Odweta Date: Tue, 17 Feb 2026 17:15:08 +0100 Subject: [PATCH] results announce --- src/chess.c | 34 +++++++++++++++++++++++++++++++--- src/chess.h | 2 +- src/main.c | 2 +- 3 files changed, 33 insertions(+), 5 deletions(-) diff --git a/src/chess.c b/src/chess.c index 19b3a64..01d35fd 100644 --- a/src/chess.c +++ b/src/chess.c @@ -71,8 +71,36 @@ bool get_move(move_t *move) { return is_move_in_bounds(*move); } -bool perform_move(player_e player, 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 +end_condition_e check_edge_cases(board_t board) { + +} + +void announce_results(end_condition_e end_condition, player_e player) { + printf("The game has ended because of a "); + + switch (end_condition) { + case CHECKMATE: + printf("CHECKMATE"); + break; + case STALEMATE: + printf("STALEMATE"); + break; + } + + printf("\nand the player who has won is"); + + switch (player) { + case WHITE: + printf(" WHITE"); + break; + case BLACK: + printf(" BLACK"); + break; + } + + printf("! Congratulations.\n"); +} \ No newline at end of file diff --git a/src/chess.h b/src/chess.h index 8c991e8..f8de0b0 100644 --- a/src/chess.h +++ b/src/chess.h @@ -81,7 +81,7 @@ bool perform_move(player_e player, move_t move); 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); +void announce_results(end_condition_e end_condition, player_e player); // shows a guide to help players understand the move prompt system void show_help(); diff --git a/src/main.c b/src/main.c index 7a8c311..50f696f 100644 --- a/src/main.c +++ b/src/main.c @@ -45,7 +45,7 @@ int main() { } } - announce_results(player); + announce_results(end_condition, player); return EXIT_SUCCESS; } \ No newline at end of file