Advertisement
Mili-NT

classes.py

Dec 26th, 2021
1,180
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.15 KB | None | 0 0
  1. from colorama import Fore, Style, Back
  2. from pyfiglet import Figlet
  3. import random
  4.  
  5. class Inventory(object):
  6.     def __init__(self):
  7.         self.items = {}
  8.  
  9.     def add_item(self, item):
  10.         if item in self.items:
  11.             self.items[item] += 1
  12.         else:
  13.             self.items.update({item:1})
  14.  
  15.     def drop_item(self, item):
  16.         self.items[item] -= 1
  17.         if self.items[item] <= 0:
  18.             del self.items[item]
  19.  
  20.     def InspectInventory(self):
  21.         print('\t'.join(['Name', 'Description', 'Damage', 'Healing', 'Stat Boost']))
  22.         for i in self.items.keys():
  23.                 print("["+str(self.items[i])+"] "+ (i.ItemName + ". " + i.ItemDescription + "."))
  24.                 print("""This item does """ + str(i.ItemDamage)+""" damage.""")
  25.                 print("""This item does """ + str(i.ItemHeal) + """ healing. """)
  26.                 print("""This item boosts all stats by """ + str(i.StatBoost))
  27. class Player:
  28.     def __init__(self):
  29.         self.stats = {'health':100,
  30.                       'sanity':100,
  31.                       'mana':100,
  32.                       'speed':random.randint(45, 100),
  33.                       }
  34.         self.location = ''
  35.         self.inventory = Inventory()
  36.         self.moves = {"Thrust": (25, 30),
  37.                       "Slash": (10, 65),
  38.                       "Heal": (25, 40)}
  39.         # Following attributes are score components
  40.         self.score = {'dmg_done':0,
  41.                       'dmg_taken':0,
  42.                       'amount_healed':0,
  43.                       'sanity_lost':0}
  44. class Room:
  45.     def __init__(self, number, description, directions, enemy, contents):
  46.         self.number = number
  47.         self.description = description
  48.         self.directions = directions
  49.         self.enemy = enemy
  50.         self.contents = contents
  51.  
  52.     def LocationCheck(self):
  53.         print(Fore.WHITE + self.directions)
  54.         if self.enemy != "none":
  55.             print(Fore.YELLOW + "You see a " + str(self.enemy))
  56.         if self.contents != "none":
  57.             print(Fore.WHITE + "This room contains a " + str(self.contents) + ".")
  58.  
  59.     def PrintDirections(self):
  60.         print(self.directions)
  61. class Item(object):
  62.     def __init__(self, name, description, properties):
  63.         self.name = name
  64.         self.description = description
  65.         self.properties = properties
  66.  
  67.  
  68.     def InspectItem(self):  # This  method will be used to inspect items in the inventory or on pickup
  69.         print("This item is a " + self.name + ". " + "It is " + self.description)
  70.         if self.damage > 0:
  71.             print("This item does " + str(self.damage) + " damage.")
  72.         if self.heal > 0:
  73.             print("This item restores " + str(self.heal) + " health.")
  74.         if self.stat_boost > 0:
  75.             print("This item boosts your stats by " + str(self.stat_boost))
  76. class Enemy:
  77.     def __init__(self, name, description, stats, moves):
  78.         self.name = name
  79.         self.description = description
  80.         self.stats = stats
  81.         self.moves = moves
  82.  
  83.     def encounter(self):
  84.         print("")
  85.         print("It's speed is " + str(self.speed) + ", your speed is " + str(player.player_speed) + ".")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement