Skip to content

Instantly share code, notes, and snippets.

@XChrisUnknownX
Created July 27, 2018 16:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save XChrisUnknownX/e022408dfec0337287166585de3fc908 to your computer and use it in GitHub Desktop.
Save XChrisUnknownX/e022408dfec0337287166585de3fc908 to your computer and use it in GitHub Desktop.
battlequest.py
import time
import random
print("""You are the great magician.
Your exploits are known throughout the world.""")
badguyhealth = 0
goodguyhealth = 20
goodguylevel = 6
goodguylevels = str(goodguylevel)
experience = 600
goodguylevel = experience / 100
goodguyminattack = goodguylevel - 5
goodguymaxattack = goodguylevel
goodguydamage = random.randint(goodguyminattack, goodguymaxattack)
goodguydamages = str(goodguydamage)
soldiercount = 1
soldiercounts = str(soldiercount)
def soldier():
global soldiercount
global solidercounts
soldiercounts = str(soldiercount)
print("""A menacing soldier appears.""")
time.sleep(3)
print("this is menacing soldier number " + soldiercounts + ".")
soldiercount += 1
soldiercounts = str(soldiercount)
global badguyhealth
global goodguyhealth
global goodguylevel
global experience
global goodguylevels
global goodguyminattack
global goodguymaxattack
global goodguydamage
global goodguydamages
global experience
goodguyminattack = goodguylevel - 5
goodguymaxattack = goodguylevel
goodguydamage = random.randint(goodguyminattack, goodguymaxattack)
badguyhealth = 20
while True:
goodguylevel = experience / 100
goodguylevels = str(goodguylevel)
goodguydamage = random.randint(goodguyminattack, goodguymaxattack)
goodguydamages = str(goodguydamage)
turnrollgood = random.randint(1, 100)
menacingsoldiername = soldiercount - 1
menacingsoldiernames = str(menacingsoldiername)
turnrollbad = random.randint(1, 100)
goodguyhealths = str(goodguyhealth)
badguyhealths = str(badguyhealth)
print("The great magician has " + goodguyhealths + " health.")
time.sleep(3)
print("The menacing soldier " + menacingsoldiernames + " has " + badguyhealths + " health.")
time.sleep(3)
healroll = random.randint(1, 100)
healrolls = str(healroll)
badguydamageroll = random.randint(1, 2)
badguydamagerolls = str(badguydamageroll)
if turnrollgood >= turnrollbad:
print("The great magician is deciding what to do.")
time.sleep(3)
if goodguyhealth <= 0:
print("The great magician dies!")
time.sleep(3)
exit()
elif goodguyhealth <= 10:
print("The great magician heals himself for " + healrolls + " health.")
goodguyhealth += healroll
time.sleep(3)
if goodguyhealth > 20:
print("Unfortunately, the great magician can only have 20 health. All extra health lost.")
goodguyhealth = 20
time.sleep(3)
else:
print("The great magician has " + goodguyhealths + " health.")
time.sleep(3)
else:
print("The great magician uses his magic to hurt the enemy, causing " + goodguydamages + " damage.")
badguyhealth -= goodguydamage
time.sleep(3)
if badguyhealth <= 0:
print("The soldier is defeated.")
experience += 100
goodguylevel = experience / 100
goodguylevels = str(goodguylevel)
time.sleep(3)
print("The great magician is now level " + goodguylevels + ".")
time.sleep(3)
soldier()
print("The soldier makes an attack, causing " + badguydamagerolls + " damage.")
goodguyhealth -= badguydamageroll
time.sleep(3)
if goodguyhealth <= 0:
print("The great magician dies!")
time.sleep(3)
exit()
else:
continue
else:
print("The soldier makes an attack, causing " + badguydamagerolls + " damage.")
goodguyhealth -= badguydamageroll
time.sleep(3)
if goodguyhealth <= 0:
print("The great magician dies!")
time.sleep(3)
exit()
else:
pass
if goodguyhealth <= 10:
print("The great magician heals for " + healrolls + " health.")
time.sleep(3)
goodguyhealth += healroll
if goodguyhealth > 20:
print("Unfortunately, the great magician can't have more than 20 health.")
time.sleep(3)
goodguyhealth = 20
continue
else:
pass
else:
print("The great magician attacks with a powerful spell, causing " + goodguydamages + " damage.")
time.sleep(3)
badguyhealth -= goodguydamage
if badguyhealth <= 0:
experience += 100
goodguylevel = experience / 100
goodguylevels = str(goodguylevel)
print("The soldier is defeated. The great magician receives 100 experience and is now level " + goodguylevels + ".")
time.sleep(3)
soldier()
else:
continue
soldier()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment