@@ -31,44 +31,51 @@ bool handle_place(int client_fd, char* client_str) {
31
31
bool handle_read_board (int client_fd , char * client_str ) {
32
32
for (int x = 0 ; x < __BOARD_SIZE__ ; x ++ ) {
33
33
for (int y = 0 ; y < __BOARD_SIZE__ ; y ++ ) {
34
- //send the info at each location
34
+ //send the info at each location to client
35
35
}
36
36
}
37
37
38
38
return 0 ;
39
39
}
40
40
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
+
41
60
bool handle_get_winner (int client_fd ) {
42
61
//implement a more effecient check if needed
43
62
44
63
enum Player winner = E ;
45
64
46
65
for (int i = 0 ; i < __BOARD_SIZE__ ; i ++ ) {
47
66
//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 ]))
52
68
winner = board [i ][0 ];
53
69
54
70
// 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 ]))
59
72
winner = board [0 ][i ];
60
73
}
61
74
// 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 ]))
66
76
winner = board [0 ][0 ];
67
77
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 ]))
72
79
winner = board [2 ][0 ];
73
80
74
81
//send winner to db stub code
0 commit comments