-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclient.py
138 lines (114 loc) · 4.03 KB
/
client.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
from PyInquirer import prompt
import nba_fantasy_draft
LEAGUE_SIZES = {"6": 6, "8": 8, "10": 10, "12": 12, "14": 14}
DRAFT_ACTIONS = {"Add player to team":0, "Remove player from team":1, "Find next best player":2, "Print Team":3, "Reset players":4, "Quit":5}
CONFIRMATION = {"No":0, "Yes":1}
class Client():
def __init__(self):
self.__dialog()
def __dialog():
start_questions = [
{
"type": "input",
"name": "reference_file",
"message": "Please enter in player reference file for modelling"
},
{
"type": "list",
"name": "league_size",
"message": "League Size",
"choices": LEAGUE_SIZES.keys()
}
]
draft_questions = [
{
"type": "list",
"name": "action_type",
"message": "Next step in the draft",
"choices": DRAFT_ACTIONS.keys()
}
]
first_name_question = [
{
"type": "input",
"name": "first_name",
"message": "What is the first name of the player?",
}
]
answers = prompt(start_questions)
file = answers["reference_file"]
league_size = LEAGUE_SIZES[answers["league_size"]]
team_number_question = [
{
"type": "input",
"name": "team_number",
"message": f"What team number? (1 - {league_size})"
}
]
confirmation_question = [
{
"type": "list",
"name": "confirmation",
"message": "Are you sure?",
"choices": CONFIRMATION.keys()
}
]
my_nba_fantasy_draft = nba_fantasy_draft.NbaFantasyDraft(file)
print('initialize league')
answer_num = 0
while answer_num != 5:
draft_action_selected = prompt(draft_questions)
answer_num = DRAFT_ACTIONS[draft_action_selected["action_type"]]
#add player
if answer_num == 0:
full_name_list = []
while not full_name_list:
answer_first_name = prompt(first_name_question)
first_name = answer_first_name["first_name"]
full_name_list = my_nba_fantasy_draft.get_player_list(first_name).to_dict()
full_name_dict = {y:x for x,y in full_name_list.items()}
full_name_question = [
{
"type": "list",
"name": "full_name",
"message": "Choose player",
"choices": full_name_dict.keys()
}
]
answer_full_name = prompt(full_name_question)
answer_team_number = prompt(team_number_question)
team_number = answer_team_number["team_number"]
my_nba_fantasy_draft.add_player(answer_full_name["full_name"], answer_team_number["team_number"])
# remove player from team
if answer_num == 1:
full_name_list = []
while not full_name_list:
answer_first_name = prompt(first_name_question)
first_name = answer_first_name["first_name"]
full_name_list = my_nba_fantasy_draft.get_player_list(first_name).to_dict()
full_name_dict = {y:x for x,y in full_name_list.items()}
full_name_question = [
{
"type": "list",
"name": "full_name",
"message": "Choose player",
"choices": full_name_dict.keys()
}
]
answer_full_name = prompt(full_name_question)
# find next best player
if answer_num == 2:
my_nba_fantasy_draft.run_simulations(league_size)
# print team
if answer_num == 3:
answer_team_number = prompt(team_number_question)
team_number = int(answer_team_number["team_number"])
print(my_nba_fantasy_draft.get_team(team_number, file))
# reset players
if answer_num == 4:
answer_confirmation = prompt(confirmation_question)
if CONFIRMATION[answer_confirmation["confirmation"]] == 1:
my_nba_fantasy_draft.reset_players(file)
my_nba_fantasy_draft.save_csv(file)
if __name__ == "__main__":
__dialog()