-
Notifications
You must be signed in to change notification settings - Fork 0
/
pregame.py
69 lines (60 loc) · 2.27 KB
/
pregame.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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
import helper
def get_player_name():
return input("Player Name: ")
def display_players_list(names_list):
print('The players are: ')
helper.print_numbered_list(names_list)
def add_new_player_bool():
return helper.yes_no_question("Add new player?")
def remove_player_bool():
return helper.yes_no_question("Remove a player?")
def remove_player(names_list):
display_players_list(names_list)
num = int(input("Select the number of the player to remove: "))
if num < len(names_list):
names_list.pop(num)
display_players_list(names_list)
return names_list
def add_players_loop(names_list):
add_name_bool = True
while add_name_bool:
display_players_list(names_list)
names_list.append(get_player_name())
add_name_bool = add_new_player_bool()
return names_list
def too_few_players_check(names_list):
while len(names_list)<2:
print("You cannot have fewer than two players. You must add more names before continuing.")
add_players_loop(names_list)
return names_list
def remove_players_loop(names_list):
remove_name_bool = True
while remove_name_bool:
names_list=remove_player(names_list)
names_list = too_few_players_check(names_list)
remove_name_bool = remove_player_bool()
return names_list
def get_names_list():
names_str = input("Please list the names of the players, separated by commas: ")
names_list = names_str.split(",")
for i in range(len(names_list)):
name = names_list[i]
if name[0]==' ':
names_list[i]=name[1:]
names_list = too_few_players_check(names_list)
return names_list
def get_players_names():
names_list = get_names_list()
display_players_list(names_list)
all_correct_bool = helper.yes_no_question('Is this correct?')
while not all_correct_bool:
if remove_player_bool():
names_list = remove_players_loop(names_list)
if add_new_player_bool():
names_list = add_players_loop(names_list)
display_players_list(names_list)
all_correct_bool = helper.yes_no_question('Is this correct?')
helper.end_section()
return names_list
if __name__ == "__main__":
get_players_names()