Update ai_manager.py
create constant variables for minor and major league cardset params
This commit is contained in:
parent
0a24e5fc2d
commit
631338e175
@ -17,6 +17,9 @@ db = SqliteDatabase(
|
||||
}
|
||||
)
|
||||
|
||||
MINOR_CARDSET_PARAMS = [('cardset_id', 1), ('cardset_id', 3)]
|
||||
MAJOR_CARDSET_PARAMS = [('cardset_id', 1), ('cardset_id', 3), ('cardset_id', 4), ('cardset_id', 5), ('cardset_id', 6)]
|
||||
|
||||
|
||||
class BaseModel(Model):
|
||||
class Meta:
|
||||
@ -216,11 +219,9 @@ def build_lineup(team_object: dict, game_id: int, league_name: str, vs_hand: str
|
||||
|
||||
set_params = [('cardset_id_exclude', 2)]
|
||||
if league_name == 'minor-league':
|
||||
set_params = [('cardset_id', 1), ('cardset_id', 3)]
|
||||
set_params = MINOR_CARDSET_PARAMS
|
||||
elif league_name == 'major-league':
|
||||
set_params = [
|
||||
('cardset_id', 1), ('cardset_id', 3), ('cardset_id', 4), ('cardset_id', 5)
|
||||
]
|
||||
set_params = MAJOR_CARDSET_PARAMS
|
||||
|
||||
# Pull players sorted by current cost
|
||||
try:
|
||||
@ -329,15 +330,22 @@ def build_lineup(team_object: dict, game_id: int, league_name: str, vs_hand: str
|
||||
|
||||
|
||||
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
|
||||
elif league_name == 'major-league':
|
||||
set_params = MAJOR_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=[
|
||||
('mlbclub', team_object['lname']), ('pos_include', 'SP'), ('pos_exclude', 'RP'),
|
||||
('cardset_id_exclude', 2), ('cardset_id_exclude', 4), ('inc_dex', False), ('sort_by', 'cost-desc'),
|
||||
('limit', 5)
|
||||
],
|
||||
params=params,
|
||||
timeout=10
|
||||
)
|
||||
except ConnectionError as e:
|
||||
@ -417,11 +425,17 @@ 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.')
|
||||
|
||||
set_params = [('cardset_id_exclude', 2)]
|
||||
if league_name == 'minor-league':
|
||||
set_params = MINOR_CARDSET_PARAMS
|
||||
elif league_name == 'major-league':
|
||||
set_params = MAJOR_CARDSET_PARAMS
|
||||
|
||||
# Pull relievers sorted by current cost
|
||||
params = [
|
||||
('mlbclub', ai_team['lname']), ('pos_include', 'RP'), ('cardset_id_exclude', 2), ('cardset_id_exclude', 4),
|
||||
('inc_dex', False), ('sort_by', 'cost-desc')
|
||||
('mlbclub', ai_team['lname']), ('pos_include', 'RP'), ('inc_dex', False), ('sort_by', 'cost-desc')
|
||||
]
|
||||
params.extend(set_params)
|
||||
|
||||
alt_flag = False
|
||||
if attempts == 1:
|
||||
|
||||
Loading…
Reference in New Issue
Block a user