Skip to content

Commit d90c7f3

Browse files
committed
added high score logic
1 parent a2dedca commit d90c7f3

File tree

4 files changed

+5
-3
lines changed

4 files changed

+5
-3
lines changed

game_dispatcher.c

+1
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ pkt_handler handlers[] = {
3232

3333
/* high scores */
3434
handle_add_winner,
35+
handle_reset_winner_data,
3536
handle_set_outro_message,
3637
handle_report_winners,
3738
};

high_score.c

+2-1
Original file line numberDiff line numberDiff line change
@@ -16,11 +16,12 @@
1616
char winners_list[MAX_BUF_SIZE] = {0};
1717
char outro_message[MAX_BUF_SIZE] = {0};
1818

19-
void reset_winner_data()
19+
bool handle_reset_winner_data(int client_fd, char* client_str)
2020
{
2121
memset(winners_list, sizeof(winners_list), 0);
2222
memset(outro_message, sizeof(outro_message), 0);
2323
strcpy(outro_message, "\nBetter Luck to our other participants next time!\n" );
24+
return true;
2425
}
2526

2627
bool handle_add_winner(int client_fd, char* client_str) {

high_score.h

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#include <stdbool.h>
55
#include "tictactoe.h"
66

7-
void reset_winner_data();
7+
bool handle_reset_winner_data(int client_fd, char* client_str);
88

99
bool handle_add_winner(int client_fd, char* client_str); // Collect information about the winner from the user
1010
bool handle_set_outro_message(int client_fd, char* client_str);

main_game_server.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616

1717
int main (int argc, char *argv[]) {
1818
uses_assumed_sizes();
19-
reset_winner_data();
19+
handle_reset_winner_data(0, NULL);
2020
set_random_admin_password();
2121

2222
int server_fd, client_fd, err;

0 commit comments

Comments
 (0)