nba-stats-game

Git hub pages repository

View the Project on GitHub chesterjzara/nba-stats-game

NBA Stat Guessing Games

https://chesterjzara.github.io/nba-stats-game/index.html

This website primarily consists of a Player Comparison guessing game and a Team Guessing game.

  1. The Player Comparison is inspired by an all-too-common practice employed on basketball forums since time immemorial. If you think your guy is underrated, find another, better regarded, player with similar boxscores. Then you can post both and challenge other users to guess which is which. This way you can make your point while ignoring all context to the statistics!

    For the website, the game will give two players and two statlines. The user will drag each player name to the statline they think coorelates to each player. The game will then evaluate if the user chose correctly or not.

  2. The Team guessing game comes from a brilliant segment from the basketball analysis TV show “Inside the NBA”. In the show an ex-player analyst is challenged to determine “Who he play for?”. Usually this purported expert will fail to identify any players’ teams correctly, to humorous effect.

    On the website the game is played by clicking the button to get a random player and then clicking the correct team icon below. Users will need to switch the display between East and West to toggle the 15 teams in a given conference.

    Inside the NBA Clip

Technology Used

Website

This website was made with HTML, CSS, and Javascript.

Data

Approach

As outlined above, the general approach is a simple website that uses JS/jQuery to pull NBA player data from the balldontlie.io NBA Stats API. In order to make a one-page site, all content is generated with Javascript.

The general approach flows from the navigation buttons. Clicking either the Player Comp or Team Guess game will call functions that generate the HTML content for each game. From there the created clickable areas on the page will lead to the API calls and game logic.

Code Path

Link to Code Path Diagram

alt-text

Key Functionality

  1. API Usage
    • Pulling player names, stats, teams from Balldontlie.io
    • Pulling player images from NBA.com (not officially supported API) and matching names
  2. Game 1 - Player Comparison Game
    • Random and Random Top 100 Player Options
    • Autocomplete on player name entry
    • Drag and Drop UI to play the game
    • Modal win/loss screen
    • Animations on various elements (bounce, pulse, position change on wrong answer)
    • Able to specify players via URL parameters
  3. Game 2 - Team Guessing Game
    • Animations on East/West button and changing teams
    • Modal win/loss screen - will explain why you lost
    • Able to specify players via URL parameters
    • Score board tracking and ability to reset
  4. General
    • Responsive design on all pages
    • localStorage Caching of player stats to avoid too many API calls
    • Customizable color scheme (also persistently stored in localStorage)

Unsolved Issues / Future Improvements

  1. Tooltips for more stats or other information
  2. Buttons to share comparison/player to social media instead of just copy-paste
  3. Store data on all players season averages to offer harder comparisons
    • Eg: give 2 players with similar stats instead of random
  4. Clean up code to use accessors instead of directly accessing class/object variables
  5. For the Player Comparison add a dropdown to have Top 50, 25, etc
  6. Also ability to enter 1 player via text and enter the other randomly, currently random or top X will do 2 players always