Advertisement
Aeroangel

School Project

Oct 14th, 2021 (edited)
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.90 KB | None | 0 0
  1. def show_instructions():
  2. #print a main menu and the commands
  3. print("The Evil Ghost Game")
  4. print("Collect 6 items to win the game, or be defeated by an evil ghost.")
  5. print("Move commands: go South, go North, go East, go West")
  6. print("Add to Inventory: get 'item name'")
  7.  
  8. show_instructions()
  9.  
  10. def player_stat(current_room='Foyer'):
  11. print('You are in the {}'.format(current_room))
  12.  
  13.  
  14. def main(current_room='Foyer', player_move= ''):
  15. # A dictionary linking a room to other rooms
  16. rooms = {
  17. 'Foyer': {
  18. 'South': 'Kitchen',
  19. 'North': 'Guest Bedroom',
  20. 'East': 'Master Bedroom',
  21. 'West': 'Living Room'},
  22. 'Kitchen': {
  23. 'North': 'Foyer',
  24. 'East': 'Garage',
  25. 'item': 'Flashlight'},
  26. 'Garage': {
  27. 'West': 'Kitchen',
  28. 'item': 'Crucifix'},
  29. 'Master Bedroom' : {
  30. 'item': 'Candles',
  31. 'West': 'Foyer',
  32. 'North' :
  33. 'Master Bathroom',
  34. 'item' : 'Ghost'},
  35. 'Master Bathroom' : {
  36. 'item': 'Ghost',
  37. 'South' : 'Master Bedroom'},
  38. 'Living Room' : {
  39. 'item': 'Spirit Box',
  40. 'East': 'Foyer' },
  41. 'Guest Bedroom': {
  42. 'item': 'Prayer Book',
  43. 'South': 'Foyer',
  44. 'East': 'Guest Bathroom', 'item' : 'Thermometer'},
  45. 'Guest Bathroom' : {
  46. 'item' : 'Thermometer',
  47. 'West' : 'Guest Bedroom'}}
  48.  
  49. while current_room != 'Exit':
  50. player_stat()
  51. player_move = input('Enter your move:')
  52. if player_move in rooms[current_room]:
  53. current_room = rooms[current_room][player_stat]
  54. currentRoom = 'Exit'
  55. print('Play again soon')
  56.  
  57. try:
  58. current_room = rooms[current_room][player_stat]
  59. except Exception:
  60. print("invalid move")
  61.  
  62.  
  63. if 'Master Bathroom' == current_room:
  64. print("Exorcise the Ghost")
  65.  
  66. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement