diff --git a/common/user.py b/common/user.py index c278e73..fdf3160 100644 --- a/common/user.py +++ b/common/user.py @@ -9,7 +9,7 @@ def __init__(self, type, id="NOT_DEFINED"): # self.hp = random.randint(50, 100) self.hp = 50 # self.ap = random.randint(5, 20) - self.ap = 1 + self.ap = 10 elif type == USERS.PLAYER: # self.hp = random.randint(10, 20) diff --git a/server/network/base_server.py b/server/network/base_server.py index efeed4a..f45e8a4 100644 --- a/server/network/base_server.py +++ b/server/network/base_server.py @@ -38,7 +38,6 @@ def _listen(self): def on_connection(self, connection, address): pass - def broadcast(self, data, without=None, type=None): """ Broadcast the data to all connections except "without". @@ -49,7 +48,7 @@ def broadcast(self, data, without=None, type=None): if client_id != without: try: self.connections[client_id].send(data, type) - except BaseException as e: + except: logger.error("Failed sending message to {} : data {}".format(self.connections[client_id], data)) def remove_connection(self, id): diff --git a/server/network/udp_server.py b/server/network/udp_server.py index 97597ad..92ae524 100644 --- a/server/network/udp_server.py +++ b/server/network/udp_server.py @@ -52,6 +52,8 @@ def on_message(self, data, address): :param address: the udp address from where the received message was sent """ if data['type'] == MSG_TYPE.PING: + if self.delay <= 0: + self.delay = 0 time.sleep(self.delay) send_udp_message(self.socket, address, MSG_TYPE.PING) else: diff --git a/test/console_control.py b/test/console_control.py index 6705706..e2d32db 100644 --- a/test/console_control.py +++ b/test/console_control.py @@ -85,7 +85,7 @@ def start(id, master_node=False): port = id * 10000 arguments = ['python3.6', '-m', 'server.app', - '--config', 'test/das_config_console_control.json', + '--config', 'test/das_config.json', '--log-prefix', str(id), '--port', str(port)] if master_node: @@ -118,7 +118,7 @@ def handle(text): def create(count): for i in range(1, count+1): Client.start(i) - time.sleep(0.1) + time.sleep(0.5) @staticmethod def status(): @@ -146,7 +146,10 @@ def kill(id): client = clients[id] if client is None: return - client.kill() + try: + client.kill() + except: + pass clients[id] = None @staticmethod