diff --git a/command_logic/logic_gameplay.py b/command_logic/logic_gameplay.py index 0d947be..f5d0c9b 100644 --- a/command_logic/logic_gameplay.py +++ b/command_logic/logic_gameplay.py @@ -75,7 +75,6 @@ from utilities.dropdown import ( from utilities.embeds import image_embed from utilities.pages import Pagination - logger = logging.getLogger("discord_app") WPA_DF = pd.read_csv(f"storage/wpa_data.csv").set_index("index") TO_BASE = {2: "to second", 3: "to third", 4: "home"} @@ -612,9 +611,11 @@ async def read_lineup( this_game, this_team=lineup_team, lineup_num=lineup_num, - roster_num=this_game.away_roster_id - if this_game.home_team.is_ai - else this_game.home_roster_id, + roster_num=( + this_game.away_roster_id + if this_game.home_team.is_ai + else this_game.home_roster_id + ), ) await interaction.edit_original_response( @@ -759,7 +760,11 @@ def complete_play(session: Session, this_play: Play): opponent_play = get_last_team_play( session, this_play.game, this_play.pitcher.team ) - nbo = opponent_play.batting_order + 1 if opponent_play.pa == 1 else opponent_play.batting_order + nbo = ( + opponent_play.batting_order + 1 + if opponent_play.pa == 1 + else opponent_play.batting_order + ) except PlayNotFoundException as e: logger.info( f"logic_gameplay - complete_play - No last play found for {this_play.pitcher.team.sname}, setting upcoming batting order to 1" @@ -1106,7 +1111,8 @@ async def get_lineups_from_sheets( position = row[0].upper() if position != "DH": player_positions = [ - getattr(this_card.player, f"pos_{i}") for i in range(1, 9) + getattr(this_card.player, f"pos_{i}") + for i in range(1, 9) if getattr(this_card.player, f"pos_{i}") is not None ] if position not in player_positions: @@ -1216,7 +1222,10 @@ async def get_full_roster_from_sheets( async def checks_log_interaction( - session: Session, interaction: discord.Interaction, command_name: str, lock_play: bool = True + session: Session, + interaction: discord.Interaction, + command_name: str, + lock_play: bool = True, ) -> tuple[Game, Team, Play]: """ Validates interaction permissions and optionally locks the current play for processing. @@ -3862,7 +3871,14 @@ async def xchecks( this_play.run, this_play.triple, this_play.batter_final, - ) = 1, 1, 1, 1, 1, 4 + ) = ( + 1, + 1, + 1, + 1, + 1, + 4, + ) this_play = advance_runners(session, this_play, num_bases=4, earned_bases=3) session.add(this_play) @@ -4291,23 +4307,17 @@ async def complete_game( # Post game stats to API try: - resp = await db_post("plays", payload=db_ready_plays) + await db_post("plays", payload=db_ready_plays) except Exception as e: await roll_back(db_game["id"], plays=True) log_exception(e, msg="Unable to post plays to API, rolling back") - if len(resp) > 0: - pass - try: - resp = await db_post("decisions", payload={"decisions": db_ready_decisions}) + await db_post("decisions", payload={"decisions": db_ready_decisions}) except Exception as e: await roll_back(db_game["id"], plays=True, decisions=True) log_exception(e, msg="Unable to post decisions to API, rolling back") - if len(resp) > 0: - pass - # Post game rewards (gauntlet and main team) try: win_reward, loss_reward = await post_game_rewards(