Advertisement
Guest User

Untitled

a guest
Oct 24th, 2016
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.72 KB | None | 0 0
  1. #Enemy Selection
  2. import sys, os, random
  3. from . import characters
  4.  
  5. #The roll that determines which enemy is selected
  6. def prefight():
  7. global enemy
  8. roll = random.randint(1,100)
  9. enemynum = roll
  10.  
  11. if enemynum < 60:
  12. enemy = characters.GoblinIG
  13. elif enemynum < 90 and enemynum >= 60:
  14. enemy = characters.ZombieIG
  15. elif enemynum < 100 and enemynum >= 90:
  16. enemy = characters.CentaurIG
  17. elif enemynum < 140 and enemynum >=100:
  18. enemy = charactes.WyvernIG
  19. elif enemynum >= 140:
  20. enemy = characters.DragonIG
  21. else:
  22. pass
  23. fight()
  24.  
  25.  
  26. #The fight menu where the player can attack
  27. def fight():
  28. os.system('clear')
  29. print "%s versus %s" % (characters.PlayerIG.name, enemy.name)
  30. print "%s's Health %d/%d %s's Health %d/%d" % (characters.PlayerIG.name, characters.PlayerIG.health, characters.PlayerIG.maxhealth, enemy.name, enemy.health, enemy.maxhealth)
  31. print "1. Attack"
  32. print "2. Skills"
  33. print "3. Run"
  34.  
  35. option = raw_input("=> ")
  36. if option == "1":
  37. attack()
  38. elif option == "2":
  39. skills()
  40. elif option == "3":
  41. run()
  42. else:
  43. fight()
  44.  
  45.  
  46. #The function that handles the player's attack
  47. def attack():
  48. os.system('clear')
  49. PAttack = random.randint(characters.PlayerIG.base_attack/2, characters.PlayerIG.base_attack)
  50. PActual = PAttack-enemy.defense
  51. if PAttack == characters.PlayerIG.base_attack/2:
  52. print "You miss"
  53. eattack()
  54. else:
  55. enemy.health -= PActual
  56. print "You deal %i damage!" %PActual
  57. eattack()
  58. option=raw_input('')
  59. os.system('clear')
  60.  
  61.  
  62. #The menu that handles skills
  63. #Advanced Combat
  64. def skills():
  65. os.system('clear')
  66. print "1. Strong Attack: Deal twice as much damage"
  67. print "Return"
  68. option = raw_input('=> ')
  69. if option == "1":
  70. strongAttack()
  71. else:
  72. fight()
  73.  
  74. #The strong attack skill that deals double attack damage and cannot miss.
  75. def strongAttack():
  76. os.system('clear')
  77. if characters.PlayerIG.currstam >= 20: #Stamina manager
  78. characters.PlayerIG.currstam -= 20
  79. else:
  80. os.system('clear')
  81. print "You don't have enough stamina!"
  82. option = raw_input(' ')
  83. skills()
  84. PAttack = random.randint(characters.PlayerIG.base_attack/2, characters.PlayerIG.base_attack)*2
  85. enemy.health -= PAttack
  86. print "You deal %i damage with your strong attack!\nStamina: %i" % (PAttack, characters.PlayerIG.currstam)
  87. option = raw_input('')
  88.  
  89. eattack()
  90.  
  91. #The enemies attack function
  92. #Enemy Attack
  93. def eattack():
  94. EAttack = random.randint(enemy.attack/2, enemy.attack)
  95. EActual = EAttack - characters.PlayerIG.defense
  96. if EAttack == enemy.attack/2:
  97. print "The %s misses!" % (enemy.name)
  98. else:
  99. characters.PlayerIG.health -= EActual
  100. print "The enemy deals %i damage" %EAttack
  101. option = raw_input('')
  102. if enemy.health <= 0:
  103. win()
  104. elif characters.PlayerIG.health <= 0:
  105. die()
  106. else:
  107. fight()
  108.  
  109. #Flee/Running Away
  110. def run():
  111. os.system('clear')
  112. runnum = random.randint(1,3) #Rolling to see if the player passes the check
  113. if runnum == 1:
  114. print "You have run away!"
  115. option = raw_input('')
  116. start1()
  117. else:
  118. print "The enemy cornered you! Run check failed"
  119. option = raw_input('')
  120. os.system('clear')
  121. EAttack = random.randint(enemy.attack/2, enemy.attack)
  122. if EAttack == enemy.attack/2:
  123. print "The %s misses!" % (enemy.name)
  124. else:
  125. characters.PlayerIG.health -= EAttack
  126. print "The enemy deals %i damage" %EAttack
  127. option = raw_input('')
  128. if characters.PlayerIG.health <= 0:
  129. die()
  130. else:
  131. fight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement