@@ -76,7 +76,7 @@ def place(self, turn):
76
76
if turn == 'O' :
77
77
turn_enum = 2
78
78
packet = int .to_bytes (turn_enum , 4 , NET_ORDER ) + user_coords [0 ].encode ("utf-8" ) + user_coords [1 ].encode ("utf-8" )
79
- self .server_conn .sendall (int .to_bytes (handlers [ "handle_get_winner" ] , 4 , NET_ORDER ))
79
+ self .server_conn .sendall (int .to_bytes (7 , 4 , NET_ORDER ))
80
80
self .server_conn .sendall (packet ) #send which player, and coordinates
81
81
82
82
#expects a response that is a 9 byte string representing the board
@@ -88,14 +88,14 @@ def read_board(self):
88
88
#print the board //TODO convert ascii code from stuff
89
89
print (' 0 1 2' )
90
90
print (f'0 { response [0 ]} | { response [1 ]} | { response [2 ]} ' )
91
- print (' -- --------------' )
91
+ print (' --------------' )
92
92
print (f'1 { response [3 ]} | { response [4 ]} | { response [5 ]} ' )
93
- print (' -- --------------' )
93
+ print (' --------------' )
94
94
print (f'2 { response [6 ]} | { response [7 ]} | { response [8 ]} ' )
95
95
96
96
#expects 4 bytes repr. winner, 0 = no one, 1 = X, 2 = O
97
97
def get_winner (self ):
98
- self .server_conn .sendall (int .to_bytes (handlers [ "handle_get_winner" ] , 4 , NET_ORDER ))
98
+ self .server_conn .sendall (int .to_bytes (9 , 4 , NET_ORDER ))
99
99
response = self .read_response ()
100
100
return int .from_bytes (response , NET_ORDER )
101
101
@@ -112,7 +112,7 @@ def play(connect_tuple):
112
112
time .sleep (1 )
113
113
#gameplay
114
114
turn = 'X'
115
- while game .get_winner == 0 :
115
+ while game .get_winner () == 0 :
116
116
print ('Player %s\' s' )
117
117
game .place (game , turn )
118
118
print ('Good move. I think...' )
@@ -121,8 +121,8 @@ def play(connect_tuple):
121
121
turn = turn == 'X' if turn == 'Y' else 'Y'
122
122
123
123
#game ended
124
- name = names [ random ( 0 , len ( names ))] # fingers crossed
125
- print ('CONGRATS %s YOU WIN!' , name )
124
+ name = random . choice ( names ) # fingers crossed
125
+ print ('CONGRATS %s YOU WIN!' % name )
126
126
127
127
128
128
def main ():
0 commit comments