@@ -76,7 +76,7 @@ def place(self, turn):
7676 if turn == 'O' :
7777 turn_enum = 2
7878 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 ))
8080 self .server_conn .sendall (packet ) #send which player, and coordinates
8181
8282 #expects a response that is a 9 byte string representing the board
@@ -88,14 +88,14 @@ def read_board(self):
8888 #print the board //TODO convert ascii code from stuff
8989 print (' 0 1 2' )
9090 print (f'0 { response [0 ]} | { response [1 ]} | { response [2 ]} ' )
91- print (' -- --------------' )
91+ print (' --------------' )
9292 print (f'1 { response [3 ]} | { response [4 ]} | { response [5 ]} ' )
93- print (' -- --------------' )
93+ print (' --------------' )
9494 print (f'2 { response [6 ]} | { response [7 ]} | { response [8 ]} ' )
9595
9696 #expects 4 bytes repr. winner, 0 = no one, 1 = X, 2 = O
9797 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 ))
9999 response = self .read_response ()
100100 return int .from_bytes (response , NET_ORDER )
101101
@@ -112,7 +112,7 @@ def play(connect_tuple):
112112 time .sleep (1 )
113113 #gameplay
114114 turn = 'X'
115- while game .get_winner == 0 :
115+ while game .get_winner () == 0 :
116116 print ('Player %s\' s' )
117117 game .place (game , turn )
118118 print ('Good move. I think...' )
@@ -121,8 +121,8 @@ def play(connect_tuple):
121121 turn = turn == 'X' if turn == 'Y' else 'Y'
122122
123123 #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 )
126126
127127
128128def main ():
0 commit comments