print("FILE INPUT LINE %s: %s" % (i, line), end='')
game.io.handle_input(line, store=False)
else:
- game.io.handle_input('MAP Hex Y:5,X:5')
- game.io.handle_input('TERRAIN_LINE 0 "xxxxx"')
- game.io.handle_input('TERRAIN_LINE 1 "x...x"')
- game.io.handle_input('TERRAIN_LINE 2 "x.X.x"')
- game.io.handle_input('TERRAIN_LINE 3 "x...x"')
- game.io.handle_input('TERRAIN_LINE 4 "xxxxx"')
- game.io.handle_input('THING_TYPE 0 human')
- game.io.handle_input('THING_POS 0 Y:3,X:3')
- game.io.handle_input('THING_TYPE 1 monster')
- game.io.handle_input('THING_POS 1 Y:1,X:1')
+ game.io.handle_input('GEN_WORLD Hex Y:16,X:16 bar')
game.io.run_loop_with_server()
def get_player(self):
return self.get_thing(self.player_id)
+ def make_new(self, geometry, yx, seed):
+ import random
+ random.seed(seed)
+ self.turn = 0
+ self.new_map(geometry, yx)
+ for pos in self.map_:
+ if 0 in pos or (yx[0] - 1) == pos[0] or (yx[1] - 1) == pos[1]:
+ self.map_[pos] = '#'
+ continue
+ self.map_[pos] = random.choice(('.', '.', '.', '.', 'x'))
+ player = self.Thing(self, 0)
+ player.type_ = 'human'
+ player.position = [random.randint(0, yx[0] -1),
+ random.randint(0, yx[1] - 1)]
+ npc = self.Thing(self, 1)
+ npc.type_ = 'monster'
+ npc.position = [random.randint(0, yx[0] -1),
+ random.randint(0, yx[1] -1)]
+ self.things = [player, npc]
+
class Task:
return 'success'
def decide_task(self):
- if self.position[1] > 1:
- self.set_task('move', 'LEFT')
- elif self.position[1] < 3:
- self.set_task('move', 'RIGHT')
- else:
- self.set_task('wait')
+ #if self.position[1] > 1:
+ # self.set_task('move', 'LEFT')
+ #elif self.position[1] < 3:
+ # self.set_task('move', 'RIGHT')
+ #else:
+ self.set_task('wait')
def set_task(self, task_name, *args, **kwargs):
self.task = Task(self, task_name, args, kwargs)
def cmd_TERRAIN_LINE(self, y, terrain_line):
self.world.map_.set_line(y, terrain_line)
cmd_TERRAIN_LINE.argtypes = 'int:nonneg string'
+
+ def cmd_GEN_WORLD(self, geometry, yx, seed):
+ legal_grids = self.map_manager.get_map_geometries()
+ if geometry not in legal_grids:
+ raise ArgError('First map argument must be one of: ' +
+ ', '.join(legal_grids))
+ self.world.make_new(geometry, yx, seed)
+ cmd_GEN_WORLD.argtypes = 'string yx_tuple:pos string'