From 403fc8004590dffe2c5332d2c6ff314e31f01f3f Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Sat, 8 Apr 2023 12:59:21 -0500 Subject: [PATCH] Confirm cardset in_packs --- ai_manager.py | 47 ++++++++++++++++++++++++++++++++--------------- helpers.py | 2 +- 2 files changed, 33 insertions(+), 16 deletions(-) diff --git a/ai_manager.py b/ai_manager.py index b596b2c..668bfe9 100644 --- a/ai_manager.py +++ b/ai_manager.py @@ -327,21 +327,37 @@ def get_starting_pitcher(team_object: dict, game_id: int, is_home: bool, league_ elif league_name == 'gauntlet-1': set_params = MINOR_CARDSET_PARAMS - # Pull starters sorted by current cost - try: - params = [ - ('mlbclub', team_object['lname']), ('pos_include', 'SP'), ('pos_exclude', 'RP'), - ('inc_dex', False), ('sort_by', 'cost-desc'), ('limit', 5) - ] - params.extend(set_params) - pitchers = db_get( - endpoint='players', - params=params, - timeout=10 - ) - except ConnectionError as e: - logging.error(f'Could not get pitchers for {team_object["lname"]}: {e}') - raise ConnectionError(f'Error pulling starting pitchers for the {team_object["lname"]}. Cal help plz.') + params = [ + ('mlbclub', team_object['lname']), ('pos_include', 'SP'), ('pos_exclude', 'RP'), + ('inc_dex', False), ('sort_by', 'cost-desc'), ('limit', 5) + ] + counter = 0 + logging.info(f'params: {params}') + while counter < 2: + logging.info(f'counter: {counter}') + counter += 1 + # Pull starters sorted by current cost + try: + params.extend(set_params) + pitchers = db_get( + endpoint='players', + params=params, + timeout=10 + ) + logging.info(f'pitchers: {pitchers}') + except ConnectionError as e: + logging.error(f'Could not get pitchers for {team_object["lname"]}: {e}') + raise ConnectionError(f'Error pulling starting pitchers for the {team_object["lname"]}. Cal help plz.') + + if pitchers['count'] == 0: + logging.info(f'pitchers is None') + del params + params = [ + ('mlbclub', team_object['lname']), ('pos_include', 'SP'), + ('inc_dex', False), ('sort_by', 'cost-desc'), ('limit', 5) + ] + else: + break logging.info(f'build_lineup - eligible starting pitcher count: {len(pitchers)}') if pitchers['count'] == 0: @@ -409,6 +425,7 @@ def get_relief_pitcher(this_play: StratPlay, ai_team: dict, used_pitchers: list, set_params = MAJOR_CARDSET_PARAMS elif 'gauntlet-1' in league_name: set_params = MINOR_CARDSET_PARAMS + set_params.append(('cardset_id', 8)) # Pull relievers sorted by current cost params = [ diff --git a/helpers.py b/helpers.py index 68f92b8..da1da93 100644 --- a/helpers.py +++ b/helpers.py @@ -1894,7 +1894,7 @@ async def roll_for_cards(all_packs: list, extra_val=None) -> list: if counts[key]['count'] > 0: params = [ ('min_rarity', counts[key]['rarity']), ('max_rarity', counts[key]['rarity']), - ('limit', counts[key]['count']) + ('limit', counts[key]['count']), ('in_packs', True) ] if all_packs[0]['pack_team'] is not None: params.append(('franchise', all_packs[0]['pack_team']['lname']))