Advertisement
Guest User

TBA

a guest
Jan 20th, 2020
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.27 KB | None | 0 0
  1. import random, time
  2. class Item:
  3.     ## upon initiation of the class, this function will run. currently it is only declaring variables
  4.     def __init__(self, function, name, amount):
  5.         ##self. means a variable belonging to this instance of the class
  6.        
  7.         self.function = function
  8.         self.name = name
  9.         self.amount = amount
  10.         self.total = amount
  11.         print("you found a", self.name, "and you feel accomplished. This item can do:", self.function + ",", self.amount, "times")
  12.     ##this is a method, which you call by doing instance.methodName("parameters")
  13.     def use(self, amount, function):
  14.         if function.lower() == self.function.lower():
  15.             self.amount -= amount
  16.             print(f"you now have {self.amount} uses of {self.name}")
  17.         else:
  18.             print("this item cannot do this!")
  19.     def gain(self, amount):
  20.         if self.amount + amount <= self.total:
  21.             self.amount += amount
  22.             print("you acquired:", amount, "of", self.name, "meaning you now have:", self.amount, "of your", self.total, "uses of", self.name+".")
  23.         else:
  24.             print("you do not have space to hold this!")
  25.     def lose(self, amount):
  26.         self.amount -= amount
  27.         print("you lost", amount, "of", self.name+".")
  28. def Return(pack, items):
  29.     return (pack, items)
  30. def begin():
  31.     bpack_items = []
  32.     ## opening statement
  33.     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...")
  34.     print("your mission begins...")
  35.     ##choosing from list
  36.     mc = random.choice(["yes, but be careful Call", "No, you can't go"])
  37.     ##sleeping for one second
  38.     time.sleep(1)
  39.     print("you approach your mother. Adventurer, be careful, for this could be the most dangerous monster you meet upon your quest through Getharis")
  40.     print("you ask your mother if you can go on your adventure...")
  41.     ##displaying motherchoice
  42.     print(f"your mother says: {str(mc)}")
  43.     time.sleep(1)
  44.     ##making choice so that the next line makes sense
  45.     if mc == "No, you can't go":
  46.         print("you look at your mother angrily and choose to ignore her. You sneak out at midnight")
  47.     else:
  48.         print("you smile happily at your mother and go off on your adventure")
  49.     time.sleep(1)
  50.     print("on your way out of the house you find a backpack.")
  51.     ##making an infinite loop until they pick up the backpack
  52.     while True:
  53.         ##taking input.... first time in this game
  54.         e = input("do you wish to pick up the backpack?y/n\n")
  55.         ##breaking loop if yes, and initialising Item Class. if no, continuing loop
  56.         if e.lower() == "y":
  57.             backpack = Item("hold", "Backpack", 10)
  58.             break
  59.         else:
  60.             print("are you sure? This backpack is important, it is the only way you can hold things!")
  61.     print("within the backpack you find three items. These are: A Torch, A map, and A Dagger")
  62.     dagger = Item("Kill","Dagger", 10000)
  63.     torch = Item("Light", "Torch", 20)
  64.     mapp = Item("Display Dungeon", "Map", 10000)
  65.     backpack.use(3, "hold")
  66.     bpack_items.extend([dagger, torch, mapp])
  67. def Bpack_menu():
  68.     ##i want to use bpack_items and backpack here
  69.     pass
  70. begin()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement