Advertisement
Guest User

Untitled

a guest
May 26th, 2019
105
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.64 KB | None | 0 0
  1. def set_path(self, dir, dest):
  2. """TODO: Creates an path leading from this room to another."""
  3. if dir == "NORTH" or dir == "N":
  4. self.dir[0] = 1
  5. self.dest[0] = dest
  6. elif dir == "SOUTH" or dir == "S":
  7. self.dir[1] = 1
  8. self.dest[1] = dest
  9. elif dir == "EAST" or dir == "E":
  10. self.dir[2] = 1
  11. self.dest[2] = dest
  12. elif dir == "WEST" or dir == "W":
  13. self.dir[3] = 1
  14. self.dest[3] = dest
  15.  
  16. def draw(self):
  17. #"""TODO: Creates a drawing depicting the exits in each room."""
  18. direction_list = ["-", "-", "|", "|", "-", "-"]
  19. if self.dir[0] == 1:
  20. direction_list[0] = 'N'
  21. direction_list[1] = 'N'
  22. elif self.dir[1] == 1:
  23. direction_list[4] = 'S'
  24. direction_list[5] = 'S'
  25. elif self.dir[2] == 1:
  26. direction_list[3] = 'E'
  27. elif self.dir[3] == 1:
  28. direction_list[2] = 'W'
  29.  
  30. print("")
  31. print("+---------{}{}---------+".format(direction_list[0], direction_list[1]))
  32. print("| |")
  33. print("| |")
  34. print("| |")
  35. print("| |")
  36. print("{} {}".format(direction_list[2], direction_list[3]))
  37. print("| |")
  38. print("| |")
  39. print("| |")
  40. print("| |")
  41. print("+---------{}{}---------+".format(direction_list[4], direction_list[5]))
  42. print("You are standing at the {}.".format(self.name))
  43. print("There is nothing in this room.")
  44.  
  45. def move(self, dir):
  46. """TODO: Returns an adjoining Room object based on a direction given. (i.e. if dir == "NORTH", returns a Room object in the north)."""
  47. if dir == "NORTH" or dir == "N":
  48. if self.dir[0] == 1:
  49. self.dir[0] = 0
  50. return self.dest[0]
  51. else:
  52. return None
  53. elif dir == "SOUTH" or dir == "S":
  54. if self.dir[1] == 1:
  55. self.dir[1] = 0
  56. return self.dest[1]
  57. else:
  58. return None
  59. elif dir == "EAST" or dir == "E":
  60. if self.dir[2] == 1:
  61. self.dir[2] = 0
  62. return self.dest[2]
  63. else:
  64. return None
  65. elif dir == "WEST" or dir == "W":
  66. if self.dir[3] == 1:
  67. self.dir[3] = 0
  68. return self.dest[3]
  69. else:
  70. return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement