示例#1
0
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)

book = Item("book")
dining_hall.add_items(book)


# define characters and enemies
mike = Character("Mike", "a computer programmer")
mike.conversation = ["You never know when you could use some cheese.", "And you can't use cheese after you've eaten it."]
mike.QA = ({"what", "favorite", "language"}, "Python, of course!")
kitchen.inhabitants.add(mike)
示例#2
0
def go(string):
    if string.lower() not in player.location.exitNames():
        print("Invalid direction.")
        enter()
        return [False,False]
    else:
        if player.location.getDestination(string).lock == False: #if room is unlocked
            player.goDirection(string)
            #full health when entering the hospital
            if player.location.name == "Hospital Wing":
                if player.health != player.maxhealth:
                    player.health=player.maxhealth    
                    print("You get the nurse to heal your wounds.")
            #full mana when entering the trophy room
            if player.location.name == "Trophy Room":
                print("Seeing all these past Hogwarts legends really lifts your spirits.")
                print("Your health and mana fully restore.")
                if player.boost==False:
                    print()
                    print("You notice something in one of the trophy cases.")
                    temp=Container("Trophy Case",False)
                    temp.putInRoom(player.location,1)
                    temp.addItem(Key("Magic Key", "This is a single-use key that can unlock most doors.", 1),1)
                    temp.addItem(Item("Coin", "This is money.", 0),20)
                    player.boost=True
                enter()
            #related to q2, step 2
            if player.location.name == "Greenhouse" and quest.q2.active:
                if quest.q2step2finished == False:
                    quest.q2step2finished = True
                    quest.q2.nextStep()
            #related to q3, step 2
            if player.location.name == "Umbridge's Office" and quest.q3.active:
                if quest.q3step2finished == False:
                    quest.q3step2finished = True
                    quest.q3.nextStep()
            #related to q3, step 1
            if player.location.name == "Potions Classroom" and quest.q7.active:
                if quest.q7step1finished == False:
                    quest.q7step1finished = True
                    quest.q7.nextStep()
            return [True,True]
        #related to q5, step 3. Can enter the water only when player has gillyweed.
        gw = player.getItemByName("Gillyweed")
        if gw and string.lower() == "into the water":
            player.items.remove(gw)
            player.goDirection(string)
            return [True, True]
        elif not gw and string.lower() == "into the water":
            print("Probably not a good idea.")
            enter()
            return [False, False]
        else: #if room is locked
            print(player.location.getDestination(string).name + " is locked.")
            unlock=False
            for i in range(len(player.items)):
                if player.items[i].key==True:
                    temp=input("Unlock with a key? ")
                    if temp.lower()=="yes":
                        unlock=True
                        player.use(player.items[i], player.location.getDestination(string).name)
                    else:
                        unlock=False
                    break
            if unlock==True:
                return go(string)
            else:
                return [False,False]
示例#3
0
文件: trakt.py 项目: XesIhma/Trakt
				i_body = input()
				temp_item = Jewellery(name, description, x, y, z, loc, weight, price, body=i_body)
			elif command[1] == "machine" or command[1] == "mc":
				temp_item = Machine(name, description, x, y, z, loc, weight, price)
			elif command[1] == "vehicle" or command[1] == "vc":	
				print("Strength req: ", end="")
				i_str_r = int(input())
				print("Speed min: ", end="")
				i_spd_min = int(input())
				temp_item = Vehicle(name, description, x, y, z, loc, weight, price, str_r=i_str_r, spd_min=i_spd_min)
			elif command[1] == "container" or command[1] == "ct":	
				print("Capacity: ", end="")
				i_cap = float(input())
				print("Liquids: ", end="")
				i_liquids = bool(input())
				temp_item = Container(name, description, x, y, z, loc, weight, price, capacity=i_cap, liquids=i_liquids)
			elif command[1] == "furniture" or command[1] == "fu":	
				print("Openable: ", end="")
				i_open = bool(input())
				temp_item = Furniture(name, description, x, y, z, loc, weight, price, open=i_open)
			elif command[1] == "heap" or command[1] == "hp":
				temp_item = Heap(name, description, x, y, z, loc, weight, price)
			game.items.append(temp_item)
			print("Stworzyłeś przedmiot: "+ temp_item.name)
		else:
			print("Nie możesz tego zrobić")
	
	elif command[0] == "insert":
		if game.god_mode == True:
			temp_item = game.find_item(command, False)
			if temp_item:
示例#4
0
def createWorld(firstgenerate=True):
    ### ITEMS ###
    i = Item("Rock", "This is just a rock.", 10)
    i2 = Key("Magic Key", "This is a single-use key that can unlock most doors.", 1)
    i3 = Item("Coin", "This is money.", 0)
    i4 = Spellbook("Stupefy",2,15, 1)
    i5 = Container("Seed Box" , False)
    i6 = Item("Squill Bulb", "This is an ingredient for Felix Felicis.",0)
    i7 = Item("Squill Seed", "This can grow into a squill bulb.",0)
    i8 = Item("Bucket of Water", "Looks wet!", 2)
    i9 = Item("Pail of Dirt", "Looks dirty.", 2)
    i10= Container("Locked Box", True,"Box")
    i11= Consumable("Potion of Healing and Mana restore","This kind of does everything. +10 Health +5 Mana",1,10,5)
    i12= Consumable("Raw Meat","... I guess you could eat this? +4 Health",1, 4, 0)
    i13= Item("Werewolf Hide", "Maybe this does something?", 0)
    i14= Consumable("Small Health Potion","A small potion. +10 Health",1,10,0)
    i15= Container("Box", False)
    i16= Consumable("Chocolate Frogs", "Looks tasty! +15 Health",1,15,0)
    i17= Consumable("Butterbeer", "Nothing better than a cold butterbeer. +5 Mana",1,0,5)
    i18 = Container("Desk", False)
    i19 = Item("Occamy Eggshell", "This is an ingredient for Felix Felicis.", 0)
    i20= Consumable("Health Potion", "A health potion.  +25 Health",1,25,0)
    i21= Spellbook("Hex",2,20,1)
    i22= Consumable("Mana Potion", "A mana potion.  +5 Mana",1,0,5)
    i23= Item("Vial of Water", "Use to craft potions!",1)
    i24= Item("Rat Tail","Use (with a vial of water) to craft a health potion.",1)
    i25 = Item("Gillyweed", "Yummy.", 1)
    i26= Item("Pixie Dust","Use (with a vial of water) to craft a mana potion.",1)
    i27 = Item("Murtlap Tentacle", "This is an ingredient for Felix Felicis.", 0)
    b2 = Book("Crafting Common Items", "An introductory course in crafting.",["Rat Tail + Vial of Water = Health potion","Pixie dust + Vial of Water = Mana potion"],1)
    i28 = Item("Powdered Common Rue", "This is an ingredient for Felix Felicis.",0)
    t1 = Item("Tincture of Thyme", "This is an ingredient for Felix Felicis.", 0)
    i29 = Item("Felix Felicis", "A luck potion.",0)
    i30 = Item("Unicorn Blood", "Don't drink it.", 1)
    i31 = Container("Trophy Case",False)
    i32 = Item("Feather", "This dropped from an owl",0)
    i33 = Item("Weed", "Apparantly the Dark Forest doesn't have a gardener.",0)
    i34 = Item("Rock", "This rock looks strangly like Bob the Monster",5)
    ### LOOT TABLES ###     L1.add(item, chance, quantity), chance between 0 and 1
    # Spiders #
    L1=LootTable()
    L1.addItem(i12,.8,1)
    L1.addItem(i3,.8,12)
    L1.addItem(i2,.1,1)
    L1.addItem(i20,.6,2)
    # Werewolves #
    L2=LootTable()
    L2.addItem(i13,1,1)
    L2.addItem(i3,.9,18)
    L2.addItem(i2,.1,1)
    L2.addItem(i14,.4,2)
    L2.addItem(i20,.8,1)
    # Rats #
    L3=LootTable()
    L3.addItem(i3,.9,3)
    L3.addItem(i12,.6,1)
    L3.addItem(i14,.5,1)
    L3.addItem(i2,.1,1)
    L3.addItem(i24,1,1)
    # Pixies #
    L4=LootTable()
    L4.addItem(i21,.3,1)
    L4.addItem(i2,.1,1)
    L4.addItem(i3,.7,15)
    L4.addItem(i20,.4,2)
    L4.addItem(i22,.7,1)
    L4.addItem(i26,1,1)
    if quest.q4 in quest.questLog and not quest.q4pixies:
        L4.addItem(i25,1,1)
        quest.q4pixies=True
    # The Murtlap #
    L5=LootTable()
    L5.addItem(i2,.1,1)
    L5.addItem(i3,1,20)
    L5.addItem(i20,.8,2)
    L5.addItem(i27,1,1)
    ### MONSTERS ###     #Monster(name, health, damage, loottable), moveTo(room) also adds to room
    M1=Monster("Giant Spider",20,8,L1)
    M2=Monster("Werewolf",30,5,L2)
    M3=Monster("Rat",15,3,L3)
    M4=Monster("Pixie",12,10,L4)
    M5=Monster("Murtlap",25,10,L5)
    if firstgenerate == True: #create the map only once, else run update functions
        ### ROOMS ###
        r1 = Room("Entrance Hall", "You are in the Entrance Hall.", False)
        r2 = Room("Great Hall", "You are in the Great Hall.", False)
        r3 = Room("Trophy Room", "You are in trophy room.", False)
        r4 = Room("Entrance Courtyard", "You are in the Entrance Courtyard.", False)
        r5 = Room("Boat House", "You are in the boat house.", True)
        r6 = Room("Dungeon", "You are in the dungeon.", True)
        r7 = Room("Moving Staircase (Level 1)", "You are by the moving staircase (level 1).", False)
        r8 = Room("Moving Staircase (Level 2)", "You are by the moving staircase (level 2).", False)
        r9 = Room("Moving Staircase (Level 3)", "You are by the moving staircase (level 3).", False)
        r10 = Room("Moving Staircase (Level 4)", "You are by the moving staircase (level 4).", False)
        r11 = Room("Moving Staircase (Level 5)", "You are by the moving staircase (level 5).", False)
        r12 = Room("Moving Staircase (Level 6)", "You are by the moving staircase (level 6).", False)
        r13 = Room("Defense Against the Dark Arts Classroom", "You are in the Defense Against the Dark Arts classroom.", False)
        r14 = Room("Umbridge's Office", "You are in Umbridge's office. You hope Umbridge doesn't find you here.", True)
        r15 = Room("Hospital Wing", "You are in the hospital wing.", False)
        r16 = Room("Clock Tower", "You are in the clock tower.", False)
        r17 = Room("Clock Tower Courtyard", "You are in the clock tower courtyard.", False)
        r18 = Room("Stone Circle", "You are in the stone circle. Creepy.", False)
        r19 = Room("Hagrid's Hut", "You are in Hagrid's hut.", False)
        r20 = autogenerateForest(r19)
        r21 = Room("Owlery", "You are in the owlery.", False)
        r22 = Room("Prefect's Bathroom", "You are in the prefect's bathroom.", False)
        r23 = Room("Room of Rewards", "You are in the Room of Rewards.", False)
        r24 = Room("Divination Classroom", "You are in the Divination classroom.", False)
        r25 = Room("Room of Requirement", "You are in the Room of Requirement.", True)
        r26 = Room("Stone Bridge", "You are on the stone bridge.", False)
        r27 = Room("Library", "You are in the library.", False)
        r28 = Room("Transfiguration Courtyard", "You are in the transfiguration courtyard.", False)
        r29 = Room("Greenhouse", "You are in the greenhouse.", False)
        r30 = Room("Myrtle's Bathroom", "You are in Myrtle's bathroom. I won't ask you why.", False)
        r31 = Room("Charms Classroom", "You are in the Charms classroom.", False)
        r32 = Room("Viaduct", "You are on the viaduct.", False)
        r33 = Room("Entrance to the Viaduct", "You are at the entrance the viaduct.", False)
        r34 = Room("Potions Classroom", "You are in the Potions classroom.", False)
        r35 = Room("Gryffindor Common Room", "You are in the Gryffindor Common Room.", False)
        r36 = Room("Water", "You are in the water!", True)
        ### CONNECT ROOMS ###
        Room.connectRooms(r1, "west", r2, "east")
        Room.connectRooms(r2, "south", r3, "north")
        Room.connectRooms(r1, "east", r4, "west")
        Room.connectRooms(r4, "south", r5, "north")
        Room.connectRooms(r1, "north", r7, "south")
        Room.connectRooms(r7, "downstairs", r6, "upstairs")
        Room.connectRooms(r7, "upstairs", r8, "downstairs")
        Room.connectRooms(r8, "upstairs", r9, "downstairs")
        Room.connectRooms(r9, "upstairs", r10, "downstairs")
        Room.connectRooms(r10, "upstairs", r11, "downstairs")
        Room.connectRooms(r11, "upstairs", r12, "downstairs")
        Room.connectRooms(r8, "east", r13, "west")
        Room.connectRooms(r13, "upstairs", r14, "downstairs")
        Room.connectRooms(r9, "south", r15, "north")
        Room.connectRooms(r15, "west", r16, "east")
        Room.connectRooms(r16, "west", r17, "east")
        Room.connectRooms(r17, "west", r18, "east")
        Room.connectRooms(r18, "south", r19, "north")
        Room.connectRooms(r18, "north", r21, "south")
        Room.connectRooms(r10, "west", r22, "east")
        Room.connectRooms(r11, "west", r23, "east")
        Room.connectRooms(r12, "west", r24, "east")
        Room.connectRooms(r12, "north", r25, "south")
        Room.connectRooms(r7, "north", r26, "south")
        Room.connectRooms(r26, "north", r28, "south")
        Room.connectRooms(r28, "north", r29, "south")
        Room.connectRooms(r8, "north", r27, "south")
        Room.connectRooms(r8, "south", r30, "north")
        Room.connectRooms(r8, "west", r31, "east")
        Room.connectRooms(r4, "east", r32, "west")
        Room.connectRooms(r32, "east", r33, "west")
        Room.connectRooms(r33, "downstairs", r34, "upstairs")
        Room.connectRooms(r12, "east", r35, "west")
        Room.connectRooms(r5, "into the water", r36, "out of the water")
        ### NPCS ###
        n1 = npc.Hermione("Hermione", {})
        n2 = npc.Librarian("Librarian", {})
        n3 = npc.Centaur("Centaur", {})
        n4 = npc.Hagrid("Hagrid", {})
        n5 = npc.Ron("Ron", {"Coin":50})
        n6 = npc.HoodedCreature("Hooded Creature",{"Unicorn Blood":1})
        n7 = npc.Luna("Luna", {})
        n8 = npc.Umbridge("Umbridge", {})
        n9 = npc.Harry("Harry", {})
        ### RECIPES ###
        makeRecipe("Squill Bulb", [i7,i8,i9,i6])
        makeRecipe("Health Potion",[i23,i24,i20])
        makeRecipe("Mana Potion",[i23,i26,i22])
        makeRecipe("Felix Felicis",[i27,i28,i19,i6,t1,i29])
        ### PLACEMENT OF ITEMS, NPCS, PLAYER ###
        player.location = r1
        i16.putInRoom(r2, 2)
        i17.putInRoom(r2,1)
        i2.putInRoom(r1,1)
        n1.putInRoom(r1)
        n2.putInRoom(r27)
        i5.putInRoom(r29, 1)
        b2.putInRoom(r34,1)
        b2.putInRoom(r27,1)
        i8.putInRoom(r30,1)
        i8.putInRoom(r34,1)
        i8.putInRoom(r22,1)
        i9.putInRoom(r28,1)
        i5.addItem(i7,1)
        i4.putInRoom(r31,1)
        n4.putInRoom(r19)
        i18.putInRoom(r14, 1)
        n5.putInRoom(r35)
        i28.putInRoom(r34,1)
        n7.putInRoom(r16)
        n9.putInRoom(r25)
        i32.putInRoom(r21,random.randint(0,8))
        classlist=[r13,r23,r24,r27,r28,r31,r34] #possible rooms to put containers
        containerlist=[]
        for i in classlist: #put containers in rooms randomly
            if random.random()<.8:
                containerlist.append(Container("Box", False))
                containerlist[-1].putInRoom(i,1)
        keysleft=5 #up to five keys in all containers
        for i in containerlist: #put items in containers randomly
            quantity=int(15*random.random())    #Number of coins to put in container
            i.addItem(i3,quantity)
            if keysleft>0:  #If we haven't given out 5 keys yet, potentially put 1 in the container
                quantity=int(2*random.random()-.001)
                i.addItem(i2,quantity)
                keysleft-=1
            if random.random()<.7:      #Other items to maybe add to containers randomly
                i.addItem(i14,1)
            if random.random()<.4:
                i.addItem(i23,1)
        for i in forestrooms:       #Adding certain items to rooms i the forest randomly ("Rocks" and "Weeds")
            if random.random()<.1:
                i33.putInRoom(i,1)
            if random.random()<.1:
                i34.putInRoom(i,random.randint(1,2))
    ### THINGS THAT GET UPDATED ###
    else:
        if time.getCount()%5==0:        #Spawns monsters in the forest periodically
            count=0
            for i in monsterlist:
                if i.room in forestrooms:
                    count+=1
            if count<10:
                templist=[]
                if random.random()<.5:
                    templist.append(Monster("Giant Spider",20,8,L1))
                else:
                    templist.append(Monster("Werewolf",30,5,L2))
                templist[0].moveTo(random.choice(forestrooms))
        if time.getCount()%10==0:       #Spawns monsters in the castle periodically
            searching=True
            while searching:
                i=random.choice(rooms)
                if i not in forestrooms:
                    target=i
                    break
            templist=[]
            ratcounter=0
            pixiecounter=0
            murtlap=False
            for i in monsterlist:
                if i.name.lower()=="rat":
                    ratcounter+=1
                elif i.name.lower()=="pixie":
                    pixiecounter+=1
                elif i.name.lower()=="murtlap":
                    murtlap=True
            if random.random()<.8 and ratcounter<20:
                templist.append(Monster("Rat",15,3,L3))
            elif pixiecounter<5:
                templist.append(Monster("Pixie",12,10,L4))
            if templist!=[]:
                templist[-1].moveTo(target)
            if not murtlap:
                templist.append(Monster("Murtlap",25,10,L5))
                templist[-1].moveTo(Room.getRoomByName("Water"))
        #unicorn blood appears in the Dark Forest only when you need it for quest 6.
        if quest.q6.stepNum==2 and quest.q6unicornblood==False:
            for i in forestrooms:
                if i.name.lower()=="dark forest":
                    templist=[]
                    templist.append(Item("Unicorn Blood", "Don't drink it.", 1))
                    templist[0].putInRoom(i,1)
                    quest.q6unicornblood=True    
                    break
        #the occamy eggshell appears in in Umbridge's office only when you need it for quest 3.
        if quest.q3.active and not quest.q3occamyegg:
            target=Room.getRoomByName("Umbridge's Office")
            container=target.getItemByName("Desk")
            container.addItem(i19,1)
            quest.q3occamyegg=True
        #gillyweed appears in the prefect's bathroom only when you need it for quest 5.
        if quest.q5.active and not quest.q5gillyweed:
            target=Room.getRoomByName("Prefect's Bathroom")
            i25.putInRoom(target, 1)
            quest.q5gillyweed=True
        #If Umbridge is in the same room as you, she sends you to the Gryffindor Common Room.
        umbridge=player.location.getNPCByName("Umbridge")
        if umbridge!=False:
            player.location=Room.getRoomByName("Gryffindor Common Room")
            print("Umbridge sends you back to your commmon room.  You're not entirely sure why.")
            enter()
            umbridge.remove()
        #Umbridge removes Hagrid from school grounds after quest 5.
        if quest.q5 in quest.questLog:
            for i in rooms:
                hagrid=False
                hagrid=i.getNPCByName("Hagrid")
                if hagrid!=False:
                    i.removeNPC(hagrid)
                    break
示例#5
0
ten_gold = Gold(
    -1,
    "a smattering of 10 gold pieces lies on the cobblestone tile next to the rusty sword.",
    10)

thousand_gold = Gold(
    -1,
    "a pile of 1000 gold pieces is piled high in a treasure chest near something.",
    10)

torch = LightSource(
    0, "torch", "a crude stick with an oil soaked rag at its tip",
    "a torch lies on the floor next to the chest, hastily discarded.", 0, 0, 4)

chest = Container(
    1, "chest",
    "its lock was clearly broken, but there appears to be something inside.",
    "a battered wooden chest sits in the corner", [ten_gold])

rusty_sword = Weapon(
    2, "rusty_sword",
    "rusting, it could probably do better if it were sharpened",
    "a rusty sword lies nearby under a drip somewhere on the cavern's ceiling",
    2, 4)

golden_sword = Weapon(
    3, "golden_sword",
    "This brilliant blade has clearly been well taken care of",
    "a golden sword lies buried to the hilt in a large stone just before the mouth of the chasm",
    2000, 200)

items = [
示例#6
0
rooms['shallow_crossing'].to_e = rooms['bridge_crossing']

rooms['river_delta'].to_e = rooms['river_bank']

rooms['doggo'].to_s = rooms['bridge_crossing']
rooms['bridge_crossing'].to_n = rooms['doggo']

# Add items.
flashlight = Item('flashlight', 'A handy tool to light your way.', weight=5)
flashlight.is_light = True
rooms['rest_stop'].items_[flashlight.name] = flashlight

# Hide an item in a box in the dark in a cave.
# Make a Container.
black_lock_box = Container('black_lock_box',
                           'A sturdy, locked box. It is black',
                           weight=50)

# And something to put in it.
sling_shot = SlingShot(
    'sling_shot',
    'Launches a small stone at high speeds. Pretty accurate, too.',
    weight=5)

# Put the item in the box.
black_lock_box.items_[sling_shot.name] = sling_shot

# Lock the box.
black_lock_box.locked = True

# Be sure to make a key.
示例#7
0
文件: game.py 项目: XesIhma/Trakt
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
示例#8
0
def createWorld():
    #ROOMS
    r1 = Room("Entrance Hall", "You are in the Entrance Hall.", False)
    r2 = Room("Great Hall", "You are in the Great Hall.", False)
    r3 = Room("Trophy Room", "You are in trophy room.", False)
    r4 = Room("Entrance Courtyard", "You are in the Entrance Courtyard.",
              False)
    r5 = Room("Boat House", "You are in the boat house.", True)
    r6 = Room("Dungeon", "You are in the dungeon.", True)
    r7 = Room("Moving Staircase (Level 1)",
              "You are by the moving staircase (level 1).", False)
    r8 = Room("Moving Staircase (Level 2)",
              "You are by the moving staircase (level 2).", False)
    r9 = Room("Moving Staircase (Level 3)",
              "You are by the moving staircase (level 3).", False)
    r10 = Room("Moving Staircase (Level 4)",
               "You are by the moving staircase (level 4).", False)
    r11 = Room("Moving Staircase (Level 5)",
               "You are by the moving staircase (level 5).", False)
    r12 = Room("Moving Staircase (Level 6)",
               "You are by the moving staircase (level 6).", False)
    r13 = Room("Defense Against the Dark Arts Classroom",
               "You are in the Defense Against the Dark Arts classroom.",
               False)
    r14 = Room("Umbridge's Office", "You are in Umbridge's office.", True)
    r15 = Room("Hospital Wing", "You are in the hospital wing.", False)
    r16 = Room("Clock Tower", "You are in the clock tower.", False)
    r17 = Room("Clock Tower Courtyard",
               "You are in the clock tower courtyard.", False)
    r18 = Room("Stone Circle", "You are in the stone circle.", False)
    r19 = Room("Hagrid's Hut", "You are in Hagrid's hut.", True)
    r20 = Room("Dark Forest", "You are in the Dark Forest.", False)
    r21 = Room("Owlery", "You are in the owlery.", False)
    r22 = Room("Prefect's Bathroom", "You are in the prefect's bathroom.",
               False)
    r23 = Room("Room of Rewards", "You are in the Room of Rewards.", False)
    r24 = Room("Divination Classroom", "You are in the Divination classroom.",
               False)
    r25 = Room("Room of Requirement", "You are in the Room of Requirement.",
               True)
    r26 = Room("Stone Bridge", "You are on the stone bridge.", False)
    r27 = Room("Library", "You are in the library.", False)
    r28 = Room("Transfiguration Courtyard",
               "You are in the transfiguration courtyard.", False)
    r29 = Room("Greenhouse", "You are in the greenhouse.", False)
    r30 = Room("Myrtle's Bathroom",
               "You are in Myrtle's bathroom. I won't ask you why.", False)
    r31 = Room("Charms Classroom", "You are in the Charms classroom.", False)
    r32 = Room("Viaduct", "You are on the viaduct.", False)
    r33 = Room("Entrance to the Viaduct",
               "You are at the entrance the viaduct.", False)
    r34 = Room("Potions Classroom", "You are in the Potions classroom.", False)
    r35 = Room("Gryffindor Common Room",
               "You are in the Gryffindor Common Room.", False)
    Room.connectRooms(r1, "west", r2, "east")
    Room.connectRooms(r2, "south", r3, "north")
    Room.connectRooms(r1, "east", r4, "west")
    Room.connectRooms(r4, "south", r5, "north")
    Room.connectRooms(r1, "north", r7, "south")
    Room.connectRooms(r7, "downstairs", r6, "upstairs")
    Room.connectRooms(r7, "upstairs", r8, "downstairs")
    Room.connectRooms(r8, "upstairs", r9, "downstairs")
    Room.connectRooms(r9, "upstairs", r10, "downstairs")
    Room.connectRooms(r10, "upstairs", r11, "downstairs")
    Room.connectRooms(r11, "upstairs", r12, "downstairs")
    Room.connectRooms(r8, "east", r13, "west")
    Room.connectRooms(r13, "upstairs", r14, "downstairs")
    Room.connectRooms(r9, "south", r15, "north")
    Room.connectRooms(r15, "west", r16, "east")
    Room.connectRooms(r16, "west", r17, "east")
    Room.connectRooms(r17, "west", r18, "east")
    Room.connectRooms(r18, "south", r19, "north")
    Room.connectRooms(r19, "west", r20, "east")
    Room.connectRooms(r18, "north", r21, "south")
    Room.connectRooms(r10, "west", r22, "east")
    Room.connectRooms(r11, "west", r23, "east")
    Room.connectRooms(r12, "west", r24, "east")
    Room.connectRooms(r12, "north", r25, "south")
    Room.connectRooms(r7, "north", r26, "south")
    Room.connectRooms(r26, "north", r28, "south")
    Room.connectRooms(r28, "north", r29, "south")
    Room.connectRooms(r8, "north", r27, "south")
    Room.connectRooms(r8, "south", r30, "north")
    Room.connectRooms(r8, "west", r31, "east")
    Room.connectRooms(r4, "east", r32, "west")
    Room.connectRooms(r32, "east", r33, "west")
    Room.connectRooms(r33, "downstairs", r34, "upstairs")
    Room.connectRooms(r12, "east", r35, "west")
    autogenerateForest(r19)
    #ITEMS
    i = Item("Rock", "This is just a rock.", 10)
    i2 = Key("Magic Key",
             "This is a single-use key that can unlock most doors.", 1)
    i3 = Item("Coin", "This is money.", 0)
    i4 = Spellbook("Stupefy", 2, 10, 1)
    i5 = Container("Box", False)
    i6 = Item("Squill Bulb", "An ingrediant for Felix Felicis", 0)
    i7 = Item("Squill Seed", "This can grow into a Squill Bulb", 0)
    i8 = Item("Bucket of Water", "This looks wet!", 2)
    i9 = Item("Pail of Dirt", "Looks dirty͡°).", 2)
    i10 = Container("Locked Box", True, "Box")
    i11 = Consumable("Potion of Healing and Mana restore",
                     "This kind of does everything", 1, 10, 5)
    i12 = Consumable("Raw Meat", "... I guess you could eat this?", 1, 4, 0)
    #NPCS
    n1 = npc.Hermione("Hermione")
    n2 = npc.Librarian("Librarian")
    #MONSTERS
    l1 = LootTable()
    l1.addItem(i3, .5, 6)
    l1.addItem(i, .3, 1)
    l1.addItem(i12, 1, 1)
    c = Monster("Bob the Monster", 20, r1, 5, l1)
    #RECIPES
    makeRecipe("Squill Bulb", [i7, i8, i9, i6])
    #PLACEMENT
    for elephant in range(4):
        player.items.append(i3)
    i.putInRoom(r2, 2)
    i2.putInRoom(r1, 3)
    i.putInRoom(r1, 10)
    #i4.putInRoom(r1,1)
    n1.putInRoom(r1)
    n2.putInRoom(r27)
    i5.putInRoom(r29, 1)
    player.location = r1
    i8.putInRoom(r30, 1)
    i9.putInRoom(r28, 1)
    i5.addItem(i7, 1)
    i10.putInRoom(r1, 1)
    i10.addItem(i3, 10)
    i11.putInRoom(r1, 1)
    i4.putInRoom(r1, 1)