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
70
71
72
73
74
75
76
77
rooms = {
'T1':{
'north' : 'FR',
'south' : 'FR2',
'east' : 'T2',
},
'FR':{
'south':'T1',
},
'FR2':{
'north':'T1',
},
'T2':{
'east': 'T3',
'object': 'drawers',
'item':'key',
}
}
currentroom = "T1"
inventory =[]
def command_game():
command = input().lower()
seperator = " "
answer = command.split(seperator)
global currentroom
global inventory
if "go" in answer:
if "east" in answer and "east" in rooms[currentroom]:
currentroom = rooms[currentroom]["east"]
print (currentroom)
answer = []
if "west" in answer and "west" in rooms[currentroom]:
currentroom = rooms[currentroom]["west"]
print (currentroom)
answer = []
if "south" in answer and "south" in rooms[currentroom]:
currentroom = rooms[currentroom]["south"]
print (currentroom)
answer = []
if "north" in answer and "north" in rooms[currentroom]:
currentroom = rooms[currentroom]["north"]
print (currentroom)
answer = []
if "examine" in answer:
if "object" in rooms[currentroom]:
if "drawers" in answer:
print("You see a key in the drawers")
if "get" in answer:
if "item" in rooms[currentroom]:
if "key" in answer:
inventory.append("key")
command_game()
command_game()
command_game()
print (inventory)