diff --git a/command_logic/logic_gameplay.py b/command_logic/logic_gameplay.py index 6c6bd6a..53d31cd 100644 --- a/command_logic/logic_gameplay.py +++ b/command_logic/logic_gameplay.py @@ -3450,7 +3450,7 @@ async def groundballs(session: Session, interaction: discord.Interaction, this_p 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: + if this_play.game.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}') @@ -3818,13 +3818,14 @@ async def select_ai_reliever(session: Session, ai_team: Team, this_play: Play) - logger.info(f'need: {need}') used_pitchers = get_game_lineups(session, this_play.game, ai_team, is_active=False) - used_player_ids = [f'{this_play.pitcher.player_id}'] + used_player_ids = [this_play.pitcher.player_id] + id_string = f'&used_pitcher_ids={this_play.pitcher.player_id}' for x in used_pitchers: - used_player_ids.append(f'{x.player_id}') + used_player_ids.append(x.player_id) + id_string += f'&used_pitcher_ids={x.player_id}' logger.info(f'used ids: {used_player_ids}') - id_string = ','.join(used_player_ids) all_links = get_game_cardset_links(session, this_play.game) if len(all_links) > 0: @@ -3835,7 +3836,7 @@ async def select_ai_reliever(session: Session, ai_team: Team, this_play: Play) - cardset_string = '' logger.info(f'cardset_string: {cardset_string}') - rp_json = await db_get(f'teams/{ai_team.id}/rp/{this_play.game.game_type.split("-run")[0]}?need={need}&used_pitcher_ids={id_string}{cardset_string}') + rp_json = await db_get(f'teams/{ai_team.id}/rp/{this_play.game.game_type.split("-run")[0]}?need={need}{id_string}{cardset_string}') rp_player = await get_player_or_none(session, player_id=get_player_id_from_dict(rp_json)) if rp_player is None: diff --git a/in_game/gameplay_models.py b/in_game/gameplay_models.py index 8529a1a..0b5f0b2 100644 --- a/in_game/gameplay_models.py +++ b/in_game/gameplay_models.py @@ -683,7 +683,7 @@ class ManagerAi(ManagerAiBase, table=True): pitcher_pow = this_pitcher.card.pitcherscouting.pitchingcard.starter_rating logger.info(f'Starter POW: {pitcher_pow}') - if outs > pitcher_pow * 3 + 8: + if outs >= pitcher_pow * 3 + 6: logger.info(f'Starter has thrown POW + 3 - being pulled') return True @@ -719,7 +719,11 @@ class ManagerAi(ManagerAiBase, table=True): pitcher_pow = this_pitcher.card.pitcherscouting.pitchingcard.relief_rating logger.info(f'Reliever POW: {pitcher_pow}') - if run_diff > 5 or (run_diff > 2 and self.ahead_aggression > 5) and (this_play.starting_outs == 2 or allowed_runners <= run_diff or this_play.on_base_code <= 3 or this_play.starting_outs == 2): + if outs >= pitcher_pow * 3 + 3: + logger.info(f'Only allow POW + 1 IP - pull reliever') + return True + + elif run_diff > 5 or (run_diff > 2 and self.ahead_aggression > 5) and (this_play.starting_outs == 2 or allowed_runners <= run_diff or this_play.on_base_code <= 3 or this_play.starting_outs == 2): logger.info(f'AI team has big lead of {run_diff} - staying in') return False