From 9700a9abd61b46505c608c0734821ffbd86548a6 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Mon, 3 Feb 2025 13:46:58 -0600 Subject: [PATCH] Runner on 3rd, gb checks updated --- command_logic/logic_gameplay.py | 80 ++++++++++++++++++++++++++------- 1 file changed, 65 insertions(+), 15 deletions(-) diff --git a/command_logic/logic_gameplay.py b/command_logic/logic_gameplay.py index 010ee82..6c6bd6a 100644 --- a/command_logic/logic_gameplay.py +++ b/command_logic/logic_gameplay.py @@ -3397,9 +3397,29 @@ async def groundballs(session: Session, interaction: discord.Interaction, this_p logger.info(f'Groundball {groundball_letter} with runner on third') def_alignment = this_play.managerai.defense_alignment(session, this_play.game) - if this_play.game.ai_team is not None and this_play.pitcher.team.is_ai and def_alignment.infield_in: - logger.info(f'AI on defense, hit to MIF, playing in') - this_play = gb_result_7(session, this_play) + if this_play.game.ai_team is not None and this_play.pitcher.team.is_ai: + if def_alignment.infield_in: + logger.info(f'AI on defense, playing in') + if groundball_letter == 'a': + this_play = gb_result_7(session, this_play) + + else: + this_play = gb_result_1(session, this_play) + else: + logger.info(f'AI on defense, playing back') + to_mif = await ask_confirm( + interaction, + question=f'Was that ball hit to either 2B or SS?', + label_type='yes' + ) + + if to_mif or not def_alignment.corners_in: + logger.info(f'playing back, gb 5') + this_play = gb_result_5(session, this_play, to_mif) + + else: + logger.info(f'corners in, gb 7') + this_play = gb_result_7(session, this_play) else: logger.info(f'Checking if hit to MIF') @@ -3409,23 +3429,53 @@ async def groundballs(session: Session, interaction: discord.Interaction, this_p label_type='yes' ) - if not to_mif: - logger.info(f'Not to a MIF, gb 7') - this_play = gb_result_7(session, this_play) - - else: - logger.info(f'AI batting, hit to MIF') - mif_playing_in = await ask_confirm( + if to_mif: + playing_in = await ask_confirm( interaction, question=f'Were they playing in?', label_type='yes', ) - if mif_playing_in: - logger.info(f'playing in, gb 7') - this_play = gb_result_7(session, this_play) + + if playing_in: + logger.info(f'To MIF, batter out, runners hold') + this_play = gb_result_1(session, this_play) else: - logger.info(f'playing back, gb 5') - this_play = gb_result_5(session, this_play, to_mif) + logger.info(f'To MIF, playing back, gb 3') + this_play = gb_result_3(session, this_play) + + else: + logger.info(f'Batter out, runners hold') + this_play = gb_result_1(session, this_play) + + elif this_play.on_base_code in [4, 5, 7] and groundball_letter == 'a': + logger.info(f'Groundball {groundball_letter} with runners on including third') + + if this_play.ai_team is not None and this_play.pitcher.team.is_ai: + def_alignment = this_play.managerai.defense_alignment(session, this_play.game) + logger.info(f'def_alignment: {def_alignment}') + + if def_alignment.infield_in: + logger.info(f'playing in, gb 7') + this_play = gb_result_7(session, this_play) + + else: + logger.info(f'playing back, gb 2') + this_play = gb_result_2(session, this_play) + + else: + playing_in = await ask_confirm( + interaction, + question='Was the defender playing in?', + label_type='yes' + ) + + if playing_in: + logger.info(f'playing in, gb 7') + this_play = gb_result_7(session, this_play) + + else: + logger.info(f'playing back, gb 2') + this_play = gb_result_2(session, this_play) else: this_play = await gb_letter(session, interaction, this_play, groundball_letter.upper(), 'None', False)