Browse Source

moved creation of the socket into main function

feature/balanceutils
informaniac 7 years ago
parent
commit
1e974a74d6
  1. 16
      games/ttrs.py

16
games/ttrs.py

@ -243,13 +243,7 @@ class BalanceTtrsPlayer(TtrsPlayer, threading.Thread): @@ -243,13 +243,7 @@ class BalanceTtrsPlayer(TtrsPlayer, threading.Thread):
self.start()
def run(self):
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
try:
sock.connect(self.addr)
except ConnectionRefusedError:
print('could not connect to balance server', file=sys.stderr)
self.evt = PlayerEvent.QUIT
return
self.running = True
evt = None
oldevt = None
@ -481,6 +475,14 @@ if __name__ == '__main__': @@ -481,6 +475,14 @@ if __name__ == '__main__':
seed = random.random()
games = []
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
host, port = args.balance.split(':')
try:
sock.connect(host, port)
except ConnectionRefusedError:
print('could not connect to balance server', file=sys.stderr)
sys.exit(1)
def start_game(player_id, xpos):
pg = Playground(10, 16)
if args.pygame:

Loading…
Cancel
Save