Confirm cardset in_packs

This commit is contained in:
Cal Corum 2023-04-08 12:59:21 -05:00
parent b1d1e919e5
commit 403fc80045
2 changed files with 33 additions and 16 deletions

View File

@ -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 = [

View File

@ -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']))