def generateItem():
    fud = [
        Food(1, 'apple', 1),
        Garbage(15, 'tin can', 1),
        Garbage(16, 'aluminum can', 2)
    ]
    room = 1
    while room < 101:
        for x in fud:
            item = Item(name=x.name, room_num=room)
            item = Item(name=x.name, room_num=room)
            item = Item(name=x.name, room_num=room)

            db.session.add(item)

            db.session.commit()
        room += 1
    return {}
Beispiel #2
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'].connectRooms(room['foyer'], 'n')
room['foyer'].connectRooms(room['overlook'], 'n')
room['foyer'].connectRooms(room['narrow'], 'e')
room['narrow'].connectRooms(room['treasure'], 'n')

rock = Item('rock', 'large, grey boulder near the entrance to the cave.')
pizza = Food('pizza', 'pepperoni pizza', 1000)

room['outside'].addItem(rock)
room['foyer'].addItem(pizza)


def printErrorString(errorString):
    print("\n{}\n".format(errorString))
    global noPrint
    noPrint = True


validDirection = ['n', 's', 'e', 'w']
noPrint = False
current_room = room['outside']
user_character = player['default_character']
Beispiel #3
0
def set_items(path, world):
    items = []
    with open(path, "r", encoding='utf-8') as f:
        data = json.loads(f.read())
        for i in range(len(data)):
            class_name = data[i]['class']
            name = data[i]['name']
            description = data[i]['description']
            weight = data[i]['weight']
            price = data[i]['price']
            x = data[i]['x']
            y = data[i]['y']
            z = data[i]['z']
            loc = world
            item_id = data[i]['id']
            if class_name == "Food":
                temp_item = Food(name, description, x, y, z, loc, weight,
                                 price, data[i]['nourish'],
                                 data[i]['stamina_suppl'])
                items.append(temp_item)
            elif class_name == "Drink":
                temp_item = Drink(name, description, x, y, z, loc, weight,
                                  price, data[i]['nourish'],
                                  data[i]['stamina_suppl'], data[i]['alcohol'])
                items.append(temp_item)
            elif class_name == "Heals":
                temp_item = Heals(name, description, x, y, z, loc, weight,
                                  price, data[i]['hp_suppl'])
                items.append(temp_item)
            elif class_name == "Elixir":
                temp_item = Elixir(name,
                                   description,
                                   x,
                                   y,
                                   z,
                                   loc,
                                   weight,
                                   price,
                                   data[i]['duration'],
                                   hp_sup=data[i]["hp_sup"],
                                   st_av_sup=data[i]["st_av_sup"],
                                   st_sup=data[i]["st_sup"],
                                   mn_sup=data[i]["mn_sup"],
                                   str=data[i]["str"],
                                   agl=data[i]["agl"],
                                   spd=data[i]["spd"],
                                   dfc=data[i]["dfc"],
                                   per=data[i]["per"],
                                   stl=data[i]["stl"],
                                   hp_b=data[i]["hp_b"],
                                   mn_b=data[i]["mn_b"])
                items.append(temp_item)
            elif class_name == "CloseRange":
                temp_item = CloseRange(name,
                                       description,
                                       x,
                                       y,
                                       z,
                                       loc,
                                       weight,
                                       price,
                                       w_type=data[i]['type'],
                                       dm=data[i]['damage'],
                                       str_r=data[i]['strength_req'],
                                       agl_r=data[i]['agility_req'],
                                       skill_r=0,
                                       though=data[i]['thoughness'],
                                       cut=data[i]['cut'],
                                       stab=data[i]['stab'],
                                       crush=data[i]['crush'],
                                       block=data[i]['block'])
                items.append(temp_item)
            elif class_name == "Ranged":
                temp_item = Ranged(name,
                                   description,
                                   x,
                                   y,
                                   z,
                                   loc,
                                   weight,
                                   price,
                                   w_type=data[i]['type'],
                                   dm=data[i]['damage'],
                                   str_r=data[i]['strength_req'],
                                   agl_r=data[i]['agility_req'],
                                   skill_r=0,
                                   ammo_type=data[i]['ammo_type'],
                                   range=data[i]['range'])
                items.append(temp_item)
            elif class_name == "Armor":
                temp_item = Armor(name,
                                  description,
                                  x,
                                  y,
                                  z,
                                  loc,
                                  weight,
                                  price,
                                  body=data[i]['body_part'],
                                  material=data[i]['material'],
                                  defe=data[i]['defence'],
                                  str_r=data[i]['strength_req'],
                                  agl_min=data[i]['agility_minus'],
                                  spd_min=data[i]['speed_minus'])
                items.append(temp_item)
            elif class_name == "Shield":
                temp_item = Shield(name,
                                   description,
                                   x,
                                   y,
                                   z,
                                   loc,
                                   weight,
                                   price,
                                   body=data[i]['body_part'],
                                   material=data[i]['material'],
                                   defe=data[i]['defence'],
                                   str_r=data[i]['strength_req'],
                                   agl_min=data[i]['agility_minus'],
                                   spd_min=data[i]['speed_minus'])
                items.append(temp_item)
            elif class_name == "Clothes":
                temp_item = Clothes(name,
                                    description,
                                    x,
                                    y,
                                    z,
                                    loc,
                                    weight,
                                    price,
                                    body=data[i]['body_part'],
                                    cold=data[i]['cold_protection'],
                                    water=data[i]['water_protection'])
                items.append(temp_item)
            elif class_name == "Tool":
                temp_item = Tool(name, description, x, y, z, loc, weight,
                                 price)
                items.append(temp_item)
            elif class_name == "Jewellery":
                temp_item = Jewellery(name,
                                      description,
                                      x,
                                      y,
                                      z,
                                      loc,
                                      weight,
                                      price,
                                      body=data[i]['body_part'])
                items.append(temp_item)
            elif class_name == "Machine":
                temp_item = Machine(name, description, x, y, z, loc, weight,
                                    price)
                items.append(temp_item)
            elif class_name == "Vehicle":
                temp_item = Vehicle(name,
                                    description,
                                    x,
                                    y,
                                    z,
                                    loc,
                                    weight,
                                    price,
                                    str_r=data[i]['strength_req'],
                                    spd_min=data[i]['speed_minus'])
                items.append(temp_item)
            elif class_name == "Container":
                temp_item = Container(name,
                                      description,
                                      x,
                                      y,
                                      z,
                                      loc,
                                      weight,
                                      price,
                                      capacity=data[i]['capacity'],
                                      liquids=data[i]['for_liquids'])
                items.append(temp_item)
            elif class_name == "Furniture":
                temp_item = Furniture(name,
                                      description,
                                      x,
                                      y,
                                      z,
                                      loc,
                                      weight,
                                      price,
                                      open=data[i]['openable'])
                items.append(temp_item)
            elif class_name == "Heap":
                temp_item = Heap(name, description, x, y, z, loc, weight,
                                 price)
                items.append(temp_item)
    return items
Beispiel #4
0
room["treasure"].s_to = room["narrow"]

# %%
# === Instantiate items === #
helmet = Armor("Helmet", "Protects the noggin", effect=9)
gauntlets = Armor("Gauntlets", "Protects the hands/wrists", effect=3)
boots = Armor("Boots", "Protects the feet/ankles", effect=4)
shield = Armor("Shield", "All around protection", effect=5)
sword = Weapon("Sword", "Good for close combat encounters", effect=6)
bow = Weapon("Bow", "Good for long-range attacks", effect=3, requires="Arrow")
arrow = Weapon("Arrow", "Missile shot by bow", effect=4, requires="Bow")
dagger = Weapon("Dagger", "Good for close quarters", effect=2)
potion1 = Medicine("Potion", "May help, may hurt", effect=-12)
potion2 = Medicine("Potion", "May help, may hurt", effect=-2)
potion3 = Medicine("Potion", "May help, may hurt", effect=20)
jerky = Food("Jerky", "A nice slab of jerky", effect=2)
gem1 = Artifact("Gem", "A sparkling gem", ability="confidence", effect=1)
gem2 = Artifact("Gem", "A sparkling gem", ability="confidence", effect=1)

# === Add items to rooms === #
room["outside"].add_item(helmet)
room["foyer"].add_item(gauntlets)
room["foyer"].add_item(arrow)
room["foyer"].add_item(potion2)
room["narrow"].add_item(sword)
room["narrow"].add_item(potion1)
room["overlook"].add_item(bow)
room["overlook"].add_item(jerky)
room["overlook"].add_item(potion3)
room["treasure"].add_item(shield)
room["treasure"].add_item(gem1)
Beispiel #5
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']

# Create Items
gold_small = Money('Money - S', 'Small Pile of Gold', 15, 'Gold Coins')
gold_medium = Money('Money - M', 'Medium Pile of Gold', 50, 'Gold Coins')
gold_large = Money('Money - L', 'Large Pile of Gold', 100, 'Gold Coins')
print('!!! XXX !!!', gold_small)
print('!!! XXX !!!', gold_medium)
print('!!! XXX !!!', gold_large)

carrot = Food('Carrot', 'Crunchy and good for you', '14 pounds', 3)
taco_softShell = Food('Taco', 'FREE TACO OMG!!!!!!!!...oh its shoft shell...',
                      '3 soft shell', 1000)
taco_hardShell = Food('Taco',
                      'FREE TACO OMG!!!!!!!!...AND ITS A REAL TACO SHELL',
                      '3 hard shell', 5000)
print('!!! XXX !!!', carrot)
print('!!! XXX !!!', taco_softShell)
print('!!! XXX !!!', taco_hardShell)

# Add Items to Rooms
room['outside'].items = [gold_small, carrot]
room['foyer'].items = [carrot]
room['overlook'].items = [gold_large, taco_hardShell]
room['narrow'].items = [taco_softShell]
room['treasure'].items = [carrot]
Beispiel #6
0
chamber! Sadly, it has already been completely emptied by
earlier adventurers. The only exit is to the south.""",
    ),
}
# 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"]
rock1 = Item("Rock", "This is a rock.")
big_rock = Item("Big Rock", "This is a big rock.")
bread = Food("Bread", "This is a loaf of bread.", 100)
egg = Egg()
playerStartingItems = [rock1]
room["outside"].addItem(big_rock)
room["foyer"].addItem(bread)
room["treasure"].addItem(egg)
valid_directions = {
    "n": "n",
    "s": "s",
    "e": "e",
    "w": "w",
    "forward": "n",
    "backwards": "s",
    "right": "e",
    "left": "w",
}
Beispiel #7
0
earlier adventurers. The only exit is to the south."""),
}

# 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']

rock = Item("rock", "This is a rock.")
sandwich = Food("sandwich", "some normal sandwiches", 100)
gun = Gun()
#
# Main
#

room['outside'].items.append(gun)

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

player = Player(input("enter your name: "), room['outside'])
player.items.append(rock)
player.items.append(sandwich)
print(f"Hello , {player.name}")

# Write a loop that:
Beispiel #8
0
from room import Room
from player import Player
from item import Gold
from item import Food

# Declare all the rooms
room = {
    '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.""",
        [Food('banana', 'is a bit bruised', 20),
         Gold(100)]),
    '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."""),
}
Beispiel #9
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']

# Link rooms with item
room['outside'].rock = Item("rock", "This is a rock.")
room['outside'].egg = Egg()
room['foyer'].sandwich = Food("sandwich", "This is a delicious sandwich.", 100)
room['foyer'].ramen = Ramen()

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

player = Player(input("Please enter your name: "), room['outside'])
# player.inventory.append(rock)
# player.inventory.append(sandwich)
# player.inventory.append(egg)
# player.inventory.append(ramen)
print(player.current_room)
Player.print_inventory(player)
# player.eat(rock)
# player.eat(sandwich)
Beispiel #10
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']

# Initialize items
ammo9mm = Item("ammo9mm", "ammunition for 9mm guns")

# Food
ramen = Food("ramen", "a cup of instant noodles", 250)
pizza = Food("pizza", "a box of left over pizza", 300)

# Weapon
knife = Weapon("knife", "a hand knife", 20)
pistol = Weapon("pistol", "9mm pistol", 40)

# Add room items
room['outside'].addItems(ammo9mm, ammo9mm, ammo9mm, ammo9mm, ammo9mm)
room['foyer'].addItems(knife, ramen)
room['overlook'].addItems(ramen, pistol)
room['narrow'].addItems(ammo9mm, ammo9mm, ramen)
room['treasure'].addItems(pizza, pizza, ramen)

#
# Main
Beispiel #11
0
from room import Room
from player import Player
from item import Item, Food
# import cmd
import textwrap
import sys
import os
# import time

# Declare all the items

item = {
    'flashlight': Item("flashlight", "This can be helpful during night time"),
    'knife': Item("knife", "This can help during hard situations"),
    'fish': Food("fish", "Eating this will give you energy", 200),
    'compass': Item("compass", "This will guide on your adventure"),
    'pet': Item("pet", "Your best friend!")
}

# Declare all the rooms

room = {
    'outside':
    Room("Outside Cave Entrance", "North of you, the cave mount beckons",
         "outside", [item['pet'], item['knife']]),
    'foyer':
    Room(
        "Foyer", """Dim light filters in from the south. Dusty
passages run north and east.""", "foyer"),
    'overlook':
    Room(
Beispiel #12
0
narrow_items = [directions.name, flashlight.name]
treasure_items = [chest.name, flashlight.name]
bedroom_items = [pillow.name, flashlight.name, chest.name, directions.name]
dungeon_items = [sword.name, flashlight.name, directions.name]

# Add items to rooms
room['outside'].room_items = outside_items
room['foyer'].room_items = foyer_items
room['overlook'].room_items = overlook_items
room['narrow'].room_items = narrow_items
room['treasure'].room_items = treasure_items
room['bedroom'].room_items = bedroom_items
room['dungeon'].room_items = dungeon_items

#Declare all player inventory items
snacks = Food("snacks", "you might get the munchies", 100)
water = Water("water", """this is going to be a long day, stay hydrated.""", "spring")

#process the 4 directions
def process_directions(choice):

    directions = ["n", "s", "e", "w"]

    if choice == "i" or choice == "inventory":        
       player.display_inventory()
    elif choice in directions:
        player.move_player(choice)  
    else:
        print("I am sorry. We did not understand your request. Please try your request again.")

def process_user_request(parsed_entry):
Beispiel #13
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['overlook'].n_to = room['win_or_lose']
room['narrow'].w_to = room['foyer']
room['narrow'].n_to = room['treasure']
room['treasure'].s_to = room['narrow']

stone = Item('Stone', 'A big stone')
juju = Food('JuJu Bean', 'A mysterious bean', 1000)
sandwich = Food('Sandwich', 'But which sandwich is which?', 500)
berries = Food(
    'Berries',
    "Delicious berries. They're not exactly blueberries, but they are blue berries",
    100)
room['outside'].items.append(stone)
cake = Food('Cake', "A suspicious cake", -500)

room['outside'].items.append(berries)
room['foyer'].items.append(berries)
room['overlook'].items.append(berries)
room['overlook'].items.append(sandwich)
room['narrow'].items.append(berries)
room['treasure'].items.append(juju)
room['treasure'].items.append(cake)
Beispiel #14
0
earlier adventurers. The only exit is to the south."""),
}

# 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']

rock = Item("rock", "This is a rock")
sandwich = Food("sandwich", "This is a delicious sandwich", 100)
stick = Item("stick", "This is a stick")
log = Item("log", "This is a log")
cake = Food("Cake", "This is a cake", 50)
sword = Item("sword", "This is a sword")

room['outside'].items.append(rock)
room['foyer'].items.append(stick)
room['foyer'].items.append(log)
room['foyer'].items.append(rock)
room['treasure'].items.append(cake)
room['treasure'].items.append(sandwich)

#
# Main
#
Beispiel #15
0
import time
from room import Room
from player import Player
from item import Item, Food, Egg, Ramen

rock = Item("rock", "This is a rock.")
egg = Food("egg", "This is an egg", 20)
sandwich = Food("sandwich", "This is a delicious sandwich.", 100)
ramen = Food("ramen", "Delicious - and easy to make!", 25)

room = {
    'outside':
    Room("Outside Cave Entrance", "North of you, the cave mount beckons",
         [["rock", rock], ["egg", egg]]),
    'foyer':
    Room(
        "Foyer", """Dim light filters in from the south. Dusty
passages run north and east.""", [["sandwich", sandwich], ["ramen", ramen]]),
    '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
Beispiel #16
0
        "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.""",
    ),
}

# items = {
#     "water": ,
#     "soda": ,
#     "gun": ,
#     "radio": ,

# }

rooms["outside"].add_items(Food("Watermelon", "It's a watermelon", 20),
                           Food("Rice", "It's rice", 15),
                           Food("Steak", "It's a welldone steak", 40))
rooms["foyer"].add_items(Food("Watermelon", "It's a watermelon", 20),
                         Food("Rice", "It's rice", 15),
                         Food("Steak", "It's a welldone steak", 40))
rooms["overlook"].add_items(Food("Watermelon", "It's a watermelon", 20),
                            Food("Rice", "It's rice", 15),
                            Food("Steak", "It's a welldone steak", 40))
rooms["narrow"].add_items(Food("Watermelon", "It's a watermelon", 20),
                          Food("Rice", "It's rice", 15),
                          Food("Steak", "It's a welldone steak", 40))
rooms["treasure"].add_items(Food("Watermelon", "It's a watermelon", 20),
                            Food("Rice", "It's rice", 15),
                            Food("Steak", "It's a welldone steak", 40))
Beispiel #17
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']

#creating the default items
item = {
    'Cheese': Food('Cheddar', 'Slightly stale but tasty cheese block', 300),
    'Orb': Item('Ender Orb', 'minecraft thing'),
    'waste': Item('Dust', 'some kind of powdering substance..maybe'),
    'other': Item('Yeet', 'This is that good stuff'),
    'Pick': Tool('Iron PickAxe', 'Used to mine', 4.5)
}

#adding defualt items to rooms

room['outside'].set_items(item['Pick'])
room['foyer'].set_items(item['Orb'])
room['overlook'].set_items(item['Cheese'])
room['narrow'].set_items(item['waste'])
room['treasure'].set_items(item['other'])
room['treasure'].set_items(item['other'])
Beispiel #18
0
from player import Player

validDirections = ["n", "s", "e", "w"]

items = {
    'sword':
    Weapon("Sword", "A rusty but useful sword", 15),
    'refined_sword':
    Weapon(
        "Sharpened Sword",
        "A big, brutish sword that has a red tint reflecting off the blade",
        50),
    'torch':
    LightSource("Torch", "A torch that has been lit recently...", 20),
    'bread':
    Food("Bread", "A half eaten loaf", 2, 20),
}

room = {
    'outside':
    Room("Outside Cave Entrance", "North of you, the cave mount beckons",
         None),
    'foyer':
    Room(
        "Foyer", """Dim light filters in from the south. Dusty
passages run north and east.""", items['bread']),
    '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.""", items['sword']),
Beispiel #19
0
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)
spam4 = Food("SpamSpamSpamSpam",
             "I would like some Spam, Spam, Spam, and Spam", 4)
spam5 = Food("SpamSpamSpamSpamSpam",
             "I would like some Spam, Spam, Spam, Spam, and Spam", 5)
eggs = Food("Eggs", "It's a tasty egg.", 1)
bacon = Food("Bacon", "What dreams are made of.", 10)
lantern = LightSource("Lantern",
                      "A lantern that you can light with a fire source.",
                      False)
torch = LightSource("Torch",
                    "A branch with an oil soaked rag wrapped on one end.",
                    False)
flint = Item("Flint",
Beispiel #20
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['foyer'].items.extend([item['cylinder'], item['sword']])

rock = Item("rock", "This is a rock.")
sandwich = Food("sandwich", "This is a delicious sandwich.", 100)
egg = Egg()

#
# Main
#

# Make a new player object that is currently in the 'outside' room.
player = Player(input("Please enter your name: "), room['outside'])
player.items.append(rock)
player.items.append(sandwich)
player.items.append(egg)
print(player.current_room)

# player.eat(rock)
# player.eat(sandwich)
Beispiel #21
0
			description = input()
			print("Weight: ", end="")
			weight = float(input())
			print("Price: ", end="")
			price = int(input())
			x = hero.x
			y = hero.y
			z = hero.z
			loc = hero.current_location
			temp_item = None
			if command[1] == "food" or command[1] == "fo":
				print("Nourish: ", end="")
				nourish = int(input())
				print("Stamina suppl: ", end="")
				stamina_suppl = int(input())
				temp_item = Food(name, description, x, y, z, loc, weight, price, nourish, stamina_suppl)		
			elif command[1] == "drink" or command[1] == "dr":
				print("Nourish: ", end="")
				nourish = int(input())
				print("Stamina suppl: ", end="")
				stamina_suppl = int(input())
				print("Alcohol: ", end="")
				alcohol = int(input())
				temp_item = Drink(name, description, x, y, z, loc, weight, price, nourish, stamina_suppl, alcohol)
			elif command[1] == "heals" or command[1] == "he":
				print("Hp suppl: ", end="")
				hp_suppl = int(input())
				temp_item = Heals(name, description, x, y, z, loc, weight, price, hp_suppl)
			elif command[1] == "elixir" or command[1] == "el":
				print("Duration: ", end="")
				duration = int(input())
Beispiel #22
0
              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(
     "Narrow Passage", """    The narrow passage bends here from west
 to north. The smell of gold permeates the air.""",
     [Food("apple", "a shiny red orb", 5, 10)], False),
 'treasure':
 Room(
     "Treasure Chamber", """    You've found the long-lost treasure
 chamber! Sadly, it has already been completely 
 emptied by earlier adventurers. There is a 
 bookshelf along the north wall. The only exposed 
 exit is to the south. """, [
         Item("leather-bound book", "a mysterious tome with missing pages",
              5)
Beispiel #23
0
# define places
kitchen = Place("Kitchen", "A dank and dirty room buzzing with flies.")
dining_hall = Place("Dining Hall", "A large room with ornate golden decorations on each wall.")
ballroom = Place("Ballroom", "A vast room with a shiny wooden floor.  Huge candlesticks guard the entrance. Stairs lead to a balcony overlooking the ballroom.")
balcony = Place("Balcony", "A balcony surrounding and overlooking the ballroom.  Stairs lead back down to the ballroom floor.")

# link places; parameters are (place to link, "how to get there")
kitchen.link_place(dining_hall, "south")
dining_hall.link_place(kitchen, "north")
dining_hall.link_place(ballroom, "west")
ballroom.link_place(dining_hall, "east")
ballroom.link_place(balcony, "up the stairs")
balcony.link_place(ballroom, "down the stairs")

# define items and their properties
cheese = Food("cheese")
cheese.add_properties("invisible") # because it's in the refrigerator

pizza = Food("pizza")
pizza.add_properties("invisible")  # because it's in the refrigerator

knife = Item("knife")
ballroom.add_items(knife)

refrigerator = Container("refrigerator")
refrigerator.add_properties("too heavy")
refrigerator.add_contents(cheese, pizza)
refrigerator.key = knife

kitchen.add_items(refrigerator, cheese, pizza)
Beispiel #24
0
 def add_items(self, nb_items):
     for _ in range(nb_items):
         self.items[self.empty_spot(
             avoids="SEMX")] = Food()  # All items are food for now
Beispiel #25
0
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.

    Returns the room the player has moved to (or the same room if the player
    didn't move).
    """
    attrib = d + '_to'

    # See if the room has the destination attribute
    if hasattr(currentRoom, attrib):
        # If so, return its value (the next room)
        return getattr(currentRoom, attrib)
Beispiel #26
0
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']

#
# Main
#

# Items
torch = Light("Torch", "a piece of wood with cloth wrapped around the end.",
              False)
apple = Food("Apple", "A juicy red apple", 20)
mushroom = Food("Mushroom", "A brown mushrom", 15)

room['outside'].items = [apple]
room['foyer'].items = [torch, mushroom]

# Make a new player object that is currently in the 'outside' room.
player = Player(input("Enter a name >> ").capitalize(), outside)

# 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.
#
# If the user enters a cardinal direction, attempt to move to the room there.