Пример #1
0
 def test_diagonal_hallway_invalid(self):
     lb = LevelBuilder().create_level(40, 16)\
                             .add_room((5,5), 7, 5, {(11, 7)})\
                             .add_room((26,6), 5, 8, {(26,7)})\
                             .add_room((14,1), 6, 4, {(17,4)})\
                             .add_room((14,9), 7, 4, {(17,9)})
     level = lb.build()
     actual = str(level)
     expected = "........................................\n" \
                "..............WWWWWW....................\n" \
                "..............W    W....................\n" \
                "..............W    W....................\n" \
                "..............WWWDWW....................\n" \
                ".....WWWWWWW............................\n" \
                ".....W     W..............WWWWW.........\n" \
                ".....W     D..............D   W.........\n" \
                ".....W     W..............W   W.........\n" \
                ".....WWWWWWW..WWWDWWW.....W   W.........\n" \
                "..............W     W.....W   W.........\n" \
                "..............W     W.....W   W.........\n" \
                "..............WWWWWWW.....W   W.........\n" \
                "..........................WWWWW.........\n" \
                "........................................\n" \
                "........................................"
     self.assertEqual(actual, expected, "Four Rooms Creation Failed.")
     with self.assertRaises(InvalidHallwayError):
         lb.add_hallway((17, 4), (26, 7))
     with self.assertRaises(InvalidHallwayError):
         lb.add_hallway((17, 4), (26, 7), [(18, 6)])
     with self.assertRaises(InvalidHallwayError):
         lb.add_hallway((17, 4), (26, 7), [(16, 7)])
     lb.add_hallway((17, 4), (26, 7), [(17, 7)])
     level = lb.build()
     actual = str(level)
     expected = "........................................\n" \
                "..............WWWWWW....................\n" \
                "..............W    W....................\n" \
                "..............W    W....................\n" \
                "..............WWWDWW....................\n" \
                ".....WWWWWWW.....-......................\n" \
                ".....W     W.....-........WWWWW.........\n" \
                ".....W     D.....---------D   W.........\n" \
                ".....W     W..............W   W.........\n" \
                ".....WWWWWWW..WWWDWWW.....W   W.........\n" \
                "..............W     W.....W   W.........\n" \
                "..............W     W.....W   W.........\n" \
                "..............WWWWWWW.....W   W.........\n" \
                "..........................WWWWW.........\n" \
                "........................................\n" \
                "........................................"
     self.assertEqual(actual, expected,
                      "Hallway with Waypoint Creation Failed.")
Пример #2
0
 def test_hallways_overlap_invalid(self):
     lb = LevelBuilder().create_level(40, 16)\
                             .add_room((5,5), 7, 5, {(11, 7)})\
                             .add_room((26,6), 5, 8, {(26,7)})\
                             .add_hallway((26,7), (11,7))\
                             .add_room((14,1), 6, 4, {(17,4)})\
                             .add_room((14,9), 7, 4, {(17,9)})
     level = lb.build()
     actual = str(level)
     expected = "........................................\n" \
                "..............WWWWWW....................\n" \
                "..............W    W....................\n" \
                "..............W    W....................\n" \
                "..............WWWDWW....................\n" \
                ".....WWWWWWW............................\n" \
                ".....W     W..............WWWWW.........\n" \
                ".....W     D--------------D   W.........\n" \
                ".....W     W..............W   W.........\n" \
                ".....WWWWWWW..WWWDWWW.....W   W.........\n" \
                "..............W     W.....W   W.........\n" \
                "..............W     W.....W   W.........\n" \
                "..............WWWWWWW.....W   W.........\n" \
                "..........................WWWWW.........\n" \
                "........................................\n" \
                "........................................"
     self.assertEqual(actual, expected,
                      "Four Rooms with Hallway Creation Failed.")
     with self.assertRaises(FloorPlanOverlapError):
         lb.add_hallway((17, 4), (17, 9))
Пример #3
0
 def test_hallway_overlap_room_invalid(self):
     lb = LevelBuilder().create_level(40, 16)\
                             .add_room((5,1), 7, 5, {(11, 3)})\
                             .add_room((26,2), 5, 8, {(26,3)})\
                             .add_room((15,2), 6, 4, {(16,2)})
     level = lb.build()
     actual = str(level)
     expected = "........................................\n" \
                ".....WWWWWWW............................\n" \
                ".....W     W...WDWWWW.....WWWWW.........\n" \
                ".....W     D...W    W.....D   W.........\n" \
                ".....W     W...W    W.....W   W.........\n" \
                ".....WWWWWWW...WWWWWW.....W   W.........\n" \
                "..........................W   W.........\n" \
                "..........................W   W.........\n" \
                "..........................W   W.........\n" \
                "..........................WWWWW.........\n" \
                "........................................\n" \
                "........................................\n" \
                "........................................\n" \
                "........................................\n" \
                "........................................\n" \
                "........................................"
     self.assertEqual(actual, expected, "Three Rooms Creation Failed.")
     with self.assertRaises(FloorPlanOverlapError):
         lb.add_hallway((26, 3), (11, 3))
Пример #4
0
 def test_multiple_connections_between_two_rooms(self):
     lb = LevelBuilder().create_level(40, 16)\
                             .add_room((5,5), 7, 5, {(11, 7), (11, 8)})\
                             .add_room((26,6), 5, 8, {(26,7), (26, 8)})\
                             .add_hallway((26,7), (11,7))\
                             .add_hallway((26,8), (11,8))
     level = lb.build()
     actual = str(level)
     expected = "........................................\n" \
                "........................................\n" \
                "........................................\n" \
                "........................................\n" \
                "........................................\n" \
                ".....WWWWWWW............................\n" \
                ".....W     W..............WWWWW.........\n" \
                ".....W     D--------------D   W.........\n" \
                ".....W     D--------------D   W.........\n" \
                ".....WWWWWWW..............W   W.........\n" \
                "..........................W   W.........\n" \
                "..........................W   W.........\n" \
                "..........................W   W.........\n" \
                "..........................WWWWW.........\n" \
                "........................................\n" \
                "........................................"
     self.assertEqual(actual, expected,
                      "Room with multiple connections failed.")
Пример #5
0
 def test_hallway_loops_back_to_room(self):
     lb = LevelBuilder().create_level(40, 16)\
                             .add_room((5,5), 7, 5, {(11, 8), (10, 9)})\
                             .add_hallway((10, 9), (11,8), [(10, 11), (21, 11), (21, 8)])
     level = lb.build()
     actual = str(level)
     expected = "........................................\n" \
                "........................................\n" \
                "........................................\n" \
                "........................................\n" \
                "........................................\n" \
                ".....WWWWWWW............................\n" \
                ".....W     W............................\n" \
                ".....W     W............................\n" \
                ".....W     D----------..................\n" \
                ".....WWWWWDW.........-..................\n" \
                "..........-..........-..................\n" \
                "..........------------..................\n" \
                "........................................\n" \
                "........................................\n" \
                "........................................\n" \
                "........................................"
     self.assertEqual(actual, expected, "Loop back hallway failed.")
Пример #6
0
 def test_room_no_door_invalid(self):
     lb = LevelBuilder().create_level(20, 10)
     level = lb.build()
     with self.assertRaises(InvalidRoomError):
         lb.add_room((5, 1), 7, 5, {})