Skip to content

Commit

Permalink
Minor bugfixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jonastheis committed Dec 5, 2017
1 parent 1559a39 commit e58c257
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 6 deletions.
2 changes: 1 addition & 1 deletion common/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
3 changes: 1 addition & 2 deletions server/network/base_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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".
Expand All @@ -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):
Expand Down
2 changes: 2 additions & 0 deletions server/network/udp_server.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
9 changes: 6 additions & 3 deletions test/console_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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():
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit e58c257

Please sign in to comment.