- self.new_map(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.game.thing_types['human'](self, 0)
- player.position = [random.randint(0, yx[0] -1),
- random.randint(0, yx[1] - 1)]
- npc = self.game.thing_types['monster'](self, 1)
- npc.position = [random.randint(0, yx[0] -1),
- random.randint(0, yx[1] -1)]
- self.things = [player, npc]
+ self.maps = {}
+ self.map_size = yx
+ self.ensure_map(YX(0,0))
+ self.ensure_map(YX(0,1))
+ self.ensure_map(YX(1,1))
+ self.ensure_map(YX(1,0))
+ self.ensure_map(YX(1,-1))
+ self.ensure_map(YX(0,-1))
+ self.ensure_map(YX(-1,-1))
+ self.ensure_map(YX(-1,0))
+ self.ensure_map(YX(-1,1))
+ for map_pos in self.maps:
+ map_ = self.maps[map_pos]
+ if YX(0,0) == map_pos:
+ for pos in map_:
+ map_[pos] = self.rand.choice(('.', '.', '.', '.', 'x'))
+ else:
+ for pos in map_:
+ map_[pos] = '~'
+ player = add_thing_at_random('human')
+ self.player_id = player.id_
+ add_thing_at_random('monster')
+ add_thing_at_random('monster')
+ add_thing_at_random('food')
+ add_thing_at_random('food')
+ add_thing_at_random('food')
+ add_thing_at_random('food')