Exemplo n.º 1
0
def test_getPlayerIdsByName_first_fuzzy():
    player_id = src.getPlayerIdsByName(TEST_PLAYER_FIRSTNAME, fuzzy_match=True)

    assert len(player_id) == 1
Exemplo n.º 2
0
def test_getPlayerIdsByName_last_fuzzy():
    player_id = src.getPlayerIdsByName(TEST_PLAYER_LASTNAME, fuzzy_match=True)

    assert len(player_id) > 0
Exemplo n.º 3
0
def test_getPlayerIdsByName_last():
    player_id = src.getPlayerIdsByName(TEST_PLAYER_LASTNAME)

    assert len(player_id) > 0
Exemplo n.º 4
0
def test_getPlayerIdsByName_first():
    player_id = src.getPlayerIdsByName(TEST_PLAYER_FIRSTNAME)

    assert len(player_id) == 1
Exemplo n.º 5
0
def test_getPlayerIdsByName_full():
    player_id = src.getPlayerIdsByName(TEST_PLAYER_FULLNAME)

    assert len(player_id) == 1
Exemplo n.º 6
0
async def player(ctx, *args):
    """Displays a active player's current season statistics"""
    name = ""
    for x in args:
        name = name + " " + x

    embed = discord.Embed(
        title="Player Not Found",
        description=
        "Double check that the player name is spelled correctly, or try using %playercareerstats [player].",
        color=0x595959)
    players = nba.getPlayerIdsByName(name.strip(), True, True)
    if players is not None:  # If the list of players is not empty
        playerIds = list(players.keys())
        playerNames = list(players.values())
        if len(
                playerIds
        ) > 1:  # If there are multiple players with the same name then list out all the players
            embed = discord.Embed(
                title="Multiple Players",
                description="There are multiple players with the name \"" +
                name.strip() + "\":",
                color=0x595959)
            if len(
                    playerIds
            ) > 12:  # If there are more than 12 players with the name specified
                for i in range(0, 12):
                    embed.add_field(name="\u200b",
                                    value=playerNames[i],
                                    inline=True)
                embed.add_field(name="\u200b",
                                value="... and more",
                                inline=True)
            else:
                for i in playerNames:
                    embed.add_field(name="\u200b", value=i, inline=True)
        else:  # List the player's stats
            stats = await nba.getPlayerSeasonStatsByID(playerIds[0])
            height = stats["HEIGHT"].split("-")
            embed = discord.Embed(
                title=playerNames[0],
                description=stats["SEASON_ID"] + "\n" + stats["TEAM_CITY"] +
                " " + stats["TEAM_NAME"] + " | #" + stats["JERSEY"] + " | " +
                stats["POSITION"] + "\n" + height[0] + "'" + height[1] + "\"" +
                " | " + stats["WEIGHT"] + " lbs",
                color=stats["TEAM_COLOR"])
            embed.set_thumbnail(url=nba.getPlayerHeadshotURL(playerIds[0]))
            embed.add_field(name="Games Played",
                            value="**" + str(stats["GP"]) + "**",
                            inline=True)
            embed.add_field(name="Games Started",
                            value="**" + str(stats["GS"]) + "**",
                            inline=True)
            embed.add_field(name="Points",
                            value="**" + str(stats["PTS"]) + "** (" +
                            str(stats["PPG"]) + " PPG)",
                            inline=False)
            embed.add_field(name="Rebounds",
                            value="**" + str(stats["REB"]) + "** (" +
                            str(stats["RPG"]) + " RPG)",
                            inline=False)
            embed.add_field(name="Assists",
                            value="**" + str(stats["AST"]) + "** (" +
                            str(stats["APG"]) + " APG)",
                            inline=False)
            embed.add_field(name="Blocks",
                            value="**" + str(stats["BLK"]) + "** (" +
                            str(stats["BPG"]) + " BPG)",
                            inline=False)
            embed.add_field(name="Steals",
                            value="**" + str(stats["STL"]) + "** (" +
                            str(stats["SPG"]) + " SPG)",
                            inline=False)
    await ctx.send(embed=embed)
Exemplo n.º 7
0
async def playercareerstats(ctx, *args):
    """Displays a player's career statistics"""

    name = ""
    for x in args:
        name = name + " " + x

    embed = discord.Embed(
        title="Player Not Found",
        description="Double check that the player name is spelled correctly.",
        color=0x595959)
    players = nba.getPlayerIdsByName(name.strip(), False, True)
    if players is not None:  # If the list of players is not empty
        playerIds = list(players.keys())
        playerNames = list(players.values())
        if len(
                playerIds
        ) > 1:  # If there are multiple players with the same name then list out all the players
            embed = discord.Embed(
                title="Multiple Players",
                description="There are multiple players with the name \"" +
                name.strip() + "\":",
                color=0x595959)
            if len(
                    playerIds
            ) > 12:  # If there are more than 12 players with the name specified
                for i in range(0, 12):
                    embed.add_field(name="\u200b",
                                    value=playerNames[i],
                                    inline=True)
                embed.add_field(name="\u200b",
                                value="... and more",
                                inline=True)
            else:
                for i in playerNames:
                    embed.add_field(name="\u200b", value=i, inline=True)
        else:  # List the player's stats
            stats = await nba.getPlayerCareerStatsByID(playerIds[0])
            height = stats["HEIGHT"].split("-")
            embed = discord.Embed(
                title=playerNames[0],
                description=stats["TEAM_CITY"] + " " + stats["TEAM_NAME"] +
                " | #" + stats["JERSEY"] + " | " + stats["POSITION"] + "\n" +
                height[0] + "'" + height[1] + "\"" + " | " + stats["WEIGHT"] +
                " lbs" + " | " + str(stats["FROM_YEAR"]) + " - " +
                str(stats["TO_YEAR"]) + "\nDraft Info: " +
                str(stats["DRAFT_YEAR"]) + " | Round " +
                str(stats["DRAFT_ROUND"]) + ", Pick " +
                str(stats["DRAFT_NUMBER"]),
                color=stats["TEAM_COLOR"])
            embed.set_thumbnail(url=nba.getPlayerHeadshotURL(playerIds[0]))
            embed.add_field(name="Career Points",
                            value="**" + str(stats["PTS"]) + "**",
                            inline=False)
            embed.add_field(name="Career Rebounds",
                            value="**" + str(stats["REB"]) + "**",
                            inline=False)
            embed.add_field(name="Career Assists",
                            value="**" + str(stats["AST"]) + "**",
                            inline=False)
            embed.add_field(name="Career Blocks",
                            value="**" + str(stats["BLK"]) + "**",
                            inline=False)
            embed.add_field(name="Career Steals",
                            value="**" + str(stats["STL"]) + "**",
                            inline=False)
    await ctx.send(embed=embed)