Skip to content

Commit

Permalink
[Hockey] Not sure how pickems didn't save game state correctly but th…
Browse files Browse the repository at this point in the history
…is should fix it.
  • Loading branch information
TrustyJAID committed Nov 14, 2023
1 parent d155046 commit 9fdf803
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 4 deletions.
6 changes: 3 additions & 3 deletions hockey/hockeypickems.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
from hockey.helper import utc_to_local

from .abc import HockeyMixin
from .game import Game, GameType
from .game import Game, GameState, GameType
from .pickems import Pickems

_ = Translator("Hockey", __file__)
Expand Down Expand Up @@ -206,7 +206,7 @@ async def set_guild_pickem_winner(self, game: Game, edit_message: bool = False)
if not await pickem.check_winner(game):
# log.debug("Game %r does not have a winner yet.", game)
continue
if game.game_state == pickem.game_state:
if game.game_state is pickem.game_state:
# log.debug("Game state %s not equal to pickem game state %s", game.game_state, pickem.game_state)
continue
pickem.game_state = game.game_state
Expand Down Expand Up @@ -486,7 +486,7 @@ async def create_pickems_channel(

async def make_pickems_msg(self, guild: discord.Guild, game: Game) -> str:
winner = ""
if game.game_state == "Final":
if game.game_state.value > GameState.over.value:
team = game.home_team if game.home_score > game.away_score else game.away_team
team_emoji = game.home_emoji if game.home_score > game.away_score else game.away_emoji
winner = _("**WINNER:** {team_emoji} {team}").format(team_emoji=team_emoji, team=team)
Expand Down
6 changes: 5 additions & 1 deletion hockey/pickems.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,9 +241,13 @@ def from_json(cls, data: dict) -> Pickems:
log.trace("Pickems from_json data: %s", data)
game_start = datetime.strptime(data["game_start"], "%Y-%m-%dT%H:%M:%SZ")
game_start = game_start.replace(tzinfo=timezone.utc)
try:
game_state = GameState(data["game_state"])
except ValueError:
game_state = GameState.from_statsapi(data["game_state"])
return cls(
game_id=data["game_id"],
game_state=GameState(data["game_state"]),
game_state=game_state,
messages=data.get("messages", []),
guild=data["guild"],
game_start=game_start,
Expand Down

0 comments on commit 9fdf803

Please sign in to comment.