Advertisement
D10d3

inflight.py

Nov 13th, 2016
163
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.66 KB | None | 0 0
  1. import engine
  2. import rooms
  3.  
  4. def main():
  5.     t = rooms.TestRoom()
  6.     print t
  7.        
  8. if __name__ == "__main__": # this part
  9.     main()
  10.    
  11.    
  12. # #GET
  13. # #DROP
  14. # #USE
  15. # GO
  16. # QUIT
  17. # STATUS
  18.  
  19. class Game(object):
  20.     def __init__(self):
  21.         # Standards for room names
  22.         self.roomList = {"North Hall": NorthHall(),
  23.                          "South Hall": SouthHall(),
  24.                          "Test Room": TestRoom()}
  25.         self.currentRoom = roomList["Test Room"]
  26.     def __repr__(self):
  27.         rstring = str(self.currentRoom) + "\n"
  28.         rstring += self.currentRoom.exitsString()
  29.     def getInput(self):
  30.         i = raw_input("> ")     # > VERB NOUN
  31.         i = i.lower
  32.         return i.split()        # ["VERB", "NOUN"]
  33.     def move(self, direction):
  34.         # arg direction is a direction string
  35.         newRoom = self.currentRoom.getExitDirection(direction)
  36.         if newRoom:
  37.             self.currentRoom = roomList[newRoom]
  38.     def useItem(self, item):
  39.         pass
  40.     def getItem(self, item):
  41.         pass
  42.     def dropItem(self, item):
  43.         pass
  44.     def quitGame(self, item):
  45.         # Maybe import sys later
  46.         quit()
  47.     def mainLoop(self):
  48.         print self
  49.         commandList = {"go": self.move,
  50.                        "quit": self.quitGame}
  51.         userInput = self.getInput()
  52.         verb = userInput[0]
  53.         if len(userInput) > 1:
  54.             noun = userInput[1]
  55.         else:
  56.             noun = None
  57.         if verb in commandList:
  58.             if noun:
  59.                 commandList(noun)
  60.             else:
  61.                 commandList()
  62.         else:
  63.             print("I do not understand %s" % verb
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement