fix random world selection
This commit is contained in:
parent
b09dca22e5
commit
704ae05175
1 changed files with 8 additions and 4 deletions
12
main.py
12
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()
|
||||
|
|
Loading…
Reference in a new issue