Advertisement
Guest User

Untitled

a guest
Oct 22nd, 2014
156
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.77 KB | None | 0 0
  1.  
  2. import random
  3.  
  4. def clear(num):
  5.     for i in range(num):
  6.         print
  7.  
  8.  
  9. enemy_hp = random.randrange(50, 150)
  10. player_hp = 100
  11. weapon_stats = {'knife': 15, 'hammer': 21, '9mm pistol': 67, '5.56 hunting rifle': 240}
  12. weapons_list = ['knife', 'hammer', '9mm pistol', '5.56 hunting rifle']
  13. weapon = []
  14.  
  15. print "======================================"
  16. print "You found yourself in combat situation"
  17. print "There is cabinet with weapons"
  18. print " Content of cabinet: "
  19. print "---------------"
  20. for x in weapons_list:
  21.     print x
  22. print "---------------"
  23. print
  24. print "which weapon you take out of cabinet ?"
  25.  
  26. answer = raw_input("Make your choice : ")
  27.  
  28. for x in weapons_list:
  29.     if x == answer:
  30.         weapon.append(x)
  31.  
  32. print "You took", weapon, " armed with it you hope to prevail"
  33. print
  34.  
  35. while enemy_hp > 0 and player_hp > 0:
  36.  
  37.     print "    ", player_hp, " PLAYER HEALTH"
  38.     print "    ", enemy_hp, " ENEMY HEALTH"
  39.     print "=============================================================="
  40.     print "You have option to attack HEAD or BODY, which do you choose ?"
  41.     print "(targeting head has lower chance of success but damage is much more lethal !)"
  42.  
  43.     answer2 = raw_input("select a or b: ")
  44.  
  45.     if answer2 == "a":
  46.         if random.randrange(1, 20) > 15:
  47.             enemy_hp -= (4 * weapon_stats[weapon[0]])
  48.             clear(40)
  49.             print "You struck enemy !"
  50.             if random.randrange(1, 20) > 10:
  51.                 player_hp -= 20
  52.                 print "Enemy struck you !"
  53.                 print
  54.  
  55.             else:
  56.                 print "enemy missed"
  57.                 print
  58.  
  59.         else:
  60.             clear(40)
  61.             print " You missed "
  62.             if random.randrange(1, 20) > 10:
  63.                 player_hp -= 20
  64.                 print "Enemy struck you !"
  65.                 print
  66.             else:
  67.                 print "enemy missed"
  68.                 print
  69.  
  70.     elif answer2 == "b":
  71.         if random.randrange(1, 20) > 7:
  72.             enemy_hp -= weapon_stats[weapon[0]]
  73.             clear(40)
  74.             print "You struck enemy !"
  75.             if random.randrange(1, 20) > 10:
  76.                 player_hp -= 20
  77.                 print "Enemy struck you !"
  78.                 print
  79.             else:
  80.                 print "enemy missed"
  81.                 print
  82.  
  83.         else:
  84.             clear(40)
  85.             print " You missed "
  86.             if random.randrange(1, 20) > 10:
  87.                 player_hp -= 20
  88.                 print "Enemy struck you !"
  89.                 print
  90.             else:
  91.                 print "enemy missed"
  92.                 print
  93.  
  94. print "=============="
  95. print "=============="
  96. print "=============="
  97.  
  98. if player_hp <= 0:
  99.  
  100.     print "You died today"
  101. else:
  102.     print "You live another day"
  103.  
  104. raw_input("")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement