Guest User

Game.Py

a guest
Mar 30th, 2020
139
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.34 KB | None | 0 0
  1. import random
  2. from .Magic import Spell
  3.  
  4.  
  5. class Bcolor:
  6.     HEADER = '\033[95m'
  7.     OKBLUE = '\033[94m'
  8.     OKGREEN = '\033[92m'
  9.     WARNING = '\033[93m'
  10.     FAIL = '\033[91m'
  11.     ENDC = '\033[0m'
  12.     BOLD = '\033[1m'
  13.     UNDERLINE = '\033[4m'
  14.  
  15.  
  16. class Person:
  17.     def __init__(self, name, hp, mp, at, df, magic, items):
  18.         self.name = name
  19.         self.maxhp = hp
  20.         self.hp = hp     # HP of the player changes throughout the battle
  21.         self.maxmp = mp
  22.         self.mp = mp
  23.         self.al = at-10
  24.         self.ah = at+10
  25.         self.df = df
  26.         self.magic = magic
  27.         self.items = items
  28.         self.actions = ["Attack", "Magic", "Items"]
  29.  
  30.     def gen_dm(self):
  31.        return random.randrange(self.al, self.ah)
  32.  
  33.     def take_dm(self, dm):
  34.         self.hp -=dm
  35.         if self.hp < 0:
  36.             self.hp = 0
  37.             return self.hp
  38.  
  39.     def heal(self, dm):
  40.         self.hp += dm
  41.         if self.hp > self.maxhp:
  42.             self.hp = self.maxhp
  43.  
  44.     def get_hp(self):
  45.         return self.hp
  46.  
  47.     def get_maxhp(self):
  48.         return self.maxhp
  49.  
  50.     def get_mp(self):
  51.         return self.mp
  52.  
  53.     def get_maxmp(self):
  54.         return self.maxmp
  55.  
  56.     def reduce_mp(self, cost):
  57.         self.mp -= cost
  58.  
  59.     def choose_actions(self):
  60.         i = 1
  61.         print("Actions")
  62.         for item in self.actions:
  63.             print("     ", str(i) + ":", item)
  64.             i += 1
  65.  
  66.     def magic_choice(self):
  67.         print("Magic")
  68.         i = 1
  69.         for Spell in self.magic:
  70.             print("     ", str(i) + ":", Spell.name, " cost : ", Spell.cost)
  71.             i += 1
  72.  
  73.     def item_choice(self):
  74.         print("Items")
  75.         i = 1
  76.         for item in self.items:
  77.             print("     ", str(i) + ":", item["item"].name, " : ", item["item"].des, "(* " + str(item["quantity"]) + ")")
  78.             i += 1
  79.  
  80.     def g_s(self):
  81.         print("                                    _________________________               __________")
  82.         print(Bcolor.BOLD + str(self.name) + str(self.hp) + "/" + str(self.maxhp) +"                  |" + Bcolor.OKGREEN + "██████████████           " + Bcolor.ENDC + "|            "          " |" + Bcolor.ENDC + Bcolor.BOLD +  str(self.mp) + "/" + str(self.maxmp) + "|" + Bcolor.OKBLUE + "█████████ " + Bcolor.ENDC + "|")
Add Comment
Please, Sign In to add comment