Gauntlets public release
Add MSS to /paperdex, add get_relief_pitcher logic, add MSS to /player, remove excess logging
This commit is contained in:
parent
403fc80045
commit
c1ff723612
@ -337,6 +337,7 @@ def get_starting_pitcher(team_object: dict, game_id: int, is_home: bool, league_
|
||||
logging.info(f'counter: {counter}')
|
||||
counter += 1
|
||||
# Pull starters sorted by current cost
|
||||
logging.info(f'counter: {counter} / params: {params}')
|
||||
try:
|
||||
params.extend(set_params)
|
||||
pitchers = db_get(
|
||||
@ -417,7 +418,6 @@ def get_relief_pitcher(this_play: StratPlay, ai_team: dict, used_pitchers: list,
|
||||
if attempts > 3:
|
||||
raise ValueError(f'Could not find a reliever for the {ai_team["sname"]}. Cal plz.')
|
||||
|
||||
logging.info(f'TEST GAME - league_name: {league_name}')
|
||||
set_params = [('cardset_id_exclude', 2)]
|
||||
if league_name == 'minor-league':
|
||||
set_params = MINOR_CARDSET_PARAMS
|
||||
|
||||
@ -367,8 +367,8 @@ class Players(commands.Cog):
|
||||
@app_commands.checks.has_any_role(PD_PLAYERS_ROLE_NAME)
|
||||
async def player_slash_command(
|
||||
self, interaction: discord.Interaction, player_name: str,
|
||||
cardset: Literal['All', '2013 Season', '2019 Season', '2021 Season', '2022 Season', '2022 Promos',
|
||||
'Sams Choice'] = 'All'):
|
||||
cardset: Literal['All', '2012 Season', '2013 Season', '2019 Season', '2021 Season', '2022 Season',
|
||||
'2022 Promos', 'Mario Super Sluggers', 'Sams Choice'] = 'All'):
|
||||
# min_rarity: Literal['Replacement', 'Reserve', 'Starter', 'All-Star', 'MVP'] = None):
|
||||
ephemeral = False
|
||||
if interaction.channel.name in ['paper-dynasty-chat', 'pd-news-ticker']:
|
||||
|
||||
44
gauntlets.py
44
gauntlets.py
@ -108,19 +108,37 @@ def get_starting_pitcher(this_team, this_game, this_event, this_run):
|
||||
else:
|
||||
raise KeyError(f'Pitcher not found for Gauntlet {this_event["id"]}')
|
||||
|
||||
# Pull pitchers
|
||||
try:
|
||||
pitchers = db_get(
|
||||
endpoint='players',
|
||||
params=params,
|
||||
timeout=10
|
||||
)
|
||||
except ConnectionError as e:
|
||||
logging.error(f'Could not get pitchers for {this_team["lname"]}: {e}')
|
||||
raise ConnectionError(f'Error pulling starting pitchers for the {this_team["lname"]}. Cal help plz.')
|
||||
params = [
|
||||
('mlbclub', this_team['lname']), ('pos_include', 'SP'), ('pos_exclude', 'RP'),
|
||||
('inc_dex', False), ('sort_by', 'cost-desc'), ('limit', 5)
|
||||
]
|
||||
counter = 0
|
||||
while True:
|
||||
counter += 1
|
||||
# Pull starters sorted by current cost
|
||||
try:
|
||||
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 {this_team["lname"]}: {e}')
|
||||
raise ConnectionError(f'Error pulling starting pitchers for the {this_team["lname"]}. Cal help plz.')
|
||||
|
||||
if pitchers['count'] == 0:
|
||||
logging.info(f'pitchers is None')
|
||||
del params
|
||||
params = [
|
||||
('mlbclub', this_team['lname']), ('pos_include', 'SP'),
|
||||
('inc_dex', False), ('sort_by', 'cost-desc'), ('limit', 5)
|
||||
]
|
||||
elif counter >= 2:
|
||||
raise KeyError(f'Error pulling pitchers for the {this_team["lname"]}. Cal help plz.')
|
||||
else:
|
||||
break
|
||||
|
||||
if pitchers['count'] == 0:
|
||||
raise DatabaseError(f'Could not find any SP for {this_team["abbrev"]}. Seems like a Cal issue.')
|
||||
pitcher_num = games_played(this_run) % 5
|
||||
card_id = ai_manager.get_or_create_card(pitchers['players'][pitcher_num], this_team)
|
||||
|
||||
@ -445,6 +463,8 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
|
||||
|
||||
|
||||
def get_embed(this_run=None, this_event=None):
|
||||
logging.info(f'get_embed - this_run:\n{this_run}\n\nthis_event:\n{this_event}')
|
||||
|
||||
if this_run is None and this_event is None:
|
||||
raise KeyError('Must provide either a run or an event to get_embed')
|
||||
|
||||
|
||||
@ -508,7 +508,8 @@ class SelectPaperdexCardset(discord.ui.Select):
|
||||
discord.SelectOption(label='2021 Season'),
|
||||
discord.SelectOption(label='2019 Season'),
|
||||
discord.SelectOption(label='2013 Season'),
|
||||
discord.SelectOption(label='2012 Season')
|
||||
discord.SelectOption(label='2012 Season'),
|
||||
discord.SelectOption(label='Mario Super Sluggers')
|
||||
]
|
||||
super().__init__(placeholder='Select a Cardset', options=options)
|
||||
|
||||
@ -527,6 +528,8 @@ class SelectPaperdexCardset(discord.ui.Select):
|
||||
cardset_id = 6
|
||||
elif self.values[0] == '2012 Season':
|
||||
cardset_id = 7
|
||||
elif self.values[0] == 'Mario Super Sluggers':
|
||||
cardset_id = 8
|
||||
|
||||
c_query = db_get('cardsets', object_id=cardset_id, none_okay=False)
|
||||
await interaction.response.edit_message(content=f'Okay, sifting through your cards...', view=None)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user