From b9be2a90751701c22efc7fbb7f7ae79f48f9ccb3 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Thu, 1 Jun 2023 10:44:14 -0500 Subject: [PATCH] Deep copying param lists --- ai_manager.py | 30 +++++++++++++++--------------- gauntlets.py | 8 ++++---- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/ai_manager.py b/ai_manager.py index b3d1abb..a03dc8e 100644 --- a/ai_manager.py +++ b/ai_manager.py @@ -240,15 +240,15 @@ async def build_lineup(team_object: dict, game_id: int, league_name: str, vs_han if team_object['id'] == 58: set_params = [] elif league_name == 'minor-league': - set_params = MINOR_CARDSET_PARAMS + set_params = copy.deepcopy(MINOR_CARDSET_PARAMS) elif league_name == 'major-league': - set_params = MAJOR_CARDSET_PARAMS + set_params = copy.deepcopy(MAJOR_CARDSET_PARAMS) elif league_name == 'hall-of-fame': - set_params = HOF_CARDSET_PARAMS + set_params = copy.deepcopy(HOF_CARDSET_PARAMS) elif 'gauntlet-1' in league_name: - set_params = MINOR_CARDSET_PARAMS + set_params = copy.deepcopy(MINOR_CARDSET_PARAMS) elif 'gauntlet-2' in league_name: - set_params = GAUNTLET2_PARAMS + set_params = copy.deepcopy(GAUNTLET2_PARAMS) # Pull players sorted by current cost try: @@ -348,15 +348,15 @@ async def build_lineup(team_object: dict, game_id: int, league_name: str, vs_han async def get_starting_pitcher(team_object: dict, game_id: int, is_home: bool, league_name: str = None) -> dict: set_params = [('cardset_id_exclude', 2)] if league_name == 'minor-league': - set_params = MINOR_CARDSET_PARAMS + set_params = copy.deepcopy(MINOR_CARDSET_PARAMS) elif league_name == 'major-league': - set_params = MAJOR_CARDSET_PARAMS + set_params = copy.deepcopy(MAJOR_CARDSET_PARAMS) elif league_name == 'hall-of-fame': - set_params = HOF_CARDSET_PARAMS + set_params = copy.deepcopy(HOF_CARDSET_PARAMS) elif league_name == 'gauntlet-1': - set_params = MINOR_CARDSET_PARAMS + set_params = copy.deepcopy(MINOR_CARDSET_PARAMS) elif 'gauntlet-2' in league_name: - set_params = GAUNTLET2_PARAMS + set_params = copy.deepcopy(GAUNTLET2_PARAMS) params = [ ('mlbclub', team_object['lname']), ('pos_include', 'SP'), ('pos_exclude', 'RP'), @@ -457,15 +457,15 @@ async def get_relief_pitcher(this_play: StratPlay, ai_team: dict, league_name: s set_params = [('cardset_id_exclude', 2)] if league_name == 'minor-league': - set_params = MINOR_CARDSET_PARAMS + set_params = copy.deepcopy(MINOR_CARDSET_PARAMS) elif league_name == 'major-league': - set_params = MAJOR_CARDSET_PARAMS + set_params = copy.deepcopy(MAJOR_CARDSET_PARAMS) elif league_name == 'hall-of-fame': - set_params = HOF_CARDSET_PARAMS + set_params = copy.deepcopy(HOF_CARDSET_PARAMS) elif 'gauntlet-1' in league_name: - set_params = MINOR_CARDSET_PARAMS + set_params = copy.deepcopy(MINOR_CARDSET_PARAMS) elif 'gauntlet-2' in league_name: - set_params = GAUNTLET2_PARAMS + set_params = copy.deepcopy(GAUNTLET2_PARAMS) # Pull relievers sorted by current cost params = [ diff --git a/gauntlets.py b/gauntlets.py index 01a04d1..d4c69cd 100644 --- a/gauntlets.py +++ b/gauntlets.py @@ -50,7 +50,7 @@ def games_played(this_run): def is_home_team(this_team, this_event, this_run): - if this_event['id'] == 1: + if this_event['id'] in [1, 2]: return True return False @@ -120,7 +120,7 @@ async def build_lineup(this_team, this_game, this_event): async def get_starting_pitcher(this_team, this_game, this_event, this_run): if this_event['id'] == 1: if this_team['id'] != 58: - set_params = ai_manager.MINOR_CARDSET_PARAMS + set_params = copy.deepcopy(ai_manager.MINOR_CARDSET_PARAMS) else: set_params = [] params = [ @@ -129,7 +129,7 @@ async def get_starting_pitcher(this_team, this_game, this_event, this_run): ] params.extend(set_params) elif this_event['id'] == 2: - set_params = ai_manager.GAUNTLET2_PARAMS + set_params = copy.deepcopy(ai_manager.GAUNTLET2_PARAMS) params = [ ('mlbclub', this_team['lname']), ('pos_include', 'SP'), ('pos_exclude', 'RP'), ('inc_dex', False), ('sort_by', 'cost-desc'), ('limit', 5) @@ -192,7 +192,7 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra elif this_event['id'] == 2: embed_title = f'{main_team["lname"]} - {this_event["name"]} Draft' embed_description = f'{this_event["name"]}' - base_params = ai_manager.GAUNTLET2_PARAMS + base_params = copy.deepcopy(ai_manager.GAUNTLET2_PARAMS) base_params.extend([('limit', 8)]) else: logging.error(f'run_draft - Event ID {this_event["id"]} not recognized')