示例#1
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))
示例#2
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))
示例#3
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.")