daily pastebin goal
27%
SHARE
TWEET

Untitled

a guest Jan 24th, 2019 120 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. import random
  2.  
  3. class mithrandir():
  4.     def __init__(self):
  5.         self.turn = ''
  6.         self.health = 100
  7.         self.energy = 100
  8.         self.defense = 10
  9.         self.defense_cap = 10
  10.         self.regen_health = 5
  11.         self.regen_energy = 15
  12.         self.regen_defense = 5
  13.  
  14.         # The embedded list first contains the value of the dmg/regen and then the percent of success rate:
  15.         self.actions = [['1. Light of the Valar (ATT)',25,20, 80],
  16.            ['2. Fire of Narya (ATT)',35,30, 55],
  17.            ['3. Aid of the Eagles (DEF)',25, 25, 70],
  18.            ['4. Turn Pass', 0, 0, 100]]
  19.  
  20. class Sauron():
  21.     def __init__(self):
  22.         self.turn = ''
  23.         self.health = 100
  24.         self.energy = 100
  25.         self.defense = 10
  26.         self.regen_health = 5
  27.         self.regen_energy = 10
  28.         self.regen_defense = 5
  29.         self.defense_cap = 10
  30.         self.actions = [['Wrath of Mordor',25,20,70],
  31.                         ['Howl of the Ring Wraiths',35,25,60],
  32.                         ['Might of Morgoth',40,35,45],
  33.                         ['Pass', 0, 0, 100]]
  34.  
  35. Sauron = Sauron()
  36. player = mithrandir()
  37. name = 'Gandalf'
  38.  
  39.  
  40. def round():
  41. #Deciding who goes first
  42.     turn = random.randint(1, 2)
  43.     if turn == 1:
  44.         player.turn = True
  45.         Sauron.turn = False
  46.     else:
  47.         player.turn = False
  48.         Sauron.turn = True
  49.  
  50. #PLAYER TURN
  51.     if player.turn:
  52.         print(f"{name}'s Turn!")
  53. #Beginning Regeneration Phase:
  54.         player.health += player.regen_health
  55.         player.energy += player.regen_energy
  56.         player.defense += player.regen_defense
  57.         if player.health > 100:
  58.             player.health = 100
  59.         if player.energy > 100:
  60.             player.energy = 100
  61.         if player.defense > player.defense_cap:
  62.             player.defense = player.defense_cap
  63.  
  64. #Preliminary Turn Data
  65.         player_stats = f'You have {player.health} HP, {player.energy} energy and {player.defense} defense.'
  66.         print(player_stats)
  67.         # Showing only the actions that the player has enough energy for
  68.         for action in player.actions:
  69.             if action[2] < player.energy:
  70.                 print(action)
  71.         print('The three corresponding numbers represent the action power, its energy cost and success rate percentage.')
  72.         choice = int(input(print('Choose an action:')))
  73.  
  74. #player actions and outcomes
  75.         if choice == 1:
  76.             print(f'{name} uses {player.actions[0][0]}')
  77. #Calculating actions chance of success- Enemy HP and defense lowered, player's energy lowered:
  78.             if random.randint(0, 100) <= player.actions[0][3]:
  79.                 dmg = player.actions[0][1] - Sauron.defense
  80.                 Sauron.health = Sauron.health - int(dmg)
  81.                 Sauron.defense = 0
  82.                 player.energy -= player.actions[0][2]
  83.                 print(f'It does {dmg} DMG to Sauron! He now has {Sauron.health} HP.')
  84.             else:
  85.                 print(f'It Missed! Sauron has {Sauron.health} HP.')
  86.         elif choice == 2:
  87.             print(f'{name} uses {player.actions[1][0]}')
  88.             if random.randint(0, 100) <= player.actions[1][3]:
  89.                 dmg = player.actions[1][1] - Sauron.defense
  90.                 Sauron.health = Sauron.health - int(dmg)
  91.                 Sauron.defense = 0
  92.                 player.energy -= player.actions[1][2]
  93.                 print(f'It does {dmg} DMG to Sauron! He now has {Sauron.health} HP.')
  94.             else:
  95.                 print(f'It Missed! Sauron has {Sauron.health} HP.')
  96.         elif choice == 3:
  97.             print(f'{name} uses {player.actions[2][0]}')
  98.             if random.randint(0, 100) <= player.actions[2][3]:
  99.                 heal = player.actions[2][1]
  100.                 player.energy -= player.actions[2][2]
  101.                 print(f'You have been healed {heal} HP!')
  102.             else:
  103.                 print(f'It Failed!')
  104.         elif choice == 4:
  105.             print('You skipped your turn')
  106.    
  107.  
  108. #SAURONS TURN
  109.     elif Sauron.turn:
  110.         print("Sauron's Turn!")
  111.         Sauron.health += Sauron.regen_health
  112.         Sauron.energy += Sauron.regen_energy
  113.         Sauron.defense += Sauron.regen_defense
  114.         if Sauron.health > 100:
  115.             Sauron.health = 100
  116.         if Sauron.energy > 100:
  117.             Sauron.energy = 100
  118.         if Sauron.defense > Sauron.defense_cap:
  119.             Sauron.defense = Sauron.defense_cap
  120.  
  121.         #Configuring sauron's behaviors:
  122.         if Sauron.energy >= 25 and Sauron.health > 25:
  123.             while Sauron.energy >= 60:
  124.                 if random.randint(0, 100) <= Sauron.actions[1][3]:
  125.                     dmg = Sauron.actions[1][1] - player.defense
  126.                     player.health = player.health - int(dmg)
  127.                     player.defense = 0
  128.                     Sauron.energy -= Sauron.actions[1][2]
  129.                     print(f'Sauron used {Sauron.actions[1][0]} and dealt {dmg} DMG to your HP!')
  130.                     return
  131.                 else:
  132.                     print(f'The attack Missed!.')
  133.                     return
  134.             while Sauron.energy < 60:
  135.                 if random.randint(0, 100) <= Sauron.actions[2][3]:
  136.                     dmg = Sauron.actions[2][1] - player.defense
  137.                     player.health = player.health - int(dmg)
  138.                     player.defense = 0
  139.                     Sauron.energy -= Sauron.actions[2][2]
  140.                     print(f'Sauron used {Sauron.actions[2][0]} and dealt {dmg} DMG to your HP!')
  141.                     return
  142.                 else:
  143.                     print(f'The attack Missed!.')
  144.                     return
  145.  
  146.         elif Sauron.health < 25 and Sauron.energy >= 35:
  147.             if random.randint(0, 100) <= Sauron.actions[3][3]:
  148.                 heal = Sauron.actions[3][1]
  149.                 Sauron.energy -= Sauron.actions[3][2]
  150.                 print(f'Sauron used {Sauron.actions[3][0]} and healed {heal} HP!')
  151.                 print(f'Sauron has {Sauron.health} HP')
  152.                 return
  153.             else:
  154.                 print(f'Sauron failed to heal himself!.')
  155.                 return
  156.  
  157.         if Sauron.energy < 25:
  158.             print('Sauron Passes')
  159.  
  160.  
  161.     player.turn = not player.turn
  162.     Sauron.turn = not Sauron.turn
  163.  
  164.    
  165.  
  166. while player.health != 0 and Sauron.health != 0:
  167.     round()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top