Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import random, time
- class Item:
- ## upon initiation of the class, this function will run. currently it is only declaring variables
- def __init__(self, function, name, amount):
- ##self. means a variable belonging to this instance of the class
- self.function = function
- self.name = name
- self.amount = amount
- self.total = amount
- print("you found a", self.name, "and you feel accomplished. This item can do:", self.function + ",", self.amount, "times")
- ##this is a method, which you call by doing instance.methodName("parameters")
- def use(self, amount, function):
- if function.lower() == self.function.lower():
- self.amount -= amount
- print(f"you now have {self.amount} uses of {self.name}")
- else:
- print("this item cannot do this!")
- def gain(self, amount):
- if self.amount + amount <= self.total:
- self.amount += amount
- print("you acquired:", amount, "of", self.name, "meaning you now have:", self.amount, "of your", self.total, "uses of", self.name+".")
- else:
- print("you do not have space to hold this!")
- def lose(self, amount):
- self.amount -= amount
- print("you lost", amount, "of", self.name+".")
- def Return(pack, items):
- return (pack, items)
- def begin():
- bpack_items = []
- ## opening statement
- print("welcome to Getharis, a dungeon exploration game in which you will play as Call, an adventurer who still needs his mothers permission to go...")
- print("your mission begins...")
- ##choosing from list
- mc = random.choice(["yes, but be careful Call", "No, you can't go"])
- ##sleeping for one second
- time.sleep(1)
- print("you approach your mother. Adventurer, be careful, for this could be the most dangerous monster you meet upon your quest through Getharis")
- print("you ask your mother if you can go on your adventure...")
- ##displaying motherchoice
- print(f"your mother says: {str(mc)}")
- time.sleep(1)
- ##making choice so that the next line makes sense
- if mc == "No, you can't go":
- print("you look at your mother angrily and choose to ignore her. You sneak out at midnight")
- else:
- print("you smile happily at your mother and go off on your adventure")
- time.sleep(1)
- print("on your way out of the house you find a backpack.")
- ##making an infinite loop until they pick up the backpack
- while True:
- ##taking input.... first time in this game
- e = input("do you wish to pick up the backpack?y/n\n")
- ##breaking loop if yes, and initialising Item Class. if no, continuing loop
- if e.lower() == "y":
- backpack = Item("hold", "Backpack", 10)
- break
- else:
- print("are you sure? This backpack is important, it is the only way you can hold things!")
- print("within the backpack you find three items. These are: A Torch, A map, and A Dagger")
- dagger = Item("Kill","Dagger", 10000)
- torch = Item("Light", "Torch", 20)
- mapp = Item("Display Dungeon", "Map", 10000)
- backpack.use(3, "hold")
- bpack_items.extend([dagger, torch, mapp])
- def Bpack_menu():
- ##i want to use bpack_items and backpack here
- pass
- begin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement