Esempio n. 1
0
    def generate(self):
        canvas = self._scrap_canvas(height=80, width=30)
        self.draw_room(canvas, top=0, bottom=79, left=0, right=29)

        # Place the stairs
        canvas[10][10] = things.Thing(type=things.staircase_down)

        map = Map.from_fractor_canvas(canvas)

        # Place an item
        map.put(things.Thing(type=things.potion), Position(2, 3))
        # Or two
        map.put(things.Thing(type=things.newt), Position(2, 9))

        return map
Esempio n. 2
0
    def to_map(self):
        map = Map.from_fractor_canvas(self)

        canvas = [[None] * self.box.width for _ in range(self.box.height)]

        wall = things.Thing(type=things.wall)
        for col, row in self.box:
            canvas[row][col] = wall

        floor = things.Thing(type=things.floor)
        for box in self.contents:
            for col, row in box:
                canvas[row][col] = floor

        map._architecture = canvas

        # Place an item
        map.put(things.Thing(type=things.potion), Position(2, 3))
        # Or two
        map.put(things.Thing(type=things.newt), Position(2, 9))

        return map