コード例 #1
0
    def test_travel_north_south(self):
        room1 = Room(self.game, "A place", "Description of a place. ")
        room2 = Room(
            self.game, "A different place", "Description of a different place. "
        )
        room1.north = room2
        room2.south = room1
        self.me.location.removeThing(self.me)
        room1.addThing(self.me)
        self.assertIs(
            self.me.location, room1, "This test needs the user to start in room1"
        )

        self.game.turnMain("go n")
        self.assertEqual(self.app.print_stack[-3], room1.n_msg)

        self.assertIs(
            self.me.location,
            room2,
            f"Tried to travel north to {room2}, '{room2.name}', but player in "
            f"{self.me.location}",
        )

        self.game.turnMain("s")

        self.assertEqual(self.app.print_stack[-3], room1.s_msg)

        self.assertIs(
            self.me.location,
            room1,
            f"Tried to travel south to {room1}, '{room1.name}', but player in "
            f"{self.me.location}",
        )
コード例 #2
0
ファイル: testgame.py プロジェクト: JSMaika/intficpy
shackdoor.entrance_a.description = "To the east, a door leads outside. "
shackdoor.entrance_b.description = "The door to the shack is directly west of you. "

cabinlock = Lock(game, True, rustykey)
shackdoor.setLock(cabinlock)

startroom.exit = shackdoor
beach.entrance = shackdoor

# Attic

attic = Room(game, "Shack, attic", "You are in a dim, cramped attic. ")
shackladder = LadderConnector(game, startroom, attic)
shackladder.entrance_a.description = (
    "Against the north wall is a ladder leading up to the attic. ")
startroom.north = shackladder
silverkey.moveTo(attic)

# CHARACTERS
# Sarah
sarah = Actor(game, "Sarah")
sarah.makeProper("Sarah")
sarah.moveTo(startroom)


def sarahOpalFunc(game, dobj):
    """
    IntFicPy verbs can be overridden or customized for specific items.
    To do this, find the verb you want to customize in the intficpy.verb module.
    Note
        1) the class name of the verb