class World:
turn = 0
+ map_ = 'xxxxx\nx...x\nx.X.x\nx...x\nxxxxx'
+ player_pos = (3, 3)
def fib(n):
self.send_to(connection_id, reply)
def cmd_inc(self, connection_id):
- """Increment world.turn, send TURN_FINISHED, NEW_TURN to everyone.
+ """Increment world.turn, send game turn data to everyone.
To simulate game processing waiting times, a one second delay between
TURN_FINISHED and NEW_TURN occurs; after NEW_TURN, some expensive
sleep(1)
self.world.turn += 1
self.send_all('NEW_TURN ' + str(self.world.turn))
- self.pool_result = self.pool.map_async(fib, (35,35))
+ self.send_all('TERRAIN\n' + self.world.map_)
+ self.send_all('POSITION_Y ' + str(self.world.player_pos[0]))
+ self.send_all('POSITION_X ' + str(self.world.player_pos[1]))
+ self.pool_result = self.pool.map_async(fib, (35, 35))
def cmd_get_turn(self, connection_id):
"""Send world.turn to caller."""