X-Git-Url: https://plomlompom.com/repos/?a=blobdiff_plain;f=server.py;h=e8bca6abf402cb0ea9bef2d175c2f12d454dda7b;hb=0aaa22e9e7c123fb0eda849136c5b69659ba7abc;hp=215317dd6714cfdd97c59b3f980781414e5b269e;hpb=9a83921c91a36e7dcb53ee1ea20605cdb6127c26;p=plomrogue2-experiments diff --git a/server.py b/server.py index 215317d..e8bca6a 100755 --- a/server.py +++ b/server.py @@ -90,7 +90,8 @@ class Task: class Thing: - def __init__(self, position): + def __init__(self, type_, position): + self.type = type_ self.position = position self.task = Task('wait') @@ -135,7 +136,7 @@ class World: 'x.X.x\n'+\ 'x...x\n'+\ 'xxxxx' - self.things = [Thing(position=[3, 3]), Thing([1, 1])] + self.things = [Thing('human', [3, 3]), Thing('monster', [1, 1])] self.player_i = 0 self.player = self.things[self.player_i] @@ -201,7 +202,9 @@ class CommandHandler: self.send_all('NEW_TURN ' + str(self.world.turn)) self.send_all('MAP_SIZE ' + self.stringify_yx(self.world.map_size)) self.send_all('TERRAIN\n' + self.world.map_) - self.send_all('POSITION ' + self.stringify_yx(self.world.player.position)) + for thing in self.world.things: + self.send_all('THING TYPE:' + thing.type + ' ' + + self.stringify_yx(thing.position)) def cmd_fib(self, tokens, connection_id): """Reply with n-th Fibonacci numbers, n taken from tokens[1:]. @@ -244,7 +247,9 @@ class CommandHandler: self.send_all('NEW_TURN ' + str(self.world.turn)) self.send_all('MAP_SIZE ' + self.stringify_yx(self.world.map_size)) self.send_all('TERRAIN\n' + self.world.map_) - self.send_all('POSITION ' + self.stringify_yx(self.world.player.position)) + for thing in self.world.things: + self.send_all('THING TYPE:' + thing.type + ' ' + + self.stringify_yx(thing.position)) self.pool_result = self.pool.map_async(fib, (35, 35)) def cmd_get_turn(self, connection_id):