ProuxFather

For Reddit

Jan 29th, 2016
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 5.73 KB | None | 0 0
  1. import random
  2.  
  3. playerName = input("What is your name? \n")
  4. playerClass = input("What is your Class? Ranger, Warrior, Mage? \n")
  5. playerClass = playerClass.lower()
  6.  
  7. playerLevel = 1
  8. playerExperience = 0
  9. experienceNeeded = 100
  10. playerStrength = 1
  11. playerDexterity = 1
  12. playerConstitution = 1
  13.    
  14. playerAttack = 0
  15. playerDefense = 0
  16. playerSpeed = 0
  17. playerHealth = 0
  18.  
  19. def battle():
  20.     global enemy
  21.     global playerName
  22.     fullPlayerHealth = playerName.health
  23.     fullEnemyHealth = enemy.health
  24.     while playerName.health > fullPlayerHealth and enemy.health > fullEnemyHealth:
  25.         if playerName.speed > enemy.speed:
  26.             playerAction = input("What do you want to do? Attack, Heal, Run \n")
  27.             playerAction = playerAction.lower()
  28.             if playerAction == "attack" or playerAction.startswith("a"):
  29.                 criticalHitChance = random.randint(1, 50)
  30.                 if criticalHitChance <= 45:
  31.                     enemy.health = enemy.health - ((playerName.attack / 10) - (enemy.defense / 5))
  32.                     print(enemy.health)
  33.                 elif criticalHitChance > 45:
  34.                     enemy.health = enemy.health - ((playerName.attack / 5) - (enemy.defense / 5))
  35.                     print(enemy.health)
  36.         elif playerAction == "heal" or playerAction.startswith("h"):
  37.             criticalHealChance = random.randint(1, 50)
  38.             if criticalHealChance <= 45:
  39.                 playerName.health = playerName.health + (playerAttack / 5) + (playerDefense / 3)
  40.                 print(playerName.health)
  41.                
  42. def update():
  43.     global playerAttack
  44.     global playerDefense
  45.     global playerSpeed
  46.     global playerHealth
  47.     global playerClass
  48.     global playerLevel
  49.     global playerExperience
  50.     global experienceNeeded
  51.     if playerClass == "ranger" or playerClass.startswith("r"):
  52.         playerAttack = (playerStrength * 1.5) + (playerDexterity * 3.5) + (playerLevel * 5) + 10
  53.         playerDefense = (playerStrength * 3.25) + (playerDexterity * 1.5) + (playerLevel * 5) + 8
  54.         playerSpeed = (playerStrength * 1.25) + (playerDexterity * 3.25) + (playerLevel * 5) + 12
  55.         playerHealth = (playerConstitution * 5) + (playerLevel * 5) + 100
  56.        
  57.     elif playerClass == "warrior" or playerClass.startswith("w"):
  58.         playerAttack = (playerStrength * 3.25) + (playerDexterity * 1.25) + (playerLevel * 5) + 15
  59.         playerDefense = (playerStrength * 2.75) + (playerDexterity * 2.25) + (playerLevel * 5) + 10
  60.         playerSpeed = (playerStrength * 1.25) + (playerDexterity * 1.5) + (playerLevel * 5) + 5
  61.         playerHealth = (playerConstitution * 20) + (playerLevel * 5) + 100
  62.    
  63.     elif playerClass == "mage" or playerClass.startswith("m"):
  64.         playerAttack = (playerStrength * 2) + (playerDexterity * 2) + (playerLevel * 5) + 8
  65.         playerDefense = (playerStrength * 2) + (playerDexterity * 2) + (playerLevel * 5) + 5
  66.         playerSpeed = (playerStrength * 2) + (playerDexterity * 2) + (playerLevel * 5) + 8
  67.         playerHealth = (playerConstitution * 10) + (playerLevel * 5) + 100
  68.        
  69.     if playerExperience >= experienceNeeded:
  70.         playerLevel + 1
  71.         playerExperience = playerExperience - experienceNeeded
  72.         experienceNeeded = (experienceNeeded * playerLevel) + (playerLevel + 75)
  73.    
  74. def enemyFind():
  75.     global enemy
  76.     enemyChoice = random.randint(1, 100)
  77.     if enemyChoice < 60:
  78.         enemy = Goblin
  79.         print(enemy.name)
  80.     elif enemyChoice >= 60 and enemyChoice < 90:
  81.         enemy = Orc
  82.         print(enemy.name)
  83.     elif enemyChoice >= 90 and enemyChoice < 95:
  84.         enemy = Troll
  85.         print(enemy.name)
  86.     elif enemyChoice >= 95 and enemyChoice < 99:
  87.         enemy = Prince
  88.         print(enemy.name)
  89.     elif enemyChoice >= 99:
  90.         enemy = King
  91.         print(enemy.name)
  92.    
  93. pointsRemaining = 10
  94. while pointsRemaining > 0:
  95.     print("You have ", pointsRemaining, "points left.")
  96.     playerChoice = input("What Attribute do yo want to upgrade? Strength, Dexterity, or Constitution \n")
  97.     playerChoice = playerChoice.lower()
  98.     if playerChoice == "strength" or playerChoice.startswith("s"):
  99.         playerStrength = playerStrength + 1
  100.         print("Strength: ", playerStrength)
  101.         pointsRemaining = pointsRemaining - 1
  102.     elif playerChoice == "dexterity" or playerChoice.startswith("d"):
  103.         playerDexterity = playerDexterity + 1
  104.         print("Dexterity: ", playerDexterity)
  105.         pointsRemaining = pointsRemaining - 1
  106.     elif playerChoice == "constitution" or playerChoice.startswith("c"):
  107.         playerConstitution = playerConstitution + 1
  108.         print("Constitution: ", playerConstitution)
  109.         pointsRemaining = pointsRemaining - 1
  110.     else:
  111.         print("Invalid choice, please try again")
  112.    
  113. if pointsRemaining == 0:
  114.     print("All done, you are ready to go forward. Good Luck")
  115.     print("Strength: ", playerStrength)
  116.     print("Dexterity: ", playerDexterity)
  117.     print("Constitution: ", playerConstitution)
  118.    
  119. update()
  120.  
  121. class Player:
  122.     name = playerName
  123.     clas = playerClass
  124.     attack = playerAttack
  125.     defense = playerDefense
  126.     speed = playerSpeed
  127.     health = playerHealth
  128.    
  129. class Goblin:
  130.     name = "Goblin"
  131.     attack = 5
  132.     defense = 8
  133.     speed = 5
  134.     health = 25
  135.    
  136. class Orc:
  137.     name = "Orc"
  138.     attack = 10
  139.     defense = 13
  140.     speed = 10
  141.     health = 50
  142.    
  143. class Troll:
  144.     name = "Troll"
  145.     attack = 20
  146.     defense = 25
  147.     speed = 8
  148.     health = 125
  149.    
  150. class Prince:
  151.     name = "Prince"
  152.     attack = 30
  153.     defense = 32
  154.     speed = 21
  155.     health = 200
  156.    
  157. class King:
  158.     name = "King"
  159.     attack = 50
  160.     defense = 40
  161.     speed = 30
  162.     health = 400
  163.    
  164. enemyFind()
  165. playerName = Player
  166. battle()
Add Comment
Please, Sign In to add comment