Edit: Looks like my main problem was, for whatever reason, having the boolean operator "or" in my choices would default the user to playing both choices, or the affirmative one instead of the negative one. If anyone can explain why, I would greatly appreciate it.
I am a novice to Python 3, that is probably obvious, so hopefully this is a simple fix. I really want to complete this game as it is one of the only projects I find as a "fun" way to learn that constantly keeps me focused (and frustrated). I would also eventually like to add more complicated features like a user inventory. I have been following some function-based youtube guides and essentially some paths in my game work (north>>west>>fight) while some do not (north>>east>>no). In the latter case, my program chooses "Y" every time on the third choice the player makes, even if the player writes "N". The issue pops up several other times in this chunk of code. Here, I'll show you(and if you see anything else fundamentally wrong with my code, let me know):
#Author: Joseph C 2021
# Cyoa (Kyoa) is a text-based fantasy game set in the realm of Kyoa. The Traveller awakens empty-handed and
# without any inkling of memory about who s/he is or what this strange medieval motor-punk world has to offer...
import random
import time
def playagain():
answer = input("Do you want to play again? Y or N")
if answer == "Y":
print("OK.")
chapter1()
elif answer == "N":
print("Goodbye.")
def Intro():
print("Hey there...")
time.sleep(.5)
print("Hello?!")
time.sleep(1.5)
print("WAKE UP!")
time.sleep(1)
print("You awaken under a bodhi tree, to the annoying chirp of your Lilliputian fairy ally, Pyxys. She soon figures")
print("that you've lost your memory due to the encounter up north, and respawned in the middle of a hilly field.")
print("As a blank slate and denizen of the uncharted realm of Kyoa, you and Pyxys decide to explore once more.")
def chapter1():
choice = input("Do you choose to go north, south, east, or west? \n")
if choice == "north":
print("You move forward in this direction. You witness a murder of winged orca whales in the blue, star"
"covered yet daylit sky.")
chapter1north()
if choice == "east":
chapter1east()
if choice == "south":
print("You walk a lot, pass by a lake with a distant background mountain range, and finally")
print("come across an abandoned town. You loot a house and find a sack of gold! But suddenly,")
print("a cohort of Vector Vipers and Glue Goblins gang up on you! You have died.")
playagain()
if choice == "west":
print("You walk a lonely, boring path that twists and wanes but ultimately points west.")
print("Before you know it, you stand before a tall evergreen forest, densely packed with")
print("rocks and trees.")
chapter2SF()
def chapter1north():
time.sleep(.5)
print("You continue walking north...")
time.sleep(1)
print("You come across a dense carniferous forest on the horizon to the east, and more spacious hillsides to"
"the west.")
choice = input("Will you go west toward the hilly plains, or east toward the dense woods? \n")
if choice == "west":
print("As you tread upon the hills towards the northwest, you encounter a spinfoam slime!")
decision = input("Fight or flee?")
if decision == "fight":
print("You stomp on the paltry slime multiple times until it dissociates, bubbling into gas!"
"Congratulations! You gained 2 XP!")
chapter2()
if decision == "flee":
print("You evade the paltry slime, yet you hear something from a distance...")
time.sleep(1)
print("The spinfoam slime sends a torrent of electricity towards you, burning you to a crisp!"
"You have died.")
playagain()
if choice == "east":
print("You approach the thick forest, which you find is gated by barbed wire.")
time.sleep(1) #at this point the code starts to bug. Maybe I need to make this in a new function
InsectForestEntrance()
def InsectForestEntrance():
decision2 = input("You decide to walk amid the perimeter of the barbed forest, heading in the"
"east and southeast directions...You manage to find an entrance."
" Will you enter? (Y or N)\n")
if decision2 == "yes" or "Y":
print("You enter the Insect Forest...")
time.sleep(1)
chapter1insectforest()
elif decision2 == "no" or "N":
print("You decide to travel south, as the forest expands throughout the entirety of the north.")
chapter1east()
def chapter1insectforest():
print("Immediately, the forest forks into two paths: one going northbound, the other southeastern.")
decision2a = input("Which one will you take? north or southeast?")
if decision2a == "north":
pass
if decision2a == "southeast":
print("You go")
def chapter2():
pass
def chapter3():
pass
def chapter4():
pass
Intro()
chapter1()