Skip to content

Commit 76c4d36

Browse files
authored
Update random_client.py
1 parent 96c7b4d commit 76c4d36

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

random_client.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,6 @@
55
for the Hex board game.
66
"""
77

8-
98
import asyncio
109
import sys
1110
import hexgui
@@ -32,6 +31,8 @@ def game_client(loop, state):
3231
print("Connected to the game server")
3332
sys.stdout.flush()
3433
state[0] = INIT_STATE
34+
player=2
35+
init=0
3536
while state[0] not in (END_STATE, CONNECTION_REFUSED):
3637
if state[0] == INIT_STATE:
3738
data = yield from reader.readline()
@@ -53,6 +54,9 @@ def game_client(loop, state):
5354
hexboard = hexgame.Hex.create_from_str(message[5:])
5455
hexgui.redraw(hexboard)
5556
hexgui.set_title("hexgui.Hex game - your turn")
57+
if init==0 and "1" not in message:
58+
player=1
59+
init=1
5660
print(message)
5761
if message.startswith("End"):
5862
state[0] = END_STATE
@@ -86,6 +90,7 @@ def game_client(loop, state):
8690
state[0] = PLAYING
8791
sys.stdout.flush()
8892
if state[0] == END_STATE:
93+
print("Joueur :"+str(player))
8994
print("{} wins the game".format(hexgui.player_names[hexboard.winner]))
9095
writer.close()
9196

0 commit comments

Comments
 (0)