Skip to content

Commit

Permalink
Added statemes in data/game.py to allow for additional play handling
Browse files Browse the repository at this point in the history
  • Loading branch information
Xatunix authored Jul 30, 2024
1 parent f6c06a6 commit 09db08b
Showing 1 changed file with 101 additions and 1 deletion.
102 changes: 101 additions & 1 deletion data/game.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

SCHEDULE_API_FIELDS = "dates,date,games,status,detailedState,abstractGameState,reason"

GAME_UPDATE_RATE = 10
GAME_UPDATE_RATE = 7


class Game:
Expand All @@ -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)

def update(self, force=False) -> UpdateStatus:
if force or self.__should_update():
Expand Down Expand Up @@ -314,6 +315,105 @@ def current_play_result(self):
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("description", "")
):
result += "_looking"
elif result == "field_out" and (
"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"
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"

if result == "home_run" and (
"2"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("rbi", "")
):
result += "_2"
elif result == "home_run" and (
"3"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("rbi", "")
):
result += "_3"
elif result == "home_run" and (
"4"
in self._current_data["liveData"]["plays"].get("currentPlay", {}).get("result", {}).get("rbi", "")
):
result += "_4"
return result

def __should_update(self):
Expand Down

0 comments on commit 09db08b

Please sign in to comment.