コード例 #1
0
ファイル: tutorial2.py プロジェクト: jplevyak/bwx-adventure
#!/user/bin/python
# vim: et sw=2 ts=2 sts=2
#
# This is the second tutorial for writing Interactive Fiction with the BWX Adventure Game Engine.
#
from advent import *
# for cloud9
from advent import Game, Location, Connection, Object, Animal, Robot, Pet, Player
from advent import NORTH, SOUTH, EAST, WEST, UP, DOWN, RIGHT, LEFT, IN, OUT, FORWARD, BACK, NORTH_WEST, NORTH_EAST, SOUTH_WEST, SOUTH_EAST, NOT_DIRECTION

# import random module for random numbers
import random

# Let's start with the code from the first tutorial:

game = Game("Brightworks Adventure")

sidewalk = game.new_location(
    "Sidewalk",
    "There is a large glass door to the east. The sign says 'Come In!'")

vestibule = game.new_location(
    "Vestibule", """A small area at the bottom of a flight of stairs.
There is a glass door to the west.""")

game.new_connection("Glass Door", sidewalk, vestibule, [IN, EAST], [OUT, WEST])

player = game.new_player(sidewalk)

# Now let's add an inanimate object, a key by providing a single word name and a longer
# description.  We will create the key at the sidewalk
コード例 #2
0
# Create the game

print("                       ~~~ Welcome to ~~~                       ")
print("    ___       __                 __                     ___  ___")
print("   /   | ____/ /   _____  ____  / /___  __________     |__ \<  /")
print("  / /| |/ __  / | / / _ \/ __ \/ __/ / / / ___/ _ \    __/ // / ")
print(" / ___ / /_/ /| |/ /  __/ / / / /_/ /_/ / /  /  __/   / __// /  ")
print("/_/  |_\__,_/ |___/\___/_/ /_/\__/\__,_/_/   \___/   /____/_/   ")
print("                                                                ")
print("                       ~~~~~~~~~~~~~~~~~~                       ")
print("                                                                ")
print("For a list of commands, just enter 'commands' or 'verbs'...     ")
print("                                                                ")

game = Game("Adventure 21")

# Create all Rooms

room_hallway_north = game.new_location(
    "Hallway North",
    """You find yourself in a hallway. In the west, you see the open door to the living room.
In the east, you look at a door with a combination lock. 
The hallway extends towards south.""")

room_hallway_middle = game.new_location(
    "Center Hallway",
    """ You still walk through the hallway. There is a closed door in the west.
The hallway is open to south and north.""")

room_hallway_south = game.new_location(
コード例 #3
0
                "Death from boredom after twelve continous hours of blood transfusion"
            )
            self.player.terminate()
        else:
            self.output(
                "12 hours pass - you gain 10 Acceptatrons, but you now fill depressed. "
                "You need to find more of these happy pills!")
            game.player.unset_flag(happypills.name)
            self.player.add_to_inventory(
                Object("Acceptatrons", "10 pure, undiluted acceptatrons"))

        self.verb.act(actor, noun, words)
        return True


game = Game("Non-Compulsory Slaving-Volunteering")

lobby = Location(
    "Lobby",
    "The heavy smog of the slave-volunteering ship Vromarion is hurting your lungs. "
    "Captain must be cheap, air filters are expensive. 'Welcome to cruise-ship Vromarion', a pleasant voice explains. "
    "'You are a first generation volunteer. "
    "Given a choice of death by thirst and hunger or volunteering for just 56 years,  you chose (out of your own free volition) the later. "
    "We start volunteering on the decks at exactly 7am, one hour before robot operations commence. "
    "You arrived late, thus there will be no formal induction."
    "the transporter to the right will move you to blood operations. You can choose to go right. Please hurry!'",
    "on")

blood_room = Location(
    "Blood donations",
    "You are teleported in the middle of what is probably a mile-wide and two-miles long room full of little 'igloos'. Your iCommunicator beams:"