Skip to content

Commit 70a5d3f

Browse files
committed
minor
1 parent 8ad511c commit 70a5d3f

File tree

2 files changed

+24
-17
lines changed

2 files changed

+24
-17
lines changed

server

0 Bytes
Binary file not shown.

tictactoe.c

Lines changed: 24 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,44 +31,51 @@ bool handle_place(int client_fd, char* client_str) {
3131
bool handle_read_board(int client_fd, char* client_str) {
3232
for (int x = 0; x < __BOARD_SIZE__; x++) {
3333
for (int y = 0; y < __BOARD_SIZE__; y++) {
34-
//send the info at each location
34+
//send the info at each location to client
3535
}
3636
}
3737

3838
return 0;
3939
}
4040

41+
//commented function sends the board as a 36-byte (9 ints) char*
42+
// bool handle_read_board(int client_fd, char* client_str) {
43+
// char board_pkt[9];
44+
// int i = 0;
45+
// for (int x = 0; x < __BOARD_SIZE__; x++) {
46+
// for (int y = 0; y < __BOARD_SIZE__; y++) {
47+
// board_pkt[i] = board[x][y];
48+
// i++;
49+
// }
50+
// }
51+
52+
// //send the board_pkt string to client
53+
54+
// return 0;
55+
// }
56+
57+
58+
59+
4160
bool handle_get_winner(int client_fd) {
4261
//implement a more effecient check if needed
4362

4463
enum Player winner = E;
4564

4665
for (int i = 0; i < __BOARD_SIZE__; i++) {
4766
//check vertical lines
48-
if ((board[i][0] != E) &&
49-
(board[i][0] == board[i][1]) &&
50-
(board[i][0] == board[i][2]))
51-
67+
if ((board[i][0] != E) && (board[i][0] == board[i][1]) && (board[i][0] == board[i][2]))
5268
winner = board[i][0];
5369

5470
// check horizontal lines
55-
if ((board[0][i] != E) &&
56-
(board[0][i] == board[1][i]) &&
57-
(board[0][i] == board[2][i]))
58-
71+
if ((board[0][i] != E) && (board[0][i] == board[1][i]) && (board[0][i] == board[2][i]))
5972
winner = board[0][i];
6073
}
6174
// check diagonals
62-
if ((board[0][0] != E) &&
63-
(board[0][0] == board[1][1]) &&
64-
(board[0][0] == board[2][2]))
65-
75+
if ((board[0][0] != E) && (board[0][0] == board[1][1]) && (board[0][0] == board[2][2]))
6676
winner = board[0][0];
6777

68-
if ((board[2][0] != E) &&
69-
(board[2][0] == board[1][1]) &&
70-
(board[0][0] == board[0][2]))
71-
78+
if ((board[2][0] != E) && (board[2][0] == board[1][1]) && (board[0][0] == board[0][2]))
7279
winner = board[2][0];
7380

7481
//send winner to db stub code

0 commit comments

Comments
 (0)