Skip to content

Commit

Permalink
Merge branch 'master' of github.com:jonastheis/das
Browse files Browse the repository at this point in the history
  • Loading branch information
kianenigma committed Dec 5, 2017
2 parents 2ce422a + e58c257 commit a892e18
Show file tree
Hide file tree
Showing 5 changed files with 11 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,11 +85,11 @@ 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:
arguments.extend(['--users', 'test/das_map.json'])
arguments.extend(['--users', 'test/das_hell.json'])

print("Starting Server {} with {}".format(id, arguments))

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
1 change: 1 addition & 0 deletions test/das_hell.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,6 @@
{"type": "d", "r": 18, "c": 3},
{"type": "d", "r": 16, "c": 7},
{"type": "d", "r": 24, "c": 19},
{"type": "d", "r": 13, "c": 9},
{"type": "d", "r": 20, "c": 2}
]

0 comments on commit a892e18

Please sign in to comment.