コード例 #1
0
    def test_travel_in_out(self):
        room1 = Room(self.game, "A place", "Description of a place. ")
        room2 = Room(
            self.game, "A different place", "Description of a different place. "
        )
        room1.entrance = room2
        room2.exit = 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("enter")

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

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

        self.game.turnMain("exit")

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

        self.assertIs(
            self.me.location,
            room1,
            f"Tried to travel out to {room1}, '{room1.name}', but player in "
            f"{self.me.location}",
        )
コード例 #2
0
ファイル: testgame.py プロジェクト: JSMaika/intficpy

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. "
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")