예제 #1
0
 def test_desc_contains_lock_state(self):
     subject = Container(self.game, self._get_unique_noun())
     subject.giveLid()
     lock = Lock(self.game, False, None)
     subject.setLock(lock)
     self.game.turnMain(f"x {subject.verbose_name}")
     msg = self.app.print_stack.pop()
     self.assertNotIn("is locked", msg)
예제 #2
0
 def test_add_remove_item_with_lock_from_Room(self):
     parent = Room(self.game, "parent", "This is a room. ")
     parent.revealed = True
     child = Container(self.game, "child")
     child.has_lid = True
     lock = Lock(self.game, "lock", None)
     child.setLock(lock)
     self._assert_can_add_remove(parent, child)
예제 #3
0
 def test_add_remove_item_with_lock_from_Container(self):
     parent = Container(self.game, "parent")
     child = Container(self.game, "child")
     child.has_lid = True
     lock = Lock(self.game, "lock", None)
     child.setLock(lock)
     self.start_room.addThing(parent)
     self._assert_can_add_remove(parent, child)
예제 #4
0
 def test_lock_already_attached_to_something_cannot_be_applied_to_a_door(self):
     room2 = Room(
         self.game, "A different place", "Description of a different place. "
     )
     c = DoorConnector(self.game, self.start_room, "n", room2, "s")
     lock = Lock(self.game, is_locked=True, key_obj=None)
     c.setLock(lock)
     c2 = DoorConnector(self.game, self.start_room, "e", room2, "w")
     with self.assertRaises(IFPError):
         c2.setLock(lock)
예제 #5
0
 def setUp(self):
     super().setUp()
     self.container = Container(self.game, "chest")
     self.container.has_lid = True
     self.container.is_open = False
     self.key = Key(self.game, "key")
     self.me.addThing(self.key)
     self.lock = Lock(self.game, False, self.key)
     self.lock.is_locked = False
     self.container.setLock(self.lock)
예제 #6
0
 def setUp(self):
     super().setUp()
     self.room2 = Room(self.game, "A hot room",
                       "This room is uncomfortably hot. ")
     self.door = DoorConnector(self.game, self.start_room, "se", self.room2,
                               "nw")
     self.key = Key(self.game, "key")
     self.me.addThing(self.key)
     self.lock = Lock(self.game, False, self.key)
     self.lock.is_locked = False
     self.door.setLock(self.lock)
예제 #7
0
 def test_create_Lock(self):
     item = Lock(self.game, self.game, Lock.__name__, None)
     self.assertTrue(item.ix)
     self.assertIn(
         item.ix,
         self.game.ifp_objects,
         f"Tried to create a {Lock.__name__}, but index not in things obj_map",
     )
     self.assertIs(
         self.game.ifp_objects[item.ix],
         item,
         f"New {Lock.__name__} index successfully added to "
         f"object_map, but {self.game.ifp_objects[item.ix]} found under key instead of "
         f"the new instance {item}",
     )
예제 #8
0
    def test_cannot_travel_closed_and_locked_door(self):
        room2 = Room(
            self.game, "A different place", "Description of a different place. "
        )
        c = DoorConnector(self.game, self.start_room, "n", room2, "s")
        lock = Lock(self.game, is_locked=True, key_obj=None)
        c.setLock(lock)

        self.assertItemIn(
            self.me, self.start_room.contains, "test needs player to start here"
        )
        self.assertIs(self.start_room.north, c)

        self.game.turnMain("n")

        self.assertIn(
            f"{c.entrance_a.capNameArticle(True)} is locked. ", self.app.print_stack
        )

        self.assertIs(self.me.location, self.start_room)
        self.assertItemIn(
            self.me, self.start_room.contains, "player should not have moved"
        )
예제 #9
0
bench.addComposite(underbench)
# UnderSpaces that are components of another item are not described if their "description"
# attribute is None
# This also means that we cannot see what's underneath
# Set description to an empty string so we can show what's underneath without
# having to print an actual description of the UnderSpace
underbench.description = ""
underbench.full_name = "space under the bench"

box = Container(game, "box")
box.giveLid()
box.moveTo(underbench)

opal.moveTo(box)

boxlock = Lock(game, True, silverkey)
box.setLock(boxlock)

# Beach
beach = OutdoorRoom(game, "Beach, near the shack",
                    "You find yourself on an abandoned beach. ")


def beachArrival(game):
    freeEnding.endGame(game)


beach.arriveFunc = beachArrival

shackdoor = DoorConnector(game, startroom, "e", beach, "w")
shackdoor.entrance_a.description = "To the east, a door leads outside. "