forked from FutureTechCity/codeclub
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmazehouse.py
More file actions
69 lines (53 loc) · 1.46 KB
/
mazehouse.py
File metadata and controls
69 lines (53 loc) · 1.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
#!/bin/python3
# Replace RPG starter project with this code when new instructions are live
def showInstructions():
#print a main menu and the commands
print('''
RPG Game
========
Commands:
go [direction]
get [item]
''')
def showStatus():
#print the player's current status
print('---------------------------')
print('You are in the ' + currentRoom)
#print the current inventory
print('Inventory : ' + str(inventory))
#print an item if there is one
if "item" in rooms[currentRoom]:
print('You see a ' + rooms[currentRoom]['item'])
print("---------------------------")
#an inventory, which is initially empty
inventory = []
#a dictionary linking a room to other rooms
rooms = {
'Hall' : {
'south' : 'Kitchen',
'east' : 'Dining Room'
},
'Kitchen' : {
'north' : 'Hall'
},
'Dining Room : {
} 'west' : 'Hall'
}
#start the player in the Hall
currentRoom = 'Hall'
showInstructions()
#loop forever
while True:
showStatus()
#get the player's next 'move'
#.split() breaks it up into an list array
#eg typing 'go east' would give the list:
#['go','east']
move = ''
while move == '':
move = input('>')
move = move.lower().split()
#if they type 'go' first
if move[0] == 'go':
#check that they are allowed wherever they want to go
if move[1] in rooms[currentRoom]: