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
#new travel system variables
a = 3
b = 3
#New Location definitions
if (a == 3 and b == 3):
locationstr = "the Center of the Wilds"
elif (a == 2 and b == 2):
locationstr = "the Northwestern plains of the Wilds"
#Game
print("You are currently in", locationstr)
print("Debug: a", a)
print("Debug: b", b)
while True:
print("Do you want to travel somewhere?")
print("(T)ravel")
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")
print("###########################################################################")
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 == "T" or x == "t"):
#Travel system
print("###########################################################################")
print("You decided to travel somewhere")
print("Where to travel?")
print("(1) Northwest")
ti = input("What is your choice?")
if(ti == "1"):
a = a - 1
b = b -1
print("########################################################################")
print("You traveled to", locationstr)
print("Debug: a", a)
print("Debug: b", b)
else:
print("#######################################################################")
print(ti, "is not a valid choice")
else:
print(x, "is not a valid choice")
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