예제 #1
0
파일: routes.py 프로젝트: acidmole/teammate
def player_info(id):
	compared_id = request.args.get('compare_to', None)

	player_list = players.get_players_without(id)
	player = players.get_player(id)
	top_points = players.get_top_points(id)
	top_rebs = players.get_top_rebs(id)
	top_ass = players.get_top_ass(id)
	top_steal = players.get_top_steal(id)
	top_block = players.get_top_block(id)
	attendance = players.get_player_attendance(id)

	compared_player = players.get_player(compared_id)
	return render_template("player.html", person_info=player, players=player_list, top_points=top_points, top_rebs=top_rebs, top_ass=top_ass, top_steal=top_steal, top_block=top_block,
	attendance=attendance, compared_player=compared_player)
예제 #2
0
def get_coach_info(coach_id):

    with db_helper.db_connect() as db:
        rows = db.get_rows("coaches", "CoachAPIID", coach_id)
        if len(rows) == 1:
            row = rows[0]
            coach = {
                "name":
                row[1],
                "image_url":
                row[9],
                "dob":
                row[4],
                "current_team":
                teams.get_team(row[3]),
                "win_loss_percentage":
                row[5],
                "color":
                row[10] if 10 in row else None,
                "current_roster": [
                    players.get_player(player_id)
                    for player_id in row[8].split(",")
                ],
                "past_teams": [team for team in row[7].split(",")],
                "recognitions": [award for award in row[6].split(";")]
            }
            return coach
        else:
            return None
예제 #3
0
파일: routes.py 프로젝트: acidmole/teammate
def edit_user(id):
	if users.is_admin() or users.user_id() == id:
		form = EditInfoForm(request.form)
		user = users.get_user(id)
		if players.is_player(id):
			player_id = players.get_player_id(id)
			player = players.get_player(player_id[0])
			return render_template("edit_user.html", user=user, player=player, form=form)
		else:
			return render_template("edit_user.html", user=user, form=form)
	else:
		return render_template("error.html", message="Ei oikeutta")
예제 #4
0
def main(player_params, num_games, game_name, working_dir, save_games, play_all_hand_rotations):
    players = [get_player(**player_params.player_one),
               get_player(**player_params.player_two),
               get_player(**player_params.player_three)]

    total_scores = np.array([0., 0., 0.])
    last_state = None
    for i in tqdm(range(num_games)):
        new_game = Game(game_name, last_state, play_all_hand_rotations, players)
        last_state = new_game.play()
        total_scores += last_state.current_scores - last_state.current_scores.mean()
        print("###########################################################")
        print("Scores: ", total_scores[0], total_scores[1], total_scores[2])
        print("###########################################################")
        if save_games:
            new_game.save(os.path.join(working_dir, f"game_{i+1}.gm"))

    for i, player in enumerate(players):
        player.save_data(working_dir, player_id=i)
    mean_scores = total_scores / num_games
    result_dict = {f"player_{i+1}_avg_score": score for i, score in enumerate(mean_scores)}
    print(result_dict)
    return result_dict
예제 #5
0
def get_team_info(team_id):
    def get_titles(row):
        titles = row.split(";")
        return {
            "championships":
            [i.strip() for i in titles[0].split(",")] if titles[0] else [],
            "conference_champs":
            [i.strip() for i in titles[1].split(",")] if titles[1] else [],
            "division_champs":
            [i.strip() for i in titles[2].split(",")] if titles[2] else [],
        }

    with db_helper.db_connect() as db:
        rows = db.get_rows("teams", "TeamAPIID", team_id)
        if len(rows) == 1:
            row = rows[0]
            team = {
                "name":
                row[3],
                "logo_url":
                row[11],
                "city":
                row[1],
                "arena":
                row[9],
                "head_coach":
                coaches.get_coach_by_number(row[7]),
                "color":
                row[12],
                "twitter":
                row[13] if 13 in row else None,
                "titles":
                get_titles(row[10]),
                "division":
                row[5],
                "conference":
                row[6],
                "current_roster": [
                    players.get_player(player_id)
                    for player_id in row[8].split(",")
                ],
            }
            return team
        else:
            return None
예제 #6
0
""" Crawler players logs from fbref.com"""
import players

if __name__ == '__main__':

    SEASON_START, SEASON_END = 2014, 2019

    with open("Input/players_info.txt", 'r') as file:

        PLAYERS_INFO = file.read().split('\n')

        PLAYERS_INFO = list(map(lambda x: x.split('\t'), PLAYERS_INFO))

        # making a dict with player_id : player_name
        PLAYERS_INFO.pop(0)  # removing header
        PLAYERS_INFO = {player[1]: player[0] for player in PLAYERS_INFO}

    HEADER = True
    for season in range(SEASON_START, SEASON_END):

        for player in PLAYERS_INFO:
            players.get_player(player,
                               PLAYERS_INFO[player],
                               season,
                               header=HEADER)
            HEADER = False
 def GET(self, player_name):
     return str(players.get_player(player_name))+"\n"
 def POST(self, player_name):
     players.create_player(player_name)
     return str(players.get_player(player_name))+"\n"