Advertisement
Guest User

My first game in python

a guest
Sep 7th, 2017
229
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.46 KB | None | 0 0
  1. import random
  2. onward = "\n..."
  3. dragon_hp = 40
  4. player_hp = 20
  5. heal_lmt = 4
  6.  
  7. print("You are a fearsome warrior facing off against a terrible dragon.")
  8. print("You can choose to fight the dragon or run away.")
  9. Turn = True
  10.  
  11. while Turn:
  12.     dodge_chance = random.randint(1, 8)
  13.     action_play = input("\nChoose an action:\nAttack\nHeal\nMagic\nRun\n")
  14.     if action_play == "a":
  15.         # "a" stands for attack
  16.         print("\nYou swing at the dragon with your sword.")
  17.         player_atk = random.randint(3, 5)
  18.         damage = player_atk
  19.         dragon_hp = dragon_hp - damage
  20.         print("\nYou did %d damage!\nDragon HP is now %d!" % (damage, dragon_hp))
  21.         if damage == 5:
  22.             print(' CRITICAL!')
  23.     if action_play == "m":
  24.         # "m" stands for magic
  25.         print("\nYou try hitting the dragon with a fireball...")
  26.         player_magic = random.randint(10, 12)
  27.         magic_miss = random.randint(1, 6)
  28.         if magic_miss == 1:
  29.             print("BLAM! You hit the dragon with a fire ball! You deal a massive %d damage!!" % player_magic)
  30.             dragon_hp = dragon_hp - player_magic
  31.             print("Dragon HP is now %d!" % dragon_hp)
  32.         else:
  33.             print("The dragon dodges your fireball. You deal 0 damage.")
  34.     if action_play == "h":
  35.         # "h" stands for heal
  36.         heal_plus = 8
  37.         if heal_lmt < 5:
  38.             player_hp = player_hp + heal_plus
  39.             if player_hp > 20:
  40.                 player_hp = 20
  41.             print("\nYou drink a healing potion. You regain %d HP. You know have %d HP." % (heal_plus, player_hp))
  42.             heal_lmt = heal_lmt + 1
  43.             print("You have", 5 - heal_lmt, "healing potions left.")
  44.             if heal_lmt == 5:
  45.                 print("WARNING!! YOU ARE OUT OF HEALING POTIONS!! USING HEAL AGAIN WOULD WASTE A TURN!")
  46.         else:
  47.             print("You ran out of healing potions. You can't heal anymore.")
  48.     if action_play == "r":
  49.         # "r" stands for run
  50.         print("You ran away...")
  51.         break
  52.  
  53.     if dragon_hp <= 0:
  54.             print("The dragon is Dead!\nYou Win!!")
  55.             break
  56.  
  57.     print("\nDragon Attacks!")
  58.     dragon_atk = random.randint(1, 3)
  59.  
  60.     if dragon_atk == 1:
  61.             print("The dragon attacks with blazing fire.")
  62.             fire_dmg = random.randint(15, 18)
  63.             if dodge_chance == 1:
  64.                 print("Ouch! The flames burn you! you take %d damage!" % fire_dmg)
  65.                 player_hp = player_hp - fire_dmg
  66.             else:
  67.                 print("You dodged the fire. Close call.")
  68.  
  69.     if dragon_atk == 2:
  70.             print("The dragon attacks with his savage claws.")
  71.             claw_dmg = random.randint(3, 5)
  72.             if dodge_chance > 3:
  73.                 print("Ouch! You get slashed! you take %d damage!" % claw_dmg)
  74.                 player_hp = player_hp - claw_dmg
  75.             else:
  76.                 print("You dodged the claws. Close call.")
  77.  
  78.     if dragon_atk == 3:
  79.             print("The dragon bites down on you with his massive fangs")
  80.             bite_dmg = random.randint(6, 8)
  81.             if dodge_chance > 5:
  82.                 print("Ouch! You're caught in the dragon's fangs! you take %d damage!" % bite_dmg)
  83.                 player_hp = player_hp - bite_dmg
  84.             else:
  85.                 print("You dodged the bite. Close call.")
  86.  
  87.     print("You now have %d HP" % player_hp)
  88.     if player_hp <= 0:
  89.         print("YOU DIED!")
  90.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement