I'm totally new to coding and tried myself on a short text based adventure game. I got the feeling that the functions are the same ones all the time and the whole game is a bit monotonous... I'd be very thankful if anybody has some improvements or additional ideas!
import random
import time
def nameFunction(): #hello what's your name?
name = input("Hello! What's your name, adventurer?\n")
time.sleep(2)
print ("Hi " + name + "...!")
time.sleep(3)
def storyFunction(): #the story until hard part #half story is told
print ("A few miles away,")
time.sleep(3)
print ("behind a huge wall out of undestroyable iron and concrete,")
time.sleep(4)
print ("is the most dangerous and frightening place you'll ever see.")
time.sleep(5)
print ("Once, many, many years ago the town had the euphonious name Therondia.")
time.sleep(5)
print ("The people living there where called 'the happy people', because of the prevailing satisfied and sunshiny atmosphere.")
time.sleep(5)
print ("Inhabitants of the sorrounding areas, envied people living in this town for the friendliness \nbetween the citizens and the completely safe neighborhoods, nothing bad had ever happened in Therondia.")
time.sleep(6)
print ("Everybody thought of it as the perfect place to spend their life.")
time.sleep(5)
print ("...")
time.sleep(5)
print ("But then it happened...")
time.sleep(5)
print ("... and everything changed.")
def readyFunction(): # ready to join?
ready = input("Are you brave enough to join us exploring this haunted town? Then say 'yes'! But if you are too scared, you can say no...\n")
if ready == "yes" or ready == "Yes" or ready == "yes!":
print ("You're coming with us? That is amazing, we need every help we can get! But let us tell you the whole story so that you know in what you engage.")
time.sleep(4)
storyFunction()
if ready == "no" or ready == "No":
print ("You're not coming with us? What a petty... See you next time!")
else:
print ("That's not what I asked for...")
readyFunction() #Problem: wenn danach das richtige eingegeben wird geht er trotzdem wieder in die Loop zu are you ready #
def missionFunctionAS(): #missionFunction after school
print ("Well... Where should we search now?")
time.sleep(3)
schoolhomechurch = input ("What do you think? Should we search for her at school (1), at her families home (2) or at church (3)?\nJust answer '1', '2' or '3'!\n")
time.sleep(3)
if schoolhomechurch == "1":
print("- you go to the school -")
time.sleep(3)
print("Hmmmmm... Let's split up, so if she's here, we can find her faster. But be careful that her friends do not see you!")
schoolyesno = random.randint(1,2)
if schoolyesno == 1:
time.sleep(4)
print ("HERE SHE IS!!!")
time.sleep(3)
print (".....")
time.sleep(3)
print ("Now that we know what happened to her, we can go home and carry on research for couring sickened people.")
time.sleep(3)
print ("And when we find a remedy, we'll come back and try to bring this town the peace it once held.")
time.sleep(5)
print ("... to be continued,extended and improved...")
if schoolyesno == 2:
time.sleep(4)
print ("I think there is nobody around... Let's search somewhere else...")
missionFunctionAS()
if schoolhomechurch == "2":
print ("- you go to the families home -")
time.sleep(3)
print ("Hmmmmm... Let's split up, so if she's here, we can find her faster. But be careful that her parents do not see you!")
homeyesno = random.randint(1,2)
if homeyesno == 1:
time.sleep(4)
print ("HERE SHE IS!!!")
time.sleep(3)
print (".....")
time.sleep(3)
print ("Now that we know what happened to her, we can go home and carry on research for couring sickened people.")
time.sleep(3)
print ("And when we find a remedy, we'll come back and try to bring this town the peace it once held.")
time.sleep(5)
print ("... to be continued,extended and improved...")
if homeyesno == 2:
time.sleep(4)
print ("I think there is nobody around... Let's search somewhere else...")
missionFunctionAS()
if schoolhomechurch == "3":
print ("- you go to the church -")
time.sleep(3)
print ("*whispering* Wow... this is an amazing building!... But pretty scary as well...")
time.sleep(3)
print ("LOOK! There she is... At the confessional...")
time.sleep(3)
print (" ......... ")
time.sleep (3)
print ("Now that we know what happened to her, we can go home and carry on research for couring sickened people.")
time.sleep(3)
print ("And when we find a remedy, we'll come back and try to bring this town the peace it once held.")
time.sleep(5)
print ("... to be continued,extended and improved...")
def rightpathFunction(): #which path to get into the town? -> 1. stop to be kicked out of the game!!
time.sleep(4)
print ("The only way to get into the city is to climb the wall with our special equipment.")
time.sleep(4)
print ("There is still one problem we would have to deal with if we made it to the other side of it:")
time.sleep(4)
print ("If anyone sees us, they will fight us. We have to be prepared for a battle.")
time.sleep(4)
print ("We are five people, they will be max. 10. We can overcome them if we hit 5 of them quickly. Let's go!")
time.sleep(4)
seen = random.randint(1, 2)
if seen == 1:
print ("Puhhh... We did it without drawing any attention towards us. Good Job!")
missionFunction()
if seen == 2:
print ("Ohhhh sh***!! Okay guys we have to fight!")
time.sleep(4)
print ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
print (" Fighting... ")
print ("YOU MUST HIT ABOVE 5 OF YOUR ENEMIES TO WIN THIS FIGHT")
print (" IF THE ZOMBIES HIT MORE OFTEN THAN YOU, YOU WILL DIE" )
print ("~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~")
time.sleep(4)
humans = int(random.randint(3, 10))
zombies = int(random.randint(1, 5))
print ("You hit ", humans, "times.")
time.sleep(2)
print ("The Zombies hit ", zombies, "times.")
time.sleep(2)
if zombies > humans:
print ("The Zombies have dealt more damage than you!")
time.sleep(3)
print ("You can't make it out alive... You die a heroic death....")
time.sleep(3)
playAgain = input ("Do you want to try to climb the wall again? God seems to give you another chance...")
if playAgain == "yes" or playAgain == "Yes" or playAgain == "yes!":
rightpathFunction()
else:
print ("Okay! See you next time!")
else:
print ("You won the fight!")
time.sleep(3)
print ("That was amazing! But we have no to time to rest on our success, let's go on.")
missionFunction()
#def schoolFunction():
#print ("Hmmmmm... Let's split up, so if she's here, we can find her faster.")
#time.sleep(3)
#print ("If somebody finds her, he contacts the rest of us via the walkie talkie!")
#->choose random string from List
#schoolyesno = ["shhhht....shtshht... (out of the walkie talkie) I found her! Come to room 143.", "shhhht....shtshht... (out of the walkie talkie) I think there is nobody around... Let's search somewhere else..."]
#print (random.choice(schoolyesno))
#if schoolyesno == "shhhht....shtshht... (out of the walkie talkie) I found her! Come to room 143.":
#room143Function()
#if schoolyesno == "shhhht....shtshht... (out of the walkie talkie) I think there is nobody around... Let's search somewhere else...":
#missionFunction()
#schoolyesno = random.randint(1, 2)
#if schoolyesno == 1:
#print ("shhhht....shtshht... (out of the walkie talkie) I found her! Come to room 143.")
#room143Function()
#if schoolyesno == 2:
#print ("shhhht....shtshht... (out of the walkie talkie) I think there is nobody around... Let's search somewhere else...")
def missionFunction(): #where to go and if the girl is found
print ("We need to find the girl. She is the key to everything that happended here. If we can find out what turned her to what ever she might be now,\nwe might find the cause and can save our families... ")
time.sleep(4)
print ("We assume the girl to be around either her school, her home or the church of the town. As you brang us good luck last time, you should decide again.")
time.sleep(3)
schoolhomechurch = input ("What do you think? Should we search for her at school (1), at her families home (2) or at church (3)?\nJust answer '1', '2' or '3'!\n")
time.sleep(3)
if schoolhomechurch == "1":
print("- you go to the school -")
time.sleep(3)
print("Hmmmmm... Let's split up, so if she's here, we can find her faster. But be careful that her friends do not see you!")
schoolyesno = random.randint(1,2)
if schoolyesno == 1:
time.sleep(4)
print ("HERE SHE IS!!!")
time.sleep(3)
print (".....")
time.sleep(3)
print ("Now that we know what happened to her, we can go home and carry on research for couring sickened people.")
time.sleep(3)
print ("And when we find a remedy, we'll come back and try to bring this town the peace it once held.")
time.sleep(5)
print ("... to be continued,extended and improved...")
if schoolyesno == 2:
time.sleep(4)
print ("I think there is nobody around... Let's search somewhere else...")
missionFunctionAS()
if schoolhomechurch == "2":
print ("- you go to the families home -")
time.sleep(3)
print ("Hmmmmm... Let's split up, so if she's here, we can find her faster. But be careful that her parents do not see you!")
homeyesno = random.randint(1,2)
if homeyesno == 1:
time.sleep(4)
print ("HERE SHE IS!!!")
time.sleep(3)
print (".....")
time.sleep(3)
print ("Now that we know what happened to her, we can go home and carry on research for couring sickened people.")
time.sleep(3)
print ("And when we find a remedy, we'll come back and try to bring this town the peace it once held.")
time.sleep(5)
print ("... to be continued,extended and improved...")
if homeyesno == 2:
time.sleep(4)
print ("I think there is nobody around... Let's search somewhere else...")
missionFunctionAS()
if schoolhomechurch == "3":
print ("- you go to the church -")
time.sleep(3)
print ("*whispering* Wow... this is an amazing building!... But pretty scary as well...")
time.sleep(3)
print ("LOOK! There she is... At the confessional...")
time.sleep(3)
print (" ......... ")
time.sleep (3)
print ("Now that we know what happened to her, we can go home and carry on research for couring sickened people.")
time.sleep(3)
print ("And when we find a remedy, we'll come back and try to bring this town the peace it once held.")
time.sleep(5)
print ("... to be continued,extended and improved...")
def rightpathFunction(): #which path to get into the town? -> 1. stop to be kicked out of the game!!
time.sleep(4)
print ("There are two ways to get into the city: We could climb the wall (1) or take the secret tunnel (2).\nBoth have their risks.")
time.sleep(4)
print ("If we climb the wall and somebody sees us we will be dead by the time we arrive on the other side.\nIn the tunnel there are poisonous plants that randomly eject deadly gas that kills immediatly when inhaled.")
time.sleep(4)
chosenPath = input ("Which path should we try? 1 or 2 ? \n")
time.sleep(3)
print ("Okay... Let's take it! There's no wrong or right decision, it's just good or bad luck for us right now...")
time.sleep(3)
correctPath = random.randint(1,2)
if str(chosenPath) == str(correctPath):
print ("YES! You are amazing! We're inside! You will make all the decisions from now.")
missionFunction()
if str(chosenPath) != str(correctPath):
print ("Oh....")
time.sleep(3)
print ("Ooooooooh NO !!!")
time.sleep(3)
print ("We...won't make it.")
time.sleep(3)
print ("----------------------------game over------------------------------")
time.sleep(3)
playAgain = input ("Do you want to choose again?")
if playAgain == "yes" or playAgain == "Yes" or playAgain == "yes!":
rightpathFunction()
else:
print ("Okay! See you next time!")
def stillinFunction():
stillin = input ("Are you still willing to come with us?\n")
if stillin == "yes" or stillin == "Yes" or stillin == "yes!":
print ("Wow, I'm impressed. We can really need somebody brave like you. Which path shall we take?")
rightpathFunction()
if stillin == "no" or stillin == "No" or stillin == "no!":
print ("Okay... We totally understand your choice. Goodbye!")
if stillin != "yes" and stillin != "Yes" and stillin != "yes!" and stillin != "no" and stillin != "No":
stillinFunction() #still in after hearing the whole story #still in after hearing the whole story?
def wholestoryFunction(): #beeing told the whole story
wholestory = input("Do you still want to hear the whole story? You might change your mind after hearing it...\n")
if wholestory == "yes" or wholestory == "Yes" or wholestory == "yes!":
print ("So you seem to be one of the fearless ones...")
time.sleep(3)
print ("Fine. Here's the end of the tragedy.")
time.sleep(3)
print ("One day the little daughter of the mayor got missing.")
time.sleep(3)
print ("Nobody could imagine what could've happened to her, the girl was a good kid who woul've never run away.")
time.sleep(4)
print ("Moreover there was no ransom demand or anything similar that could've indicated a kidnap.")
time.sleep(4)
print ("The whole town was searching for her for 3 whole months.")
time.sleep(3)
print ("But then one day, all of a sudden, she came home to the front door as if nothing had ever happened.")
time.sleep(5)
print ("She was completly unharmed and at first showed no signs of mental problems,\nexcept that she couldn't remember anyhting from the last quarter of the year.")
time.sleep(6)
print ("The little girl went back to school just one day after beeing back home and everything seemed normal until the some kids\nin the class of the little girl got sick.")
time.sleep(6)
print ("From one day to another, they lost their ability to speak.")
time.sleep(4)
print ("In addition, they had anxiety attacks and always their face was contorted with pain. No doctor knew what to do...")
time.sleep(4)
print ("At first many children fell ill, but when the first parent fell sick, everyone knew, that it was a matter of time when the whole town would be infected.")
time.sleep(4)
print ("Panic broke out. Parents needed to decide - stay with their infected children or leave before it was too late.")
time.sleep(5)
print ("Many people left. But some stayed...")
time.sleep(3)
print ("And they still 'live' there. But they became something similar to zombies.")
time.sleep(4)
print ("Until now, they couldn't leave because of the wall the fleeing inhabitants built around their hometown,\nbut it's getting ramsackle...")
time.sleep(5)
print ("We need to get in and find the cause for the virus or whatever it may be, before they break out and infect all the adjoining villages.")
stillinFunction()
if wholestory == "no" or wholestory == "No" or wholestory == "no!":
print ("I understand, let's just get in there and try to get out alive. You can choose which path we take to go there.")
rightpathFunction()
if wholestory != "yes" and wholestory != "Yes" and wholestory != "yes!" and wholestory != "no" and wholestory != "No":
wholestoryFunction()
#else:
#wholestoryFunction()
def mainFunction():#mainFunction
nameFunction()
readyFunction()
wholestoryFunction()
"""This is my docstring, the parser will (sortof) ignore it"""
\$\endgroup\$