HI I am new to .py and I am having a bit of trouble making the rooms and items do what I want any help will be much appreciated. : )
print """
TIBBYS LITTLE ADVENTURE EPISODE ONE
Tibby the cat wakes up and is hungry,
he decides to go and find some food."""
#Indented that way for presentational purposes.
#Giving the player the instructions for the game.
print """
You will be using the QWERTY Keybord for the game,
input can be in either upper or lowercase."""
print"""
North: n or N
East: e or E
West: w or W
Sout: s or S
Take Object: either t or T
Punch enemy: either p or P
Drop Object: either d or D
"""
print"To quit the game, type quit"
#lists to initialsie the objects and rooms
location = 0
room0moves = ['E','e','Q','q']
room1moves = ['W','w','S','s','Q','q']
room2moves = ['N','n','E','e','Q','q']
room3moves = ['N','n','W','w','Q','q']
room4moves = ['S','s','E','e','Q','q']
room5moves = ['Q','q']
room0items = []
room1items = ['Boxing Gloves']
room2items = []
room3items = []
room4items = []
room5items = []
room0enemy = []
room1enemy = ["Rio"]
room2enemy = ["Fluffy"]
room3enemy = ["Jimbo"]
room4enemy = ["Ronnie the Rat"]
room5enemy = []
playerItems = []
boxinggloves = ['D','d','A','a','NO','no']
empty = ['P','p','NO','no']
noMoves = ['no','NO']
BG = "Boxing Gloves"
#defining the funtion get move
#and to promt the user to select move
def getMoves(movelist):
print "moves available for you are:", movelist
place = raw_input ("What is your action?")
while not place in movelist:
print "Unavailiable"
print "moves available for you are", movelist
place = raw_input ("What is Your action?")
return place
#definig the room objects and the moves in the rooms
def getNextMoves():
if BG in playerItems:
choice = getMoves(boxinggloves)
elif location == 0:
if BG in room0items:
choice = getMoves(movelist)
else:
choice = getMoves(room0moves)
elif location == 1:
if BG in room1items:
choice = getMoves(empty)
else:
choice = getMoves(room1moves)
elif location == 2:
if BG in room2items:
choice = getMoves(empty)
else:
choice = getMoves(room2moves)
elif location == 3:
if BG in room3items:
choice = getMoves(empty)
else:
choice = getMoves(room3moves)
elif location == 4:
if BG in room5items:
choice = getMoves(empty)
else:
choice = getMoves(room4moves)
elif location == 5:
if BG in room5items:
choice = getMoves(empty)
else:
choice = getMoves(room5moves)
return choice
#defining the direction getRoomMoves and promting the user to choose a direction
def getRoomMoves (checklist):
print "moves available for you are:", checklist
place = raw_input ("what is your action?")
while not place in checklist:
print "My freind that is wrong answer!, type something else please."
print "direction moves available to Tibby are", checklist
place = raw_input ("what is your action?")
return place
# THis will show what objects and enimeis are in the room to each user.
def showlocation():
if location == 0:
print "Garden."
print "\nroom items:"
showItems(room0items)
print "\nEnemy:\n"
showEnemy(room0enemy)
if location == 1:
print "Your House"
print "\nroom items:"
showItems(room1items)
print "\nEnemy:\n"
showEnemy(room1enemy)
if location == 2:
print "Garden of Fluffy the Cat."
print "\nroom items"
showItems(room2items)
print "\nEnemy:\n"
showEnemy(room2enemy)
if location == 3:
print "Garden of Jimbo the Mut."
print "\nroom items:"
showItems(room3items)
print "\nEnemy:\n"
showEnemy(room3enemy)
if location == 4:
print "Alley of Ronnie the Rat."
print "\nroom items:"
showItems(room4items)
print "\nEnemy:\n"
showEnemy(room4enemy)
if location == 5:
print "5"
print "\nroom items:"
showItems(room5items)
print "\nEnemy:\n"
showEnemy(room5enemy)
def showItems(checklist):
for item in checklist:
print item
def showEnemy(checklist):
for item in checklist:
print item
def addItem (checklist, item):
checklist.append(item)
def removeItem (checklist, item):
checklist.remove(item)
def getNextRoomMoves():
if location ==0:
place = getRoomMoves(room0moves)
if location ==1:
place = getRoomMoves(room1moves)
if location ==2:
place = getRoomMoves(room2moves)
if location ==3:
place = getRoomMoves(room3moves)
if location ==4:
place = getRoomMoves(room4moves)
if location ==5:
print "Tibby survived another day; you have won dude"
place = getRoomMoves(room5moves)
return place
#Tells the user were they are.
print "You are in the:"
showlocation()
move = getNextMoves() #
roomMove = getNextRoomMoves()#
#allows user to pick up and drop objects
while not roomMove in ['quit','Quit']:
if move in ['P','p']:
addItem(playerItems, BG)
if location == 0:
removeItem(room0items, BG)
elif location == 1:
removeItem(room1items, BG)
elif location == 2:
removeItem(room2items, BG)
elif location == 3:
removeItem(room3items, BG)
elif location == 4:
removeItem(room4items, BG)
elif location == 5:
removeItem(room5items, BG)
elif move in ['D','d']:
removeItem(playerItems, BG)
if location == 0:
addItem(room0items, BG)
elif location == 1:
addItem(room1items, BG)
elif location == 2:
addItem(room2items, BG)
elif location == 3:
addItem(room3items, BG)
elif location == 4:
addItem(room4items, BG)
elif location == 5:
addItem(room5items, BG)
#Freinds and enemys in the game.
elif move in ['A','a']:
if location == 1:
if playerItems == ["Boxing Gloves"]:
print "You killed Rio"
room1enemy.remove("Rio")
else:
print "you were killed by Rio\n GAME OVER!!!"
break
elif location != 1:
print "nothing to attack"
elif move in ['A','a']:
if location == 2:
if playerItems == ["Boxing Gloves"]:
print "goodbye Fluffy"
room2enemy.remove("Fluffy")
else:
print "Fluffy the cat Killed you\n GAME OVER!!!"
break
elif location != 2:
print "nothing to attack"
elif move in ['A','a']:
if location == 3:
if playerItems == ["Boxing Gloves"]:
print "you killed Jimbo"
room1enemy.remove("Jimbo")
else:
print "Roof AM top dog ruff\n GAME OVER!!!"
break
elif location != 3:
print "nothing to attack"
elif move in ['A','a']:
if location == 4:
if playerItems == ["Boxing Gloves"]:
print "the rat went splat"
room1enemy.remove("Ronnie the Rat")
else:
print "The rat killed the cat\n GAME OVER!!!"
break
elif location != 4:
print "nothing to attack"
#rooms and available directions to move in
if location == 0:
if roomMove in ['E','e']:
location = 1
elif location == 1:
if roomMove in ['W','w']:
location = 0
if roomMove in ['S','s']:
location = 2
elif location == 2:
if roomMove in ['E','e']:
location = 3
if roomMove in ['N','n']:
location = 1
elif location == 3:
if roomMove in ['N','n']:
location = 4
if roomMove in ['W','w']:
location = 2
elif location == 4:
if roomMove in ['E','e']:
location = 5
if roomMove in ['S','s']:
location = 3
elif location == 5:
print "Tibby survived another day; you have won dude"
break
#Shows the location on screen.
print "you are in the:"
showlocation()
move = getNextMoves()
roomMove = getNextRoomMoves()
print "inventory"
showItems (playerItems)
print "GAME OVER!!!"
Editor's Note: added proper code tags