Example #1
0
    def test_room_creation(self):
        # Pretend that both char1 and char2 are connected...
        self.char1.sessions.add(1)
        self.char2.sessions.add(1)
        self.assertTrue(self.char1.has_player)
        self.assertTrue(self.char2.has_player)

        wilderness.create_wilderness()
        w = self.get_wilderness_script()

        # We should have no unused room after moving the first player in.
        self.assertEquals(len(w.db.unused_rooms), 0)
        w.move_obj(self.char1, (0, 0))
        self.assertEquals(len(w.db.unused_rooms), 0)

        # And also no unused room after moving the second one in.
        w.move_obj(self.char2, (1, 1))
        self.assertEquals(len(w.db.unused_rooms), 0)

        # But if char2 moves into char1's room, we should have one unused room
        # Which should be char2's old room that got created.
        w.move_obj(self.char2, (0, 0))
        self.assertEquals(len(w.db.unused_rooms), 1)
        self.assertEquals(self.char1.location, self.char2.location)

        # And if char2 moves back out, that unused room should be put back to
        # use again.
        w.move_obj(self.char2, (1, 1))
        self.assertNotEquals(self.char1.location, self.char2.location)
        self.assertEquals(len(w.db.unused_rooms), 0)
Example #2
0
    def test_room_creation(self):
        # Pretend that both char1 and char2 are connected...
        self.char1.sessions.add(1)
        self.char2.sessions.add(1)
        self.assertTrue(self.char1.has_player)
        self.assertTrue(self.char2.has_player)

        wilderness.create_wilderness()
        w = self.get_wilderness_script()

        # We should have no unused room after moving the first player in.
        self.assertEquals(len(w.db.unused_rooms), 0)
        w.move_obj(self.char1, (0, 0))
        self.assertEquals(len(w.db.unused_rooms), 0)

        # And also no unused room after moving the second one in.
        w.move_obj(self.char2, (1, 1))
        self.assertEquals(len(w.db.unused_rooms), 0)

        # But if char2 moves into char1's room, we should have one unused room
        # Which should be char2's old room that got created.
        w.move_obj(self.char2, (0, 0))
        self.assertEquals(len(w.db.unused_rooms), 1)
        self.assertEquals(self.char1.location, self.char2.location)

        # And if char2 moves back out, that unused room should be put back to
        # use again.
        w.move_obj(self.char2, (1, 1))
        self.assertNotEquals(self.char1.location, self.char2.location)
        self.assertEquals(len(w.db.unused_rooms), 0)
Example #3
0
    def test_wilderness_correct_exits(self):
        wilderness.create_wilderness()
        wilderness.enter_wilderness(self.char1)

        # By default we enter at a corner (0, 0), so only a few exits should
        # be visible / traversable
        exits = [i for i in self.char1.location.contents
                 if i.destination and (
                  i.access(self.char1, "view") or
                  i.access(self.char1, "traverse"))]

        self.assertEquals(len(exits), 3)
        exitsok = ["north", "northeast", "east"]
        for each_exit in exitsok:
            self.assertTrue(any([e for e in exits if e.key == each_exit]))

        # If we move to another location not on an edge, then all directions
        # should be visible / traversable
        wilderness.enter_wilderness(self.char1, coordinates=(1, 1))
        exits = [i for i in self.char1.location.contents
                 if i.destination and (
                  i.access(self.char1, "view") or
                  i.access(self.char1, "traverse"))]
        self.assertEquals(len(exits), 8)
        exitsok = ["north", "northeast", "east", "southeast", "south",
                   "southwest", "west", "northwest"]
        for each_exit in exitsok:
            self.assertTrue(any([e for e in exits if e.key == each_exit]))
Example #4
0
    def test_wilderness_correct_exits(self):
        wilderness.create_wilderness()
        wilderness.enter_wilderness(self.char1)

        # By default we enter at a corner (0, 0), so only a few exits should
        # be visible / traversable
        exits = [
            i for i in self.char1.location.contents if i.destination and
            (i.access(self.char1, "view") or i.access(self.char1, "traverse"))
        ]

        self.assertEquals(len(exits), 3)
        exitsok = ["north", "northeast", "east"]
        for each_exit in exitsok:
            self.assertTrue(any([e for e in exits if e.key == each_exit]))

        # If we move to another location not on an edge, then all directions
        # should be visible / traversable
        wilderness.enter_wilderness(self.char1, coordinates=(1, 1))
        exits = [
            i for i in self.char1.location.contents if i.destination and
            (i.access(self.char1, "view") or i.access(self.char1, "traverse"))
        ]
        self.assertEquals(len(exits), 8)
        exitsok = [
            "north", "northeast", "east", "southeast", "south", "southwest",
            "west", "northwest"
        ]
        for each_exit in exitsok:
            self.assertTrue(any([e for e in exits if e.key == each_exit]))
Example #5
0
 def test_enter_wilderness_custom_name(self):
     name = "customnname"
     wilderness.create_wilderness(name)
     wilderness.enter_wilderness(self.char1, name=name)
     self.assertIsInstance(self.char1.location, wilderness.WildernessRoom)
Example #6
0
 def test_enter_wilderness_custom_coordinates(self):
     wilderness.create_wilderness()
     wilderness.enter_wilderness(self.char1, coordinates=(1, 2))
     self.assertIsInstance(self.char1.location, wilderness.WildernessRoom)
     w = self.get_wilderness_script()
     self.assertEquals(w.db.itemcoordinates[self.char1], (1, 2))
Example #7
0
 def test_create_wilderness_custom_name(self):
     name = "customname"
     wilderness.create_wilderness(name)
     w = self.get_wilderness_script(name)
     self.assertIsNotNone(w)
Example #8
0
 def test_create_wilderness_default_name(self):
     wilderness.create_wilderness()
     w = self.get_wilderness_script()
     self.assertIsNotNone(w)
Example #9
0
 def test_enter_wilderness_custom_name(self):
     name = "customnname"
     wilderness.create_wilderness(name)
     wilderness.enter_wilderness(self.char1, name=name)
     self.assertIsInstance(self.char1.location, wilderness.WildernessRoom)
Example #10
0
 def test_enter_wilderness_custom_coordinates(self):
     wilderness.create_wilderness()
     wilderness.enter_wilderness(self.char1, coordinates=(1, 2))
     self.assertIsInstance(self.char1.location, wilderness.WildernessRoom)
     w = self.get_wilderness_script()
     self.assertEquals(w.db.itemcoordinates[self.char1], (1, 2))
Example #11
0
 def test_create_wilderness_custom_name(self):
     name = "customname"
     wilderness.create_wilderness(name)
     w = self.get_wilderness_script(name)
     self.assertIsNotNone(w)
Example #12
0
 def test_create_wilderness_default_name(self):
     wilderness.create_wilderness()
     w = self.get_wilderness_script()
     self.assertIsNotNone(w)