diff --git a/main.py b/main.py index d241d2c..d92e417 100644 --- a/main.py +++ b/main.py @@ -1,4 +1,3 @@ -import argparse import os import random @@ -284,21 +283,26 @@ class Map: if __name__ == '__main__': + world_map_key_list = list(WORLD_MAP.keys()) + def get_world_response(): response = input('Which world would you like to play? Input a number: ') - if response not in [str(idx) for idx, _ in enumerate(list(WORLD_MAP.keys()))]: + if response not in [str(idx) for idx, _ in enumerate(world_map_key_list)] and response != str(len(world_map_key_list)): return get_world_response() return response os.system('clear') - for idx, name in enumerate(list(WORLD_MAP.keys())): + for idx, name in enumerate(world_map_key_list): print(f'[{idx}] {name}') random_idx = idx + 1 print(f'[{random_idx}] random world') - world = list(WORLD_MAP.keys())[int(get_world_response())] + response = int(get_world_response()) + if int(response) == random_idx: + response = random.randint(0, len(world_map_key_list)) + world = list(WORLD_MAP.keys())[response] levels = WORLD_MAP.get(world) g = Game()