Ejemplo n.º 1
0
def index():
    """the main screen for the game"""
    ranked_teams = sorted(app.league.teams, key=lambda x: x.current_season_stats().wins * 2 + x.current_season_stats().ties, reverse=True)
    top_scorers = list(PlayerStats.select().join(Season).where(Season.is_current == True, Season.league == app.league))
    top_scorers = sorted(top_scorers, key=lambda x: x.goals + x.assists, reverse=True)[:10]
    goalies = Player.select().where(Player.position == 'G')
    goalie_stats = list(PlayerStats.select().join(Season).where(Season.is_current == True,
        Season.league == app.league, PlayerStats.player << goalies))
    return render_template("index.html", teams=ranked_teams, top_scorers=top_scorers, top_goalies=goalie_stats)
Ejemplo n.º 2
0
def draft():
    """Assign players to teams via draft"""
    teams = list(app.league.teams)
    players = list(Player.select().where(Player.team >> None))
    if not players:
        app.drafting_team = None
        return redirect(url_for('index'))

    if app.drafting_team is None:
        random.shuffle(teams)
        app.drafting_team = cycle(teams)
    current_team = next(app.drafting_team)
    while current_team.name != 'Icee' and players:
        drafted_player = random.choice(players)
        players.remove(drafted_player)
        _draft_player(drafted_player, current_team)
        current_team = next(app.drafting_team)

    return render_template("draft.html", players=players, team=current_team, draft_name="Fantasy Draft")
Ejemplo n.º 3
0
def list_players():
    """Lists all players in the league universe"""
    return render_template("player_view.html", players = Player.select())