daily pastebin goal
61%
SHARE
TWEET

Untitled

a guest Dec 7th, 2017 53 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2. DHealth = random.randint(20,100)
  3. UserHealth = 100
  4.  
  5. #--------------------Fight Class------------------------------
  6. class fightProgram:
  7.   def __init__(self):
  8.     self.DHealth = random.randint(20,100) # health needs to be updated
  9.     self.usrnum = 0
  10.     self.attack = 0
  11.     self.dodgenum = 0
  12.     self.attacknum = 0
  13.     self.UserHealth = 100 #Call Health from previous fight
  14.  
  15.   def battle(self, name, maxDam):
  16.     while self.DHealth > 0 and self.UserHealth > 0:
  17.       print('What would you like to do?')
  18.       print('1 = Attack')
  19.       print('2 = Dodge')
  20.       self.usrnum = int(input('Pick a number:\n'))
  21.  
  22.       self.DHealth -= 1 #Remove
  23.      
  24.       if self.usrnum == 1:
  25.        self.attack = random.randint(0,40)
  26.        self.attacknum = random.randint(0,maxDam)
  27.        if self.attack > self.attacknum:
  28.          self.DHealth -= self.attack # -= base damage + damage modifier
  29.          print('You hit the %s' % name)
  30.          if self.DHealth <= 0:
  31.            print('%s is dead.' % name)
  32.          else:
  33.            print('%s\'s Health is %d' % (name, self.DHealth))
  34.        else:
  35.          self.UserHealth -= self.attacknum
  36.          if self.UserHealth <= 0:
  37.            print('You have died.')
  38.          else:
  39.            print('The %s hit you. Your health is %d' % (name, self.UserHealth))
  40.        
  41.  
  42.       if self.usrnum == 2:
  43.        print('You Chose to Dodge\n')
  44.        self.dodgenum = random.randint(0,10)
  45.        self.attacknum = random.randint(0,6)
  46.        if self.dodgenum > self.attacknum:
  47.          if self.attacknum > random.randint(0,10):
  48.            self.DHealth -= random.randint(20,90)
  49.            if self.DHealth <= 0:
  50.              print('%s fell into lava and died.' % name)
  51.            else:
  52.              print('%s tripped and hurt itself. %s health is %d' % (name, name, self.DHealth))
  53.        else:
  54.          self.UserHealth -= self.dodgenum
  55.        self.attacknum = 0
  56.        self.dodgenum = 0
  57.        print('Your health is %d' % self.UserHealth)
  58.      
  59. #------------------------End of Fight Class----------------------------
  60.      
  61. level1 = fightProgram()
  62. level1.battle('Cobalt', 60)
RAW Paste Data
Top