Advertisement
kenadams53

Room Object Kens Game

Aug 20th, 2019
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.59 KB | None | 0 0
  1. '''
  2. See pastebin for code:
  3. Kens Game main: https://pastebin.com/NHu4SGA0 # contains description of the game
  4. Room object: https://pastebin.com/Mn1HecX6
  5. Character object: https://pastebin.com/m6WJQNn5
  6. Item object: https://pastebin.com/GAirfZ5B
  7.  
  8. '''
  9.  
  10. class Room():# Room object for Kens Game
  11.  
  12. def __init__(self, room_name):
  13. self.name = room_name
  14. self.description = None
  15. self.linked_rooms = {}
  16. self.character = None
  17.  
  18. def set_description(self, room_description):
  19. self.description = room_description
  20.  
  21.  
  22. def get_character(self):
  23. return self.description
  24.  
  25. def get_name(self):
  26. return self.name
  27.  
  28. def set_name(self, room_name):
  29. self.name = room_name
  30.  
  31. def describe(self):
  32. print( self.description )
  33.  
  34. def link_room(self, room_to_link, direction):
  35. self.linked_rooms[direction] = room_to_link
  36. #print( self.name + " linked rooms :" + repr(self.linked_rooms) )#does not work
  37.  
  38. def get_details(self):
  39. print("\nYou are in the " + self.name)
  40. self.describe()
  41. for direction in self.linked_rooms:
  42. room = self.linked_rooms[direction]
  43. print( " The " + room.get_name() + " is " + direction)
  44.  
  45. def move(self, direction):
  46. if direction in self.linked_rooms:
  47. return self.linked_rooms[direction]
  48. else:
  49. print("You can't go that way")
  50. return self
  51.  
  52. def set_character(self, character):
  53. self.character = character
  54.  
  55. def get_character(self):
  56. return self.character
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement