-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.py
50 lines (43 loc) · 1.76 KB
/
main.py
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
from game.actions import perform_action
from game.player import create_player, get_player_status
from game.world import get_current_location, initialize_world
from utils.save_load import list_save_files, load_game, save_game
from utils.text_formatting import print_help, print_welcome_message
def main():
print_welcome_message()
# Add load game option
load_option = input("Do you want to load a saved game? (y/n): ").lower()
if load_option == 'y':
save_files = list_save_files()
if save_files:
print("Available save files:")
for i, file in enumerate(save_files, 1):
print(f"{i}. {file}")
choice = int(input("Enter the number of the save file to load: "))
player, world = load_game(save_files[choice - 1])
if player is None or world is None:
print("Failed to load game. Starting a new game.")
player = create_player("Kevin")
world = initialize_world()
else:
print("No save files found. Starting a new game.")
player = create_player("Kevin")
world = initialize_world()
else:
player = create_player("Kevin")
world = initialize_world()
while True:
current_location = get_current_location(world)
print(f"\nYou are in the {current_location}.")
print(get_player_status(player))
action = input("What would you like to do? ").lower()
if action == "quit":
save_game(player, world)
print("Thanks for playing! Your progress has been saved.")
break
elif action == "help":
print_help()
else:
perform_action(player, world, action)
if __name__ == "__main__":
main()