5
5
current_yaml = "gamedata/lobby.yaml"
6
6
7
7
selected_direction = ''
8
+ current_user = ""
8
9
9
10
def fuzzy_words (input_word , alisis_list ):
10
11
output = 0
@@ -26,9 +27,30 @@ def save_data(filepath, data):
26
27
"""Dumps data to a yaml"""
27
28
with open (filepath , "w" ) as file_desc :
28
29
yaml .dump (data , file_desc )
30
+
31
+ def save_userdata (data_type , data ):
32
+ print (current_user )
33
+ if current_user == "" :
34
+ print ("Error, you must create a user" )
35
+ else :
36
+ current_user_data = enter_room (current_user )
37
+ current_user_data .update ([data_type ][data ])
38
+ save_data (current_user , current_user_data )
39
+
40
+ def main_menu ():
41
+ print ("Welcome to the main menu\n [N] to start a new game, [L] to load an old one." )
42
+ menu_input = (input (": " )).upper ()
43
+ if menu_input == "N" :
44
+ menu_username = input ("Input your name: " )
45
+ current_user = "saves/" + menu_username + ".yaml"
46
+ print (current_user )
47
+ save_userdata ("name" , menu_username )
48
+ elif menu_input == "L" :
49
+ print ("Feature not functional" )
29
50
30
51
if __name__ == "__main__" : # If this is the main file
31
52
current_room = enter_room (current_yaml ) # fill current_room with all the room data of the current room
53
+ main_menu ()
32
54
print (current_room ['roommeta' ]['desc' ]) # give us the desc of that room
33
55
while (True ):
34
56
@@ -76,6 +98,8 @@ def save_data(filepath, data):
76
98
print (current_room [selected_direction ][user_arg_2 .lower ()]['inspect' ])
77
99
elif (fuzzy_words (user_arg_1 , ["PICKUP" , "GRAB" ])):
78
100
print ("pickup" )
101
+ elif (fuzzy_words (user_arg_1 , ["EXIT" , "MENU" ])):
102
+ main_menu ()
79
103
elif (fuzzy_words (user_arg_1 , ["OPEN" ])):
80
104
if user_arg_2 == "DOOR" :
81
105
destination = current_room [selected_direction ][user_arg_2 .lower ()]['dest' ]
0 commit comments