Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Enemy Selection
- import sys, os, random
- from . import characters
- #The roll that determines which enemy is selected
- def prefight():
- global enemy
- roll = random.randint(1,100)
- enemynum = roll
- if enemynum < 60:
- enemy = characters.GoblinIG
- elif enemynum < 90 and enemynum >= 60:
- enemy = characters.ZombieIG
- elif enemynum < 100 and enemynum >= 90:
- enemy = characters.CentaurIG
- elif enemynum < 140 and enemynum >=100:
- enemy = charactes.WyvernIG
- elif enemynum >= 140:
- enemy = characters.DragonIG
- else:
- pass
- fight()
- #The fight menu where the player can attack
- def fight():
- os.system('clear')
- print "%s versus %s" % (characters.PlayerIG.name, enemy.name)
- 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)
- print "1. Attack"
- print "2. Skills"
- print "3. Run"
- option = raw_input("=> ")
- if option == "1":
- attack()
- elif option == "2":
- skills()
- elif option == "3":
- run()
- else:
- fight()
- #The function that handles the player's attack
- def attack():
- os.system('clear')
- PAttack = random.randint(characters.PlayerIG.base_attack/2, characters.PlayerIG.base_attack)
- PActual = PAttack-enemy.defense
- if PAttack == characters.PlayerIG.base_attack/2:
- print "You miss"
- eattack()
- else:
- enemy.health -= PActual
- print "You deal %i damage!" %PActual
- eattack()
- option=raw_input('')
- os.system('clear')
- #The menu that handles skills
- #Advanced Combat
- def skills():
- os.system('clear')
- print "1. Strong Attack: Deal twice as much damage"
- print "Return"
- option = raw_input('=> ')
- if option == "1":
- strongAttack()
- else:
- fight()
- #The strong attack skill that deals double attack damage and cannot miss.
- def strongAttack():
- os.system('clear')
- if characters.PlayerIG.currstam >= 20: #Stamina manager
- characters.PlayerIG.currstam -= 20
- else:
- os.system('clear')
- print "You don't have enough stamina!"
- option = raw_input(' ')
- skills()
- PAttack = random.randint(characters.PlayerIG.base_attack/2, characters.PlayerIG.base_attack)*2
- enemy.health -= PAttack
- print "You deal %i damage with your strong attack!\nStamina: %i" % (PAttack, characters.PlayerIG.currstam)
- option = raw_input('')
- eattack()
- #The enemies attack function
- #Enemy Attack
- def eattack():
- EAttack = random.randint(enemy.attack/2, enemy.attack)
- EActual = EAttack - characters.PlayerIG.defense
- if EAttack == enemy.attack/2:
- print "The %s misses!" % (enemy.name)
- else:
- characters.PlayerIG.health -= EActual
- print "The enemy deals %i damage" %EAttack
- option = raw_input('')
- if enemy.health <= 0:
- win()
- elif characters.PlayerIG.health <= 0:
- die()
- else:
- fight()
- #Flee/Running Away
- def run():
- os.system('clear')
- runnum = random.randint(1,3) #Rolling to see if the player passes the check
- if runnum == 1:
- print "You have run away!"
- option = raw_input('')
- start1()
- else:
- print "The enemy cornered you! Run check failed"
- option = raw_input('')
- os.system('clear')
- EAttack = random.randint(enemy.attack/2, enemy.attack)
- if EAttack == enemy.attack/2:
- print "The %s misses!" % (enemy.name)
- else:
- characters.PlayerIG.health -= EAttack
- print "The enemy deals %i damage" %EAttack
- option = raw_input('')
- if characters.PlayerIG.health <= 0:
- die()
- else:
- fight()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement