Skip to content

Commit 9330d0c

Browse files
committed
fixes
1 parent d50df35 commit 9330d0c

File tree

3 files changed

+12
-11
lines changed

3 files changed

+12
-11
lines changed

client.py

+9-8
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818
"handle_read_board":8,
1919
"handle_get_winner":9,
2020
"handle_add_winner":10,
21-
"handle_set_intro":11,
22-
"handle_set_outro":12,
23-
"handle_report_winners":13,
21+
"handle_reset_winner_data":11,
22+
"handle_set_outro_message":12,
23+
"handle_report_winners":13
2424
}
2525

2626
def client_error_wrapper(error_msg):
@@ -81,16 +81,17 @@ def place(self, turn):
8181

8282
#expects a response that is a 9 byte string representing the board
8383
def read_board(self):
84-
self.server_conn.sendall(int.to_bytes(handlers["handle_get_winner"], 4, NET_ORDER))
84+
self.server_conn.sendall(int.to_bytes(8, 4, NET_ORDER))
8585
response = self.read_response()
86+
print(response)
8687

87-
#print the board
88+
#print the board //TODO convert ascii code from stuff
8889
print(' 0 1 2')
89-
print('0 %s | %s | %s', response[0], response[1], response[2])
90+
print(f'0 {response[0]} | {response[1]} | {response[2]}')
9091
print(' ----------------')
91-
print('1 %s | %s | %s', response[4], response[5], response[6])
92+
print(f'1 {response[3]} | {response[4]} | {response[5]}')
9293
print(' ----------------')
93-
print('2 %s | %s | %s', response[7], response[8], response[9])
94+
print(f'2 {response[6]} | {response[7]} | {response[8]}')
9495

9596
#expects 4 bytes repr. winner, 0 = no one, 1 = X, 2 = O
9697
def get_winner(self):

game_dispatcher.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ void handle_client(int client_fd, char* client_str) {
7171
pkt_type = ntohl(pkt_type);
7272

7373
// handle packet type
74-
printf("dispatching\n");
74+
printf("dispatching %d\n", pkt_type);
7575
bool dispatch_status = handlers[pkt_type](client_fd, client_str);
7676
printf("dispatch_status: %d\n", dispatch_status);
7777
}

tictactoe.c

+2-2
Original file line numberDiff line numberDiff line change
@@ -46,11 +46,11 @@ bool handle_place(int client_fd, char* client_str) {
4646

4747
// sends the board as a 9-byte char*
4848
bool handle_read_board(int client_fd, char* client_str) {
49-
char board_pkt[9];
49+
char board_pkt[10] = {0};
5050
int i = 0;
5151
for (int x = 0; x < __BOARD_SIZE__; x++) {
5252
for (int y = 0; y < __BOARD_SIZE__; y++) {
53-
char player = 'X' ? board[x][y] == X : 'O' ? board[x][y] == O : 'E';
53+
char player = board[x][y] == X ? 'X' : board[x][y] == O ? 'O': 'E';
5454
board_pkt[i] = player;
5555
i++;
5656
}

0 commit comments

Comments
 (0)