I'm trying to make a text based game using Python and I'm trying to add a travel system to the game
I'm using three variables for travel two integers for locations (a & b) and a string to tell the player the location(locationstr)
the code assigns values to a and b by input and supposed to give a value to locationstr based on values of a and b but even though a and b changes locationstr does not
here is the code
#Variables
day = 0
health = 100
healcheck = 0
food = 100
foodcheck = 0
#location = 0
travelcheck = 0
trvlchkr2 = 0
#new travel system variables
a = 3
b = 3
#Location definitions
"""if (location == 0):
locationstr = "Center"
elif (location == 1):
locationstr = "Northwest"
elif (location == 2):
locationstr = "North"
elif (location == 3):
locationstr = "Northeast"
elif (location == 4):
locationstr = "East"
elif (location == 5):
locationstr = "Southeast"
elif (location == 6):
locationstr = "South"
elif (location == 7):
locationstr = "Southwest"
elif (location == 8):
locationstr = "West"""
#New Location definitions
if (a == 1 and b == 1):
locationstr = "the Northwestern corner of the Wilds"
elif(a == 1 and b == 2):
locationstr = "the Western border of the Wilds"
elif(a == 1 and b == 3):
locationstr = "the Western border of the Wilds"
elif(a == 1 and b == 4):
locationstr = "the Western border of the Wilds"
elif(a == 1 and b == 5):
locationstr = "the Southwestern corner of the Wilds"
elif(a == 2 and b == 1):
locationstr ="the Northern border of the Wilds"
elif(a == 3 and b == 1):
locationstr ="the Northern border of the Wilds"
elif(a == 4 and b == 1):
locationstr ="the Northern border of the Wilds"
elif(a == 5 and b == 1):
locationstr ="the Northeastern corner of the Wilds"
elif(a == 5 and b == 2):
locationstr = "the Eastern border of the Wilds"
elif(a == 5 and b == 3):
locationstr = "the Eastern border of the Wilds"
elif(a == 5 and b == 4):
locationstr = "the Eastern border of the Wilds"
elif(a == 5 and b == 5):
locationstr = "the Southeastern corner of th Wilds"
elif (a == 2 and b == 5):
locationstr = "the Southern border of the Wilds"
elif (a == 3 and b == 5):
locationstr = "the Southern border of the Wilds"
elif (a == 4 and b == 5):
locationstr = "the Southern border of the Wilds"
elif (a == 3 and b == 3):
locationstr = "the Center of the Wilds"
elif (a == 2 and b == 2):
locationstr = "the Northwestern plains of the Wilds"
elif (a == 2 and b == 3):
locationstr = "the Western plains of the Wilds"
elif (a == 2 and b == 4):
locationstr = "the Southwestern plains of the Wilds"
elif (a == 3 and b == 2):
locationstr = "the Northern plains of the Wilds"
elif (a == 4 and b == 2):
locationstr = "the Northeastern plains of the Wilds"
elif (a == 4 and b == 3):
locationstr = "the Eastern plains of the Wilds"
elif (a == 4 and b == 4):
locationstr = "the Southeastern plains of the Wilds"
elif (a == 3 and b == 4):
locationstr = "the Southern plains of the Wilds"
#Game
print("DAY", day)
print("Health", health, "/100")
print("Food", food, "/100")
print("You are currently in", locationstr)
print("Debug: a", a)
print("Debug: b", b)
while (day < 31):
#Choices
if (health < 100 and healcheck < 1):
print("Looks like you got hurt")
print("Do you want to heal yourself?")
print("(H)eal")
if (food < 100 and foodcheck < 1):
print("Looks like you are hungry")
print("Do you want to eat something")
print("(E)at")
if (travelcheck < 1):
print("Do you want to travel somewhere?")
print("(T)ravel")
else:
print("It looks like there is nothing left to do today")
print("Do you want to end the day?")
print("(Y)es")
print("(N)o")
#Choice input
x = input("What is your choice?")
if (x == "Y" or x == "y"):
#Ending the day
print("You decided to end the day")
day = day + 1
health = health - 10
food = food - 10
healcheck = 0
foodcheck = 0
travelcheck = 0
print("################################################################################################")
print("DAY", day)
print("Health", health, "/100")
print("Food", food, "/100")
print("You are currently in", locationstr)
print("Debug: a", a)
print("Debug: b", b)
elif (x == "N" or x == "n"):
print("################################################################################################")
print("You decided to not end the day")
elif ((x == "H" or x == "h") and healcheck < 1):
print("################################################################################################")
print("You decided to heal yourself")
health = health + 10
healcheck = 1
print("Health", health, "/100")
elif ((x == "E" or x == "e") and foodcheck < 1):
print("################################################################################################")
print ("You decided to eat something")
food = food + 10
foodcheck = 1
print("Food", food, "/100")
elif ((x == "T" or x == "t") and travelcheck < 1):
#Travel system
print("################################################################################################")
print("You decided to travel somewhere")
print("Where to travel?")
print("(1) Northwest")
print("(2) North")
print("(3) Northeast")
print("(4) East")
print("(5) Southeast")
print("(6) South")
print("(7) Southwest")
print("(8) West")
print("(9) Cancel")
trvlchkr2 = 1
ti = input("What is your choice?")
if(ti == "1" and trvlchkr2 == 1):
#location = 1
a = a - 1
b = b -1
trvlchkr2 = 0
travelcheck = 1
print("################################################################################################")
print("You traveled to", locationstr)
elif (ti == "2" and trvlchkr2 == 1):
#location = 2
b = b -1
trvlchkr2 = 0
travelcheck = 1
print("################################################################################################")
print("You traveled to", locationstr)
elif (ti == "3" and trvlchkr2 == 1):
#location = 3
a = a + 1
b = b - 1
trvlchkr2 = 0
travelcheck = 1
print("################################################################################################")
print("You traveled to", locationstr)
elif(ti == "4" and trvlchkr2 == 1):
#location = 4
a = a + 1
trvlchkr2 = 0
travelcheck = 1
print("################################################################################################")
print("You traveled to", locationstr)
elif(ti == "5" and trvlchkr2 == 1):
#location = 5
a = a + 1
b = b + 1
trvlchkr2 = 0
travelcheck = 1
print("################################################################################################")
print("You traveled to", locationstr)
elif(ti == "6" and trvlchkr2 == 1):
#location = 6
b = b +1
trvlchkr2 = 0
travelcheck = 1
print("################################################################################################")
print("You traveled to", locationstr)
elif(ti == "7" and trvlchkr2 == 1):
#location = 7
a = a - 1
b = b + 1
trvlchkr2 = 0
travelcheck = 1
print("################################################################################################")
print("You traveled to", locationstr)
elif(ti == "8" and trvlchkr2 == 1):
#location = 8
a = a - 1
trvlchkr2 = 0
travelcheck = 1
print("################################################################################################")
print("You traveled to", locationstr)
elif(ti == "9" and trvlchkr2 == 1):
trvlchkr2 = 0
print("################################################################################################")
print("You decided traveling was a bad idea")
else:
print("################################################################################################")
print(ti, "is not a valid choice")
else:
print(x, "is not a valid choice")
#Game Overs
if (health == 0):
print("################################################################################################")
print("You Died!")
print("Death Cause: Poor Health")
exit()
if (food == 0):
print("################################################################################################")
print("You Died!")
print("Death Cause: Hunger")
exit()
print("################################################################################################")
print("GAME OVER")
Note: I used an old travel system by two variables(location and locatşonstr) it was working but it wasn't efficient so i decided to change the travel system
Aucun commentaire:
Enregistrer un commentaire