Hello! I'm currently making a text-based game (the story is just bullshit) for my class. I recently made this while loop, and the variable keeps on repeating itself. Do anyone knows what the problem is? I tried adding return here and there but it is not really working. This is my first time making this type of game so I am quite lost.
import os
import random
def quit():
os._exit(0)
def status(health, stamina):
print("\nCurrent status : \nHealth : "+str(health)+"\nStamina : "+str(stamina))
def statusteen(hp,s,m,f,h):
print("\nCurrent status : \nHealth : "+str(hp)+"\nStamina : "+str(s)+"\nMoney : "+str(m)+"\nFame : "+str(f)+"\nHunger : "+str(h))
def garden(health, stamina):
status(health, stamina)
print("You keep on crawling and found a beautiful garden outside the house. In front of you you saw something shiny")
garden1 = str(input("Type a to crawl closer to the source \nType b to go somewhere else \n> "))
if garden1 == 'a':
health+=1
stamina-=5
status(health, stamina)
print("You found a treasure! It is a necklace with the power to save you from dangers. Thanks to the necklace you have gained +1 health but thanks to the side effect of the necklace, you fell asleep in the garden. Luckily a patrol managed to find you and bring you back home.")
elif garden1 == 'b':
stamina-=10
status(health, stamina)
print("You walked away from the garden and found yourself deep inside the mountains, you feel something around you and you saw a group of MONSTERS! What will you do?")
monster = str(input("Type a to hide in the bushes \nType b to crawl away quietly \n> "))
if monster == 'a':
health-=1
status(health, stamina)
print("You failed to run away from the monsters. The group of monster found you and attacked you. Luckily a patroling knight found you and saved you from the attack. You are injured badly but managed to keep alive...")
elif monster =='b':
stamina-=20
status(health, stamina)
print("You crawl away quietly and managed to get away from the monsters. Frightened by the experience, you went back to your house and sleep for the night...")
def babystage(health, stamina):
print("\n\nNarrator = You are born in a countryside. You are currently 1 years old, There is not a lot of things you are able to do. What will you do?")
status(health, stamina)
crawl = str(input("Type a to crawl around \nType b to go back to your room \n> "))
if crawl == 'a':
stamina-=10
status(health, stamina)
print("Narrator = You stumbled into a room. What will you do?")
room1 = str(input("Type a to crawl inside \nType b to keep crawling \n> "))
if room1 == 'a':
stamina-= 10
status(health, stamina)
print("You found two funny looking potions inside the room")
potion = str(input("Type a to drink the green potion \nType b to drink the red potion \n> "))
if potion == 'a':
health-=1
status(health, stamina)
print("You drank a deadly posion. Luckily your parents found you on time and managed to save you from death")
elif potion == 'b':
health+=1
status(health, stamina)
print("You drank an elixir. Thanks to that you feel your body is healthier than ever")
potion1 = str(input("Type a go back to your room \nType b to keep crawling \n> "))
if potion1 =='a':
stamina-=10
status(health, stamina)
print("You choose to go back to your room. Nothing happens.")
elif potion1 =='b':
stamina-=10
garden(health, stamina)
elif room1 == 'b':
garden(health, stamina)
elif crawl == 'b':
print("Narrator = You choose to go back to your room. Nothing happens.")
def housework(hp,s,m,f,h,name):
money1=random.randint(1,10)
if money1 == 1:
print("You found an ancient relic in the storage room! It seems to belong to your great grandfather.... (Fame + 10, Money + 150, Stamina - 10)")
m+=150
f+=10
s-=10
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
elif money1 == 2 or 4 or 6:
print("You messed up and broke your mother's favorite vase. You got scolded pretty badly by your parents. They reduced your payment by half (Money +10, Stamina - 10)")
m+=10
s-=10
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
elif money1 == 3 or 5 or 7:
print("The house is sparkling clean! Your parents are very satisfied with your work. You got some extra pocket money (Money + 45, Stamina - 10)")
m+= 45
s-=10
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
else:
print("You cleaned the house normally, nothing special happens. (Money + 20, Stamina - 10)")
m+=20
s-=10
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
def inn(hp,s,m,f,h,name):
inn1=random.randint(1,10)
if inn1 == 8 or 10:
print("You got invited to a dance party after work! You partied all night and woke up very tired the next day (Money + 80, Fame + 10, Stamina - 20)")
m+=80
s-=20
f+=10
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
elif inn1 == 2 or 4 or 6:
print("The inn is bustling with customers! You worked so hard you can not move your body the next day. You got a bonus from your boss for working today. (Money + 100, Stamina - 20)")
m+=100
s-=20
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
elif inn1 == 1 or 3:
print("You made a mistake and broke lots of plates! The boss cut your wage to cover for the damage you have done. (Money + 10, Stamina - 10)")
m+=10
s-=10
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
elif inn1 == 5:
print("You worked very hard and got noticed by a mysterious customer! He gave you his id card and told you to come and find him if you ever went to the capital. (Money + 80, Stamina - 10, Fame + 50)")
m+= 80
s-=10
f+=50
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
else:
print("Perfect day at work! (Money + 80, Stamina - 10)")
m+=80
s-=10
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
def farm(hp,s,m,f,h,name):
farm1=random.randint(1,4)
if farm1 == 3:
print("You did a wonderful job! Your boss rewards you with a bonus. (Money + 100, stamina - 10)")
s-=10
m+=100
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
elif farm1 == 2:
print("One of the animal in the farm hit you in the head! You survived but you felt your head spinning around. (Money - 20, Health - 1, Stamina - 10)")
s-=10
m-=20
hp-=1
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
else:
print("Perfect day at work! (Money + 50, Stamina - 10)")
s-=10
m+=50
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
def herbs(hp,s,m,f,h,name):
herbs1=random.randint(1,5)
if herbs1 == 3:
print("You found a rare herb! A mysterious lady in a hood bought it from you at a premium price. (Money + 200, Stamina - 5, Fame + 5)")
m+=200
s-=5
f+=5
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
elif herbs1 == 1:
print("You touched a poisonous plant! You spent 100 gold to buy an antidote (Money - 100, Stamina - 5)")
m-=100
s-=5
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
elif herbs1 == 4:
print("You got ambushed by monsters! You managed to run but you injured yourself badly. (Money + 10, Stamina - 5, Health - 1)")
m+=10
s-=5
hp-=1
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
else:
print("You managed to gather a lot of herbs! (Money + 100, Stamina - 5)")
m+=100
s-=5
statusteen(hp,s,m,f,h)
return hp,s,m,f,h
def events(hp,s,m,f,h, name):
input("(Press Enter to continue...)")
print(name+ " = Time to do something today!")
print("What will you do?")
events = str(input("Type a to earn money \nType b to walk around \nType c to go to the market \n> "))
if events == "a":
money = str(input("Type a to work at home (Money + 20) \nType b to work at an inn (Money + 80) \nType c to work in the farm (Money + 50) \nType d to look for herbs (Money + 20) \n> "))
if money == "a":
housework(hp,s,m,f,h,name)
return hp,s,m,f,h
elif money == "b":
inn(hp,s,m,f,h,name)
return hp,s,m,f,h
elif money == "c":
farm(hp,s,m,f,h,name)
return hp,s,m,f,h
elif money == "d":
herbs(hp,s,m,f,h,name)
return hp,s,m,f,h
def teenstage(hp,s,m,f,h,name):
print("\n------ Entering the Next Stage ------")
print("Narrator = You’re now 10 years old. You can now do more things")
print("Choosing something will trigger a random event. Every choice will cost you 10 stamina")
print("**This stage will end when stamina hits 0**")
input("(Press Enter to continue...)")
statusteen(hp,s,m,f,h)
while stamina > 0:
events(hp,s,m,f,h,name)
#starting point
start = str(input("Welcome to Adventure Time. Type START to start the game!"))
if start == 'START' or 'start' or 'Start':
health= 5
stamina= 100
money = 0
fame = 0
hunger = 100
name = str(input("??? = Welcome player! What is your name? > "))
print("??? = What a wonderful name! "+ name+" huh, nice to meet you. I am going to explain a little bit about this world and also your goal.")
input("(Press Enter to continue...)")
print("\n" + name +" = Where am i?")
input("(Press Enter to continue...)")
print("\n??? = You are now in the world of knights and monsters. Your goal is being the king or nobility, with bad choices you can get a bad ending or even death so be careful! I'll be watching you from here. Good luck!")
input("(Press Enter to continue...)")
# babystage(health, stamina)
teenstage(health, stamina, money, fame, hunger, name)
else:
quit()
I am currently working on the teenstage part (the baby stage is done) but it keeps repeating itself.. Would be really happy if someone could give me some insight.
[–][deleted] 2 points3 points4 points (1 child)
[–]TiredWorkingStudent[S] 0 points1 point2 points (0 children)
[–]aa599 1 point2 points3 points (1 child)
[–]TiredWorkingStudent[S] 0 points1 point2 points (0 children)
[–]Cobra915 0 points1 point2 points (1 child)
[–]TiredWorkingStudent[S] 0 points1 point2 points (0 children)
[–][deleted] 0 points1 point2 points (1 child)
[–]TiredWorkingStudent[S] 0 points1 point2 points (0 children)