-
Notifications
You must be signed in to change notification settings - Fork 0
/
bball_main.py
84 lines (70 loc) · 2.2 KB
/
bball_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
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
from random import choice
from bball_class import BasketballIndex
url = 'https://www.basketball-reference.com'
bball = BasketballIndex(url)
csv_path = '/Users/rakinnefoote/Desktop/PythonProjects/bball_player_information.csv'
player_list = bball.make_list(csv_path)
user_name = input("What's your name? \n")
user_attempts = 6
def choose_player(players):
return choice(players)
won = False
lost = False
new_player = True
while True:
if won:
replay = input("Would you like to play again? (y/n) \n")
if replay.lower() == 'n':
print("Thanks for playing!")
break
else:
user_attempts = 5
elif lost:
print(f"Sorry, you failed to guess {player}!\n")
replay = input("Would you like to play again? (y/n)")
if replay.lower() == 'n':
print("Thanks for playing!")
break
else:
user_attempts = 5
else:
user_attempts = 5
if new_player == True:
print(f"{user_name}, you'll be tasked to guess the player...")
print(f"You'll be given {user_attempts - 1} chances to guess said player...")
print("If you are unable to guess, you lose...")
print(f"Good luck, {user_name}!")
else:
print(f"Welcome back, {user_name}...")
player_info = choose_player(player_list)
url2 = player_info[1]
player = player_info[0]
plyr_pos = bball.player_position(url2)
plyr_colg_team = bball.player_college_team(url2)
plyr_nba = bball.player_nba_team(url2)
plyr_height = bball.player_height(url2)
plyr_num = bball.player_number(url2)
user_guess = input(f"Who plays/played for {plyr_nba} as a {plyr_pos}? ... ")
while True:
user_attempts -= 1
if user_guess.lower() != player.lower():
print(f"Sorry! {user_guess} is not the right answer!\n")
if user_attempts == 4:
user_guess = input("Try again.\n")
elif user_attempts == 3:
print(f"This player played for {plyr_colg_team}.\n")
user_guess = input("Try again.\n")
elif user_attempts == 2:
print(f"This player is {plyr_height}in. tall.\n")
user_guess = input("Try again.\n")
elif user_attempts == 1:
print(f"This players' number is {plyr_num}.\n")
user_guess = input("Try again.\n")
elif user_attempts == 0:
lost = True
new_player = False
break
else:
print(f"Congratulations! Thats right!")
won = True
break