コード例 #1
0
    def testFinish(self):
        gen = CaveGenerator(5, 5)
        gen._map = parse_string(['#####', '#   #', '# # #', '#   #', '#####'])
        map = gen.finish()
        print_map(map)
        etalon_map = [[FT_ROCK_WALL() for i in range(0, 5)],
                      [
                          FT_ROCK_WALL(),
                          FT_ROCK_WALL(),
                          FT_FLOOR(),
                          FT_FLOOR(),
                          FT_ROCK_WALL()
                      ],
                      [
                          FT_ROCK_WALL(),
                          FT_FLOOR(),
                          FT_FLOOR(),
                          FT_FLOOR(),
                          FT_ROCK_WALL()
                      ],
                      [
                          FT_ROCK_WALL(),
                          FT_ROCK_WALL(),
                          FT_FLOOR(),
                          FT_FLOOR(),
                          FT_ROCK_WALL()
                      ], [FT_ROCK_WALL() for i in range(0, 5)]]

        y, x = 0, 0
        for row in map:
            for item in row:
                assert item.char == etalon_map[y][x].char
                x += 1
            y += 1
            x = 0
コード例 #2
0
ファイル: flood_fill_test.py プロジェクト: ca5h/darktower-rl
 def test_flood_fill(self):
     map = dungeon_generators.parse_string([
                                 '#########',
                                 '#........',
                                 '#########'])
     def check(x, y):
         if y >= len(map) or x >= len(map[0]):
             return False
         return map[y][x].passable()
     def create(x, y):
         map[y][x].char = "%"
     util.flood_fill(1, 1, check, create)
     print_map(map)
コード例 #3
0
    def test_flood_fill(self):
        map = dungeon_generators.parse_string(
            ['#########', '#........', '#########'])[0]

        def check(x, y):
            if y >= len(map) or x >= len(map[0]):
                return False
            return map[y][x].passable()

        def create(x, y):
            map[y][x].char = "%"

        util.flood_fill(1, 1, check, create)
        print_map(map)
コード例 #4
0
    def test_cloud_placement(self):
        map = dungeon_generators.parse_string(['.....', '..#..', '.....'])[0]

        def check(x, y):
            if y >= len(map) or x >= len(map[0]):
                return False
            return map[y][x].passable()

        def create(x, y):
            map[y][x].char = "%"

        util.put_cloud(1, 0, check, create)

        assert to_string(map) == '.%%%.n.%#%.n.%%%.n'
コード例 #5
0
ファイル: flood_fill_test.py プロジェクト: ca5h/darktower-rl
    def test_cloud_placement(self):
        map = dungeon_generators.parse_string([
                                        '.....',
                                        '..#..',
                                        '.....'])
        def check(x, y):
            if y >= len(map) or x >= len(map[0]):
                return False
            return map[y][x].passable()
        def create(x, y):
            map[y][x].char = "%"
        util.put_cloud(1, 0, check, create)

        assert to_string(map) == '.%%%.n.%#%.n.%%%.n'
コード例 #6
0
    def testFinish(self):
        gen = CaveGenerator(5, 5)
        gen._map = parse_string(["#####", "#   #", "# # #", "#   #", "#####"])
        map = gen.finish()
        print_map(map)
        etalon_map = [
            [FT_ROCK_WALL() for i in range(0, 5)],
            [FT_ROCK_WALL(), FT_ROCK_WALL(), FT_FLOOR(), FT_FLOOR(), FT_ROCK_WALL()],
            [FT_ROCK_WALL(), FT_FLOOR(), FT_FLOOR(), FT_FLOOR(), FT_ROCK_WALL()],
            [FT_ROCK_WALL(), FT_ROCK_WALL(), FT_FLOOR(), FT_FLOOR(), FT_ROCK_WALL()],
            [FT_ROCK_WALL() for i in range(0, 5)],
        ]

        y, x = 0, 0
        for row in map:
            for item in row:
                assert item.char == etalon_map[y][x].char
                x += 1
            y += 1
            x = 0
コード例 #7
0
    def testFinish(self):
        gen = CaveGenerator(5, 5)
        gen._map = dungeon_generators.parse_string(['NAME=TEST',
                                '#####',
                                 '#   #',
                                 '# # #',
                                 '#   #',
                                 '#####'])['TEST']
        map = gen.finish()
        print_map(map)
        etalon_map = [[FT_ROCK_WALL() for i in range(0, 5)],
                      [FT_ROCK_WALL(), FT_ROCK_WALL(), FT_FLOOR(), FT_FLOOR(), FT_ROCK_WALL()],
                      [FT_ROCK_WALL(), FT_FLOOR(), FT_FLOOR(), FT_FLOOR(), FT_ROCK_WALL()],
                      [FT_ROCK_WALL(), FT_ROCK_WALL(), FT_FLOOR(), FT_FLOOR(), FT_ROCK_WALL()],
                      [FT_ROCK_WALL() for i in range(0, 5)]]


        y,x = 0,0
        for row in map:
            for item in row:
                assert item.char == etalon_map[y][x].char
                x +=1
            y += 1
            x = 0