示例#1
0
}

# Link rooms together

room['outside'].n_to = room['foyer']
room['foyer'].s_to = room['outside']
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']
room['outside'].add_item(Item('Backpack', 'A backpack to hold your items'))
room['outside'].add_item(
    LightSource('Lantern', 'A lantern to help you see through the darkness.'))
room['treasure'].add_item(Treasure('Diamond', 'A shiny diamond.', 75))
room['overlook'].add_item(
    Treasure('Map', 'A map with an X. Could it be treasure?', 20))
room['narrow'].add_item(Treasure('Silver', 'A silver bar.', 25))

#
# Main
#

# Make a new player object that is currently in the 'outside' room.

# Write a loop that:
#
# * Prints the current room name
# * Prints the current description (the textwrap module might be useful here).
# * Waits for user input and decides what to do.
示例#2
0
# item = {
#     'sword':  Item("sword",
#                      "slay the creeps using the sword."),
#
#     'ax':    Item("ax",
#                         """crush them with the ax"""),
#
#     'torch': Item("torch",
#                         """Find your way!"""),
#
#     'amulet':   Item("amulet",
#                          """Stop spells"""),
#
# }

coins = Treasure("coins", "gold coins for the taking")
rubies = Treasure("rubies", "sparkleys")

sword = Item("sword", "slay the creeps using the sword.")
ax = Item("ax", "crush them with the ax")
mace = Item("mace", "fly anything with the mace")



playerStartingItems = [sword]
room['outside'].addItem(ax)
room['foyer'].addItem(mace)
room['treasure'].addItem(coins)
room['treasure'].addItem(rubies)

valid_directions = {"n": "n", "s": "s", "e": "e", "w": "w",
示例#3
0
room['outside'].n_to = room['foyer']
room['foyer'].s_to = room['outside']
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['partyroom']

room['outside'].is_light = True
room['foyer'].is_light = True

# Add some items

t = Treasure("stars", "Shiny stars", 100)
room['overlook'].contents.append(t)

t = Treasure("jewels", "Jewels! Beautiful Jewels ", 200)
room['treasure'].contents.append(t)

l = LightSource("jar", "Jar of Fairies")
room['foyer'].contents.append(l)

f = Food("turkeyleg", "Turkey Leg")
room['partyroom'].contents.append(f)

def tryDirection(d, currentRoom):
    """
    Try to move a direction, or print an error if the player can't go that way.
示例#4
0
# Print an error message if the movement isn't allowed.
#
# If the user enters "q", quit the game.

# Rooms are initiliazed with no items. To add them, use the
# Room.add_items(*items) method. You may pass in a  list,
# individual items, or a combination of both
# e.g. Room.add_items('sword', 'shield', ['treasure, 'crown', 'chalice'])

# room['outside'].add_items('rocks', ['skull', 'abandoned armor'])

#// ******************
# Define Items

chest = Treasure(
    'Treasure Chest - [chest]', """An old pirate relic, overflowing with 
    bullions and gems""", 'chest', 100)
ring = Treasure(
    "Princess Fiora's Ring - [ring]",
    """A ring granting the wearer god-like beauty and charm,
    but removing the ability to love""", 'ring', 125)
crown = Treasure(
    "King Arthur's Crown - [crown]",
    """Rumored among mystics and trobadours to grant
the wearer the ability to read the minds of others""", 'crown', 250)
grail = Treasure(
    'Holy Grail - [grail]', """The enchanted chalice of life. It looks benign 
    now, but perhaps in the proper hands...""", 'grail', 375)
candle = LightSource('Magic Candle', """Your true source of light""", 'candle',
                     10)
示例#5
0
}

items = {
    "shovel": Item("shovel", "Use this to dig or hit with manually droppable item"),
    "sword": Item("sword", "Use this to chop or slice manually droppable item"),
    "spells": Item("spells", "Book of spells manually droppable item"),
    "bat": Item("bat", "Use this to knock down or hit with manually droppable item"),
    "gun": Item("gun", "Shoot with this manually droppable item"),
    "extinguisher": Item("extinguisher", "Put out fires or use as a decoy, manually droppable item"),
    "coins": Item("coins", "coins count as points, every room has coins This item cannot be mannually dropped"),
    "key": Item("key", "Master key that can unlock anything might be worth holding on to."),
    "scuba": Item("scuba", "Scuba Mask allows you to breathe under water for extended periods of time.")
}

treasures = {
    "gold": Treasure(1000, "gold", "Chest full of Gold. The chest features 1000 points worth of gold. You will need a master key to unlock it!"),
    "silver": Treasure(500, "silver", "500 points worth of valuable silver at the bottom of the pool. YOu will need a scuba mask due the pool being 50 feet deep. Silvers at the bottom."),
    "wallet": Treasure (250, "wallet", "You have found the kings wallet featuring 250 points"),
}

room = {
    'outside':  Room("outside",
                     "Outside Cave Entrance North of you, the cave mount beckons", [items["coins"],treasures["gold"]],False),

    'foyer':    Room("foyer", """Dim light filters in from the south. Dusty
passages run north and east.""", [items["coins"], lights["flashlight"],treasures["silver"]], True),

    'overlook': Room("overlook", """Grand Overlook A steep cliff appears before you, falling
into the darkness. Ahead to the north, a light flickers in
the distance, but there is no way across the chasm.""", [items["spells"],items["coins"],treasures["wallet"]], True),
示例#6
0
room['outside'].n_to = room['foyer']
room['foyer'].s_to = room['outside']
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']

room['outside'].is_light = True
room['foyer'].is_light = True

# Add some items

t = Treasure("coins", "Shiny coins", 100)
room['overlook'].contents.append(t)

t = Treasure("silver", "Tarnished silver", 200)
room['treasure'].contents.append(t)

l = LightSource("lamp", "Brass lamp")
room['foyer'].contents.append(l)


def tryDirection(d, curRoom):
    """
    Try to move a direction, or print an error if the player can't go that way.
    Returns the room the player has moved to (or the same room if the player
    didn't move).
    """
示例#7
0
from room import Room
from player import Player
from item import Potion
from item import Treasure

# Declare items
hp1 = Potion("Potion", "Adds +1 to your Health", "health 1")
bc = Treasure("Coin", "Bronze coin worth 5 coins", "coin", 5)
rg = Treasure("Gem", "A shiny red gem worth 10 coins", "gem", 10)

#item sets
item_set1 = [bc]
item_set2 = [bc, rg]
item_set3 = [bc, rg, hp1]
item_set4 = [rg, hp1]
# Declare all the rooms

outside = Room("Outside Cave Entrance", "North of you, the cave mount beckons",
               [])

foyer = Room(
    "Foyer", """Dim light filters in from the south. Dusty
passages run north and east.""", item_set1)

overlook = Room(
    "Grand Overlook", """A steep cliff appears before you, falling
into the darkness. Ahead to the north, a light flickers in
the distance, but there is no way across the chasm.""", item_set3)

narrow = Room(
    "Narrow Passage", """The narrow passage bends here from west
示例#8
0
    Room(
        "Treasure Chamber", """You've found the long-lost treasure
chamber! Sadly, it has already been completely emptied by
earlier adventurers. But after some searching you find a key... """, False),
    'secret':
    Room(
        "Secret Room", """With all of your knowledge and sheer fortitude
you have found a way into this room and found the treasure. And go east to exit this ride\n\nDon't forget to claim your prize!""",
        False)
}

# Create Items Dictionary

Items = {
    "Sword": Item('Sword', 'Shiny'),
    "BronzeCoin": Treasure('BronzeCoin', 'Bronze', '5'),
    "SilverCoin": Treasure('SilverCoin', 'Silver', '10'),
    "GoldCoin": Treasure('GoldCoin', 'Gold', '20'),
    "Lamp": LightSource('Lamp', 'Illuminator'),
    "Key": Item('Key', 'Secret Hidden Key'),
    "Pebble": Item('Pebble', 'Yep, Just A Pebble')
}

# Adding Items to a Room

room['outside'].addItem(Items['Sword'])
room['foyer'].addItem(Items['BronzeCoin'])
room['narrow'].addItem(Items['SilverCoin'])
room['overlook'].addItem(Items['GoldCoin'])
room['outside'].addItem(Items['Lamp'])
room['treasure'].addItem(Items['Key'])
示例#9
0
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']

#add items to the rooms
#overlook room, lets append a new item to the contains list

#outside
room['outside'].contains.append(Item("stick", "Stick. a simple tree branch."))
room['outside'].contains.append(
    Item("matches", "Matches. an old book of matches."))
#foyer
room['foyer'].contains.append(Item("grapes", "Grapes.. need a snack?"))
room['foyer'].contains.append(
    Item("dagger", "Dagger. letter opener, or stabby thing?"))
room['foyer'].contains.append(
    Treasure("diamond", "A priceless Diamond. treasure", 1000))
#overlook
room['overlook'].contains.append(
    Item(
        "pouch",
        "Pouch. A small leather pouch of silver coins. Good, but we're looking for bigger treasure."
    ))
room['overlook'].contains.append(
    Item("letter", "Letter. A wax-sealed letter, but not addressed to us."))
room['overlook'].contains.append(
    Item(
        "book",
        "Book. A leather book. Seems to be a journal. Maybe the land owners."))
room['overlook'].contains.append(
    Treasure("ruby", "A priceless Ruby. treasure", 1000))
#narrow
示例#10
0
import random
from room import Room
from player import Player
from item import Item, Treasure, Lightsource, Food
from monster import Monster

# Declare all the rooms

room = {
    'outside':
    Room("Outside Cave Entrance", "   North of you, the cave mount beckons", [
        Treasure("golden cup", "a shimmering goblet studded with jewels", 100,
                 10)
    ], False),
    'foyer':
    Room(
        "Foyer", """    Dim light filters in from the south. 
    Dusty passages run north and east.""",
        [Lightsource("lamp", "looks like it has a genie inside", 10)], True),
    'overlook':
    Room(
        "Grand Overlook", """    A steep cliff appears before you, 
    falling into the darkness. Ahead to the north, 
    a light flickers in the distance, but there 
    is no way across the chasm.""", [
            Item("long sword", "a sharp, heavy blade", 75),
            Item("rusty sword", "a dull and dingy blade", 30),
            Food("bread", "a crusty loaf", 5, 20)
        ], False),
    'narrow':
    Room(
示例#11
0
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']

room['outside'].itemslist.append(
    Item('rusty shield', 'an old rusty shield not of any use'))
room['narrow'].itemslist.append(Item('shield', 'an shield strong and sturdy'))
room['foyer'].itemslist.append(Item('sword',
                                    'it gives off an erry green glow'))
room['treasure'].itemslist.append(Item('crown', 'A golden crown '))

# add in the 3 treasures
room['treasure'].itemslist.append(Treasure("chest", 'Chest full of coins',
                                           100))
room['outside'].itemslist.append(Treasure("chest", 'Chest full of coins', 100))
room['foyer'].itemslist.append(Treasure("chest", 'Chest full of coins', 100))
#
# Main
#
itemslist = ["there is nothing here"]
# Make a new player object that is currently in the 'outside' room.

name = input('Enter your name Traveler: ')

# this creates the player
player1 = Player(name, room['outside'])

print("Welcome " + player1.name)
示例#12
0
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']

#
# Main
#

# Make a new player object that is currently in the 'outside' room.
item = Item('sword', 'silver')
item2 = Item('cat', 'fuzzy')
item3 = Item('dog', 'big')
item4 = Item('knife', 'sharp')
item5 = Item('nerf gun', 'blue')
item6 = Treasure('ball', 'blue', 5)
item7 = Treasure('elephant', 'gray', 1000)
item8 = Treasure('lion', 'mane', 10)
player = Player('Tylar', room['outside'])
room['outside'].addItem(item)
room['foyer'].addItem(item2)
room['overlook'].addItem(item3)
room['narrow'].addItem(item4)
#room['treasure'].addItem(item5)
room['treasure'].addItem(item6)
room['treasure'].addItem(item7)
room['treasure'].addItem(item8)


# Write a loop that:
#
示例#13
0
    'narrow':
    DarkRoom(
        "in the Narrow Passage", """The narrow passage bends here from west
to north. The smell of gold permeates the air."""),
    'treasure':
    Room(
        "in the Treasure Chamber", """You've found the long-lost treasure
chamber! Sadly, it has already been completely emptied by
earlier adventurers. The only exit is to the south."""),
}

item = {
    'torch':
    LightSource("Blazing Torch", "How is this still on fire?"),
    'treasure':
    Treasure("Hidden Treasure",
             "Looks like the previous adventurers missed this!", 100),
    'rock':
    Item("Blunt Rock", "It's not very sharp..."),
    'sword':
    Item("Iron Sword", "More sharp than a rock!"),
}

# Link rooms together

room['outside'].n_to = room['foyer']
room['foyer'].s_to = room['outside']
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
示例#14
0
    'log':
    Item('log', 'a small wooden log'),
    'rope':
    Item('rope', '30 ft of rope'),
    'chair':
    Item('chair', 'generic chair'),
    'hat':
    Item('hat', 'a rain hat'),
    'hiking_pole':
    Item('hiking pole', 'a pole you use as a walking stick while hiking'),
    'treasure_chest':
    Item('treasure chest', 'a big treasure chest'),
    'shovel':
    Item('shovel', 'a big gardening shovel'),
    'treasure1':
    Treasure('treasure1', 'treasure1 description', 50),
    'treasure2':
    Treasure('treasure2', 'treasure2 description', 100),
    'treasure3':
    Treasure('treasure3', 'treasure3 description', 200),
    'lamp':
    LightSource('lamp', 'a small oil lamp')
}

# Declare all the rooms
room = {
    'outside':
    Room("Outside Cave Entrance", "North of you, the cave mount beckons",
         [item["rock"], item["log"], item["rope"]]),
    'foyer':
    Room(
示例#15
0
        handle_input()
    elif lc_command == 'q':
        print(colored('\n     **You have ended the game.**\n',
                      'red', attrs=['bold']))
        input("\n     press 'Enter' to continue")
    else:
        print(colored('\n     what command is this!?', 'red', attrs=['bold']))
        input("\n     press 'Enter' to continue")


# instantiate/initialize player, room items, and command
player = Player(room['outside'])
room['outside'].list.append(
    Item('HealthGlobe', 'Glowey Globe of Shiny Red Stuffs'))
room['outside'].list.append(Item('Sign', 'Danger, Keep out!'))
room['outside'].list.append(LightSource(
    'WillowWisp', 'A globe of shiny lights'))
room['traproom'].list.append(LightSource(
    'Torch', 'Fire strikes fear in the hearts of shadows'))
room['traproom'].list.append(Treasure('FineGemstone', 500))
room['traproom'].list.append(
    Weapon('Sword', 'A basic but effective looking blade.', 5))

command = ''  # anything other than 'q' to start main loop

# Main
while command.lower() != 'q':
    start_turn(player)
    get_input()
    handle_input()
示例#16
0
passages run north and east."""),

    'overlook': Room("Grand Overlook", """A steep cliff appears before you, falling
into the darkness. Ahead to the north, a light flickers in
the distance, but there is no way across the chasm."""),

    'narrow':   Room("Narrow Passage", """The narrow passage bends here from west
to north. The smell of gold permeates the air."""),

    'treasure': Room("Treasure Chamber", """You've found the long-lost treasure
chamber! Sadly, it has already been completely emptied by
earlier adventurers. The only exit is to the south. """),
}

t = LightSource("Torch", "And Let There Be Light")
h = Treasure("Human Poo", "I don't know why you would pick this up", 100)
f = Treasure("Tiger Poo", "I don't know why you would pick this up", 100)
j = Treasure("Bat Poo", "I don't know why you would pick this up", 100)
room['outside'].item.append(t)
room['foyer'].item.append(h)
room['narrow'].item.append(f)
room['overlook'].item.append(j)



# Link rooms together

room['outside'].n_to = room['foyer']
room['foyer'].s_to = room['outside']
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
示例#17
0
            ),
            Item("chain", "a heavy chain")
        ]),
    'narrow':
    Room(
        "Narrow Passage", """The narrow passage bends here from west
to north. The smell of gold permeates the air.""", [
            Item("cannister",
                 "a bent up fuel cannister, still a few drops left")
        ]),
    'treasure':
    Room(
        "Treasure Chamber", """You've found the long-lost treasure
chamber! Sadly, it has already been completely emptied by
earlier adventurers. The only exit is to the south.""", [
            Treasure("goblet", "a shimmering golden goblet", 15000),
            Treasure("necklace",
                     "a jewel-encrusted necklace w/ cryptic engravings", 5000)
        ]),
}

# Link rooms together

room['outside'].n_to = room['foyer']
room['foyer'].s_to = room['outside']
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']
示例#18
0
into the darkness. Ahead to the north, a light flickers in
the distance, but there is no way across the chasm."""),

    'narrow': Room("Narrow Passage", """The narrow passage bends here from west
to north. The smell of gold permeates the air."""),

    'treasure': Room("Treasure Chamber", """You've found the long-lost treasure
chamber! Sadly, it has already been completely emptied by
earlier adventurers. The only exit is to the south."""),
}

# create items
item1 = Item("coins", "Shiny coins")
item2 = Item("coins2", "Shiny coins 2")
item3 = Item("coins3", "Shiny coins 3")
gold = Treasure('gold', 'Money Money', 100)
room['outside'].addItem(item1)
room['outside'].addItem(item2)
room['outside'].addItem(item3)
room['outside'].addItem(gold)

item4 = Item('dog', 'black')
room['foyer'].addItem(item4)
# Link rooms together

room['outside'].n_to = room['foyer']
room['foyer'].s_to = room['outside']
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
示例#19
0
from item import Item, Treasure, LightSource

starter_lantern = LightSource('Lantern', 'Adding while testing')

items = [
    Treasure('Helmet', "A bronze helmet. Slightly dented, but still intact", 250),
    Treasure('Bracers', 'Leather bracers. May cause chafing', 100),
    Treasure('Pants', 'Will DEFINITELY cause chafing', 300),
    Treasure('Chestpiece', 'Strong iron chestpiece', 750),
    Treasure('Sword', 'Slightly dull, but will lay some hurt', 500),
    Item('Tome', 'Maybe someone will pay for this'),
    Item('Fork', 'Looks to be silver plated and thus worthless, why take it?'),
    LightSource('Torch', 'Good for light AND setting things on fire!')
]
示例#20
0
        "in a narrow passage",
        """The narrow passage bends here from west to north.
The smell of gold permeates the air.""",
        [
            Item('skull', 'a skull'),
            LightSource('torch', 'a torch'),
        ],
    ),
    'treasure':
    Room(
        "in the Treasure Chamber!",
        """You've found the long-lost treasure chamber!
Sadly, it has already been completely emptied by earlier adventurers
The only exit is to the south.""",
        [
            Treasure('amulet', 'an amulet'),
            Item('rum', 'a bottle of rum'),
        ],
    ),
    'hidden':
    Room(
        "there is a strange seam in the wall You push on it and find a hidden room!",
        """You've found a hidden treasure chamber!""",
        [
            Treasure('emerald', 'an emerald jewel'),
            Item('flask', 'a flask'),
        ],
    ),
    'library':
    Room(
        "in a room with old books",
示例#21
0
文件: adv.py 项目: ekm79/Intro-Python
from room import Room
from player import Player
from item import Item
from item import LightSource
from item import Treasure


item = {
    "key": Item("key", "a small golden key"),
    "rock": Item("rock", "just a small rock"),
    "torch": LightSource("torch", "a torch with a flame"),
    "coins": Treasure("coins", "a pouch filled with golden coins", 5),

}

# Declare all the rooms

room = {
    'outside':  Room("Outside Cave Entrance",
                     "North of you, the cave mount beckons", [item["rock"]], True),

    'foyer':    Room("Foyer", """Dim light filters in from the south. Dusty
passages run north and east.""", [item["key"]], True),

    'overlook': Room("Grand Overlook", """A steep cliff appears before you, falling
into the darkness. Ahead to the north, a light flickers in
the distance, but there is no way across the chasm.""", [item["torch"]], True),

    'narrow':   Room("Narrow Passage", """The narrow passage bends here from west
to north. The smell of gold permeates the air.""", [], False),
示例#22
0
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']


knife = Item("knife", "Old rusty knife that looks like it hasn't been sharpened in a decade")
lamp = Item("lamp", "It's always good to have a source of light")
leather_pouch = Item("leather_pouch", "Look inside... There might be something in there!")
wine_flask = Item("wine_flask", "Well it's empty so what's the point?")
golden_key = Item("golden_key", "You never know when you will come across a locked door")
rope = Item("rope", "It's about 10 feet long and made out of horse hair")
ancient_scroll = Item("ancient_scroll", "Looks like a love letter, does it hold any value?")

pearls = Treasure("pearls", "So shiny, so white, so pretty. Maybe this has some value?", 100)
emerald = Treasure("emerald", "Looks dirty, but it still has a glimmer to it", 200)
gold_coins = Treasure("gold_coins", "These got to be worth a lot!", 500)



room['outside'].items = [knife, lamp, pearls]
room['foyer'].items = [leather_pouch, wine_flask, gold_coins]
room['overlook'].items = []
room['narrow'].items = [golden_key, rope]
room['treasure'].items = [ancient_scroll, emerald]

#
# Main
#
print()
示例#23
0
from room import Room
from player import Player
from item import Item, Treasure, LightSource

items = {
    'club':
    Item('Club', 'An old worn stick. Good for bashing things'),
    'ring':
    Treasure(100, 'Ring',
             'A plain looking ring that gives off a mystical glow'),
    'key':
    Treasure(100, 'Key', 'A golden Key'),
    'ruby':
    Treasure(500, 'Ruby', 'A large ruby'),
    'lamp':
    LightSource('Lamp', 'A common lamp. No genies here!')
}

room = {
    'outside':
    Room("Outside Cave Entrance", "North of you, the cave mount beckons", True,
         [items['club'], items['key'], items['lamp']]),
    'foyer':
    Room(
        "Foyer", """Dim light filters in from the south. Dusty
passages run north and east."""),
    'overlook':
    Room(
        "Grand Overlook", """A steep cliff appears before you, falling
into the darkness. Ahead to the north, a light flickers in
the distance, but there is no way across the chasm.""", False,
示例#24
0
from player import Player
from item import Item
from item import Treasure
from item import LightSource
import textwrap

# Declare all the items
item = {}
item['sword'] = Item('sword', 'It is magical sword with interesting powers')
item['knife'] = Item('knife', 'It is an ancient knife with speed and power')
item['arrow'] = Item('arrow', 'Bow and arrow are a deadly combination')
item['coins'] = Item('coins', 'Coins can buy you other items')

#Treasure creation, it is a sub-class of item

item['gold'] = Treasure('gold', 'gold gives you the power to buy more items',
                        500)
item['silver'] = Treasure('silver', 'silver is the choice of a warrior', 300)
item['ruby'] = Treasure('ruby', 'ruby potion can put Hagrid to sleep', 150)

#LightSource creation
item['lamp'] = LightSource(
    'lamp', 'lamp is a source of light that leads to knowledge')

# Declare all the rooms
room = {
    'outside':
    Room("Outside Cave Entrance", "North of you, the cave mount beckons",
         [item['sword'], item['coins']], False),
    'foyer':
    Room(
        "Foyer", """Dim light filters in from the south. Dusty
示例#25
0
# Link rooms together

room['outside'].n_to = room['foyer']
room['foyer'].s_to = room['outside']
room['foyer'].n_to = room['overlook']
room['foyer'].e_to = room['narrow']
room['overlook'].s_to = room['foyer']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']

# Create items for game (item, treasure, lightsource and packs)
dagger = Item('dagger',
              'A small but very sharp dagger. Good for cutting things.')
rope = Item('rope', 'A very sturdy long piece of rope. Could be useful...')
coins = Treasure('coins',
                 "A small pile of gold coins. Shine brightly in the light")
treasure = Treasure('treasure', 'A large pile of treasure')
flashlight = LightSource('flashlight', 'A tool used to see in the dark')
backpack = Pack('backpack', 'A good way to carry more items', 3)

# Add items to the respective rooms
room['foyer'].items = [dagger, backpack]
room['overlook'].items = [rope]
room['narrow'].items = [treasure]
room['treasure'].items = [coins]
room['outside'].items = [flashlight]

# Main
#

# Make a new player object that is currently in the 'outside' room.
示例#26
0
from room import Room
from player import Player
# from minimap.minimap import MiniMap # Importing from subdirectories
from item import Item
from item import Treasure
from item import LightSource

# Declare Global Items
items = {
    'dandelions':   Item('dandelions', 'A handful of dandelions. Can be found at the entrance of the cave.'),
    'sword':        Item('sword', 'A masterfully crafted sword, suited for a champion!'),
    'lamp':         LightSource('lamp', 'An old and rusty lamp, looks like it still has oil in it'),
    'amulet':       Item('amulet', 'A glowing amulet, it vibrates as you get closer to treasures'),
    'backpack':     Item('backpack', 'A very large backpack. This can come in handy!'),
    'laptop':       Item('laptop', 'A personal laptop, too bad the batteries have run out'),
    'treasure':     Treasure('treasure', 'A cache of gems and artifacts, neatly packed in a old leather bag', 100),
}

# Declare all the rooms

room = {
    #outside:   { name: "Outside Cave Entrance", description: "North of you, the cave mount beckons", n_to: {POINTS TO FOYER}}
    'outside':  Room("Outside Cave Entrance", "Dandelions grow on the outside of the cave entrance. North of you, the cave mount beckons", is_lit=True),
    'foyer':    Room("Foyer","Dim light filters in from the south. Dusty passages run north and east.", is_lit=True),
    'overlook': Room("Grand Overlook","A steep cliff appears before you, falling into the darkness. Ahead to the north, a light flickers in the distance, but there is no way across the chasm."),
    'narrow':   Room("Narrow Passage","The narrow passage bends here from west to north. The smell of gold permeates the air."),
    'treasure': Room("Treasure Chamber","You've found the long-lost treasure chamber! Sadly, it has already been completely emptied by earlier adventurers. The only exit is to the south."),
    # Add your own room here
    'corridor': Room("Main Corridor", "You are located at a narrow corridor. West of you a dim light can be seen. East of you is the foyer"),
    'gallery':  Room(
                    "Grand Gallery", 
示例#27
0
    'outside':
    Room("Outside Cave Entrance", "North of you, the cave mount beckons",
         [LightSource("lamp", "a battered old lamp with some oil in it")],
         True),
    'bridge':
    Room(
        "Bridge",
        """Rough winds blow acoss a lonely bridge. The smell of dragon fire and brimstone is heavy here.
On the other side you see a red dragon sleeping in the sunlight. It guards the entrance to an ancient cathedral""",
        [], True),
    'cathedral':
    Room(
        "Cathedral",
        """Broken pews, torn tapestries, and skeletons of past adventurers are all that remain inside.
At the end, sunlight illuminates the lady's chapel. You see a crack in the wall.""",
        [Treasure("ruby", "crimson red jewel worn by ancient priests", 10000)],
        False),
    'foyer':
    Room(
        "Foyer", """Dim light filters in from the south. Dusty
passages run north and east.""", [
            LightSource("torch",
                        "an everlasting torch that gives off a yellow light"),
            Item("potion", "a bright red potion"),
            Item("parchment",
                 "dusy, yello parchment that's ready to disintegrate"),
            Treasure("sapphire", "sapphire set inside a silver ring", 20000)
        ], False),
    'armory':
    Room(
        "Armory",
示例#28
0
excaliber = Weapon(
    "Excaliber",
    "The Lady of the Lake, her arm clad in the purest shimmering samite, held aloft Excalibur from the bosom of the water signifying by Divine Providence that you, Arthur, were to carry Excalibur.",
    10)
grenade = Weapon(
    "Holy Hand Grenade of Antioch",
    "And Saint Attila raised the hand grenade up on high, saying, ‘O Lord, bless this thy hand grenade, that with it thou mayst blow thine enemies to tiny bits, in thy mercy.’ And the Lord did grin. And the people did feast upon the lambs and sloths, and carp and anchovies, and orangutans and breakfast cereals, and fruit-bats. And the Lord spake, saying, ‘First shalt thou take out the Holy Pin. Then shalt thou count to three, no more, no less. Three shall be the number thou shalt count, and the number of the counting shall be three. Four shalt thou not count, neither count thou two, excepting that thou then proceed to three. Five is right out. Once the number three, being the third number, be reached, then lobbest thou thy Holy Hand Grenade of Antioch towards thy foe, who, being naughty in my sight, shall snuff it.'  Amen.",
    50)
rock = Item(
    "Rock",
    "The solid mineral material forming part of the surface of the earth and other similar planets, exposed on the surface or underlying the soil or oceans."
)
stick = Item("Stick",
             "A thin piece of wood that has fallen or been cut from a tree.")
coin = Treasure("Coin", "A single coin.", 1)
duck = Treasure(
    'Duck', "If something weighs as much as a duck, it must be made of wood.",
    10)
ninePence = Treasure("Pence", "Nine pence.  Enough to pay a mortician.", 9)
shrubbery = Treasure("Shrubbery", "It's...  a shrubbery!", 10)
elderberries = Treasure(
    "Elderberries",
    "A very... *cough* manly... *cough* perfume...  *snicker snicker*", 10)
deed = Treasure("Deed", "A deed for HUGE...  tracts of land!", 10)
hamster = Item("Hamster", "This is your Mother.  Do not lose her.")
coconuts = Item("Coconuts", "A mighty steed!")
shield = Armor("Shield", "A worn, wooden shield.", 10)
spam1 = Food("Spam", "I would like some Spam.", 1)
spam2 = Food("SpamSpam", "I would like some Spam and Spam.", 2)
spam3 = Food("SpamSpamSpam", "I would like some Spam, Spam, and Spam", 3)
示例#29
0
import random
from room import Room
from player import Player
from item import Item
from item import Treasure
from item import LightSource
from monster import Monster

room = {
    'outside':
    Room("Outside Cave Entrance", "North of you, the cave mounth beckons.", [
        Item('sword', 'looks sharp'),
        LightSource("lamp", 'good source of light'),
        Treasure('goldbag', 'looks like a small bag of gold', 50)
    ]),
    'foyer':
    Room(
        "Foyer", """Dim light filters in from the south. Dusty
passages run north and east.""", []),
    'overlook':
    Room(
        "Grand Overlook", """A steep cliff appears before you, falling
into the darkness. Ahead to the north, a light flickers in
the distance, but there is no way across the chasm.""", [
            Item('key', 'looks important'),
            Item('rope', 'looks sturdy'),
            Treasure('beans', 'they appear to be magical beans', 20)
        ]),
    'narrow':
    Room(
        "Narrow Passage", """The narrow passage bends here from west
示例#30
0
# Declare all items:
items = {}
items['rocks'] = Item('rocks', 'good as weapon and building a fort')
items['gloves'] = Item(
    'gloves', 'good to keep warm, climb and not leave fingerprints')
items['hammer'] = Item(
    'hammer', 'good for building stuff, breaking stuff and of course a weapon')
items['flashlight'] = LightSource('flashlight', 'light source and a weapon')
items['carabiner'] = Item('carabiner', 'good for climbing and hanging')
items['rope'] = Item('rope', 'good for climbing and hanging and a weapon')
items['snowboard'] = Item('snowboard', 'in case you have to jet')
items['mushies'] = Item('mushies', 'good as weapon and to spread the love')
items['tent'] = Item('tent', 'good for camping, sleeping and sexing')
items['hashies'] = Item('hashies', 'good for a party and to spark it up')
items['mollys'] = Item('mollys', 'good for a party and to spread the love')
items['gold'] = Treasure(
    'gold', 'trading. A good find.. worth 256 duckets!', 256)
items['silver'] = Treasure(
    'silver', 'trading. Scored some silver coins worth 8 duckets each', 8)
items['titanium'] = Treasure(
    'titanium', 'trading. The most valuable coin.. worth 512 duckets!!', 512)


# Declare all the rooms
room = {
    'outside':  Room("Outside Cave Entrance",
                     "North of you, the cave mount beckons", [items['rocks'], items['gloves'], items['flashlight']], True),
    'foyer':    Room("Foyer", """Dim light filters in from the south. Dusty
passages run north and east.""", [items['hammer'], items['rope']], False),

    'overlook': Room("Grand Overlook", """A steep cliff appears before you, falling
into the darkness. Ahead to the north, a light flickers in