Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Additional play display compatibility #548

Open
wants to merge 2 commits into
base: dev
Choose a base branch
from

Conversation

Xatunix
Copy link

@Xatunix Xatunix commented Jul 30, 2024

This pull request makes changes in data/plays.py and data/game.py to add compatibility with numerous other common plays in the scoreboard. This could be combined with changes in renderers/game/game.py to display many more play results on scoreboards (as I've done with the rest of the code on my personal repository).

Specifically:

  • Added "RBI" tag for run scoring plays to differentiate them for others
  • Added "Home Run" play for display of all types of Home Runs
  • Added tag for type of out made (fly, pop, ground) to allow for display
  • Added other plays such as "Stolen Base"

All original plays and abbreviations should have been maintained and not break any existing functionality.

(I don't know what I'm doing, so please provide feedback if going about this incorrectly)

Copy link
Member

@WardBrian WardBrian left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing! Here are some of my thoughts on this as it stands

@@ -45,6 +45,7 @@ def __init__(self, game_id, date, broadcasts, series_status, delay_in_10s_of_sec
self._broadcasts = broadcasts
self._series_status = series_status
self._status = {}
print(self.game_id)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
print(self.game_id)

Comment on lines +319 to +337
"flies"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_fly"
elif result == "field_out" and (
"grounds"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_ground"
elif result == "field_out" and (
"lines"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_line"
elif result == "field_out" and (
"pop"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_pop"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would make sense to turn this into a helper function called like out_type

Comment on lines +338 to +400
elif result == "field_out" and (
"scores"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_rbi"

if result == "field_out_fly" and (
"scores"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_rbi"
elif result == "field_out_ground" and (
"scores"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_rbi"
elif result == "field_out_line" and (
"scores"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_rbi"
elif result == "field_out_pop" and (
"scores"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_rbi"

if result == "sacrifice_fly" and (
"scores"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_rbi"
elif result == "sacrifice_bunt" and (
"scores"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_rbi"

if result == "single" and (
"scores"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_rbi"
elif result == "double" and (
"scores"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_rbi"
elif result == "triple" and (
"scores"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_rbi"
elif result == "walk" and (
"scores"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_rbi"
elif result == "hit_by_pitch" and (
"scores"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_rbi"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly, I think making a helper function called "did_score" or something could simplify this

@Xatunix
Copy link
Author

Xatunix commented Aug 3, 2024

Thanks for the detailed thoughts (some of which made me facepalm)! I'll revise accordingly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants