Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def show_instructions():
- #print a main menu and the commands
- print("The Evil Ghost Game")
- print("Collect 6 items to win the game, or be defeated by an evil ghost.")
- print("Move commands: go South, go North, go East, go West")
- print("Add to Inventory: get 'item name'")
- show_instructions()
- def player_stat(current_room='Foyer'):
- print('You are in the {}'.format(current_room))
- def main(current_room='Foyer', player_move= ''):
- # A dictionary linking a room to other rooms
- rooms = {
- 'Foyer': {
- 'South': 'Kitchen',
- 'North': 'Guest Bedroom',
- 'East': 'Master Bedroom',
- 'West': 'Living Room'},
- 'Kitchen': {
- 'North': 'Foyer',
- 'East': 'Garage',
- 'item': 'Flashlight'},
- 'Garage': {
- 'West': 'Kitchen',
- 'item': 'Crucifix'},
- 'Master Bedroom' : {
- 'item': 'Candles',
- 'West': 'Foyer',
- 'North' :
- 'Master Bathroom',
- 'item' : 'Ghost'},
- 'Master Bathroom' : {
- 'item': 'Ghost',
- 'South' : 'Master Bedroom'},
- 'Living Room' : {
- 'item': 'Spirit Box',
- 'East': 'Foyer' },
- 'Guest Bedroom': {
- 'item': 'Prayer Book',
- 'South': 'Foyer',
- 'East': 'Guest Bathroom', 'item' : 'Thermometer'},
- 'Guest Bathroom' : {
- 'item' : 'Thermometer',
- 'West' : 'Guest Bedroom'}}
- while current_room != 'Exit':
- player_stat()
- player_move = input('Enter your move:')
- if player_move in rooms[current_room]:
- current_room = rooms[current_room][player_stat]
- currentRoom = 'Exit'
- print('Play again soon')
- try:
- current_room = rooms[current_room][player_stat]
- except Exception:
- print("invalid move")
- if 'Master Bathroom' == current_room:
- print("Exorcise the Ghost")
- main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement