Bullpen fix
This commit is contained in:
parent
ac7c98f480
commit
0d04c59e97
@ -2,7 +2,6 @@ FROM python:3.8-slim
|
|||||||
|
|
||||||
WORKDIR /usr/src/app
|
WORKDIR /usr/src/app
|
||||||
|
|
||||||
RUN apt-get update && apt-get install -y git
|
|
||||||
COPY requirements.txt ./
|
COPY requirements.txt ./
|
||||||
RUN pip install --no-cache-dir -r requirements.txt
|
RUN pip install --no-cache-dir -r requirements.txt
|
||||||
|
|
||||||
|
|||||||
@ -3,7 +3,7 @@ import logging
|
|||||||
import random
|
import random
|
||||||
|
|
||||||
import pydantic
|
import pydantic
|
||||||
from db_calls_gameplay import StratPlay, get_team_lineups
|
from db_calls_gameplay import StratPlay, StratGame, get_one_lineup
|
||||||
from db_calls import db_get, db_post
|
from db_calls import db_get, db_post
|
||||||
from peewee import *
|
from peewee import *
|
||||||
from typing import Optional, Literal
|
from typing import Optional, Literal
|
||||||
@ -489,3 +489,10 @@ def get_relief_pitcher(this_play: StratPlay, ai_team: dict, used_pitchers: list,
|
|||||||
'batting_order': 10,
|
'batting_order': 10,
|
||||||
'after_play': this_play.play_num - 1
|
'after_play': this_play.play_num - 1
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
def get_pitcher(this_game: StratGame, this_play: StratPlay):
|
||||||
|
p_team_id = this_game.away_team_id
|
||||||
|
if this_play.inning_half == 'top':
|
||||||
|
p_team_id = this_game.home_team_id
|
||||||
|
return get_one_lineup(this_game.id, team_id=p_team_id, position='P', active=True)
|
||||||
|
|||||||
@ -358,8 +358,15 @@ class Gameplay(commands.Cog):
|
|||||||
this_ai = get_manager(game)
|
this_ai = get_manager(game)
|
||||||
logging.debug(f'Pitching team is an AI')
|
logging.debug(f'Pitching team is an AI')
|
||||||
gm_name = f'{game_state["pitcher"]["team"]["gmname"]}'
|
gm_name = f'{game_state["pitcher"]["team"]["gmname"]}'
|
||||||
n_pitcher = await next_pitcher(game_state['curr_play'], game_state["pitcher"]["team"], self.bot)
|
# n_pitcher = await next_pitcher(game_state['curr_play'], game_state["pitcher"]["team"], self.bot)
|
||||||
logging.debug(f'n_pitcher: {n_pitcher}')
|
# logging.debug(f'n_pitcher: {n_pitcher}')
|
||||||
|
used_pitchers = await get_team_lineups(
|
||||||
|
game_id=game_state['curr_play'].game.id,
|
||||||
|
team_id=game_state["pitcher"]["team"]['id'],
|
||||||
|
inc_inactive=True,
|
||||||
|
pitchers_only=True,
|
||||||
|
as_string=False
|
||||||
|
)
|
||||||
|
|
||||||
last_inning_ender = get_last_inning_end_play(
|
last_inning_ender = get_last_inning_end_play(
|
||||||
game.id,
|
game.id,
|
||||||
@ -376,23 +383,24 @@ class Gameplay(commands.Cog):
|
|||||||
elif game_state['curr_play'].is_new_inning and game.short_game and game_state['curr_play'].inning_num != 1:
|
elif game_state['curr_play'].is_new_inning and game.short_game and game_state['curr_play'].inning_num != 1:
|
||||||
logging.debug(f'{game_state["pitcher"]["team"]["sname"]} going the to pen.')
|
logging.debug(f'{game_state["pitcher"]["team"]["sname"]} going the to pen.')
|
||||||
|
|
||||||
if 'card_id' in n_pitcher:
|
if len(used_pitchers) < 8:
|
||||||
replace_pitcher(game_state['pitcher']['team'], game_state['curr_play'], n_pitcher['card_id'])
|
make_sub(ai_manager.get_relief_pitcher(
|
||||||
embed.set_thumbnail(url=n_pitcher['player']['image'])
|
game_state['curr_play'], game_state['pitcher']['team'], used_pitchers, game.game_type
|
||||||
|
))
|
||||||
|
new_pitcher = await get_player(game, ai_manager.get_pitcher(game, game_state['curr_play']))
|
||||||
|
embed.set_thumbnail(url=new_pitcher['image'])
|
||||||
embed.add_field(
|
embed.add_field(
|
||||||
name=f'SUBSTITUTION',
|
name=f'SUBSTITUTION',
|
||||||
value=f'The {game_state["pitcher"]["team"]["sname"]} have brought in '
|
value=f'The {game_state["pitcher"]["team"]["sname"]} have brought in '
|
||||||
f'{n_pitcher["player"]["p_name"]} to pitch.'
|
f'[{new_pitcher["p_name"]}]({new_pitcher["image"]}) to pitch.'
|
||||||
)
|
)
|
||||||
else:
|
else:
|
||||||
ai_note += f'- continue with auto-fatigued {game_state["pitcher"]["p_name"]}\n'
|
ai_note += f'- continue with auto-fatigued {game_state["pitcher"]["p_name"]}\n'
|
||||||
|
|
||||||
else:
|
else:
|
||||||
if 'card_id' in n_pitcher:
|
if len(used_pitchers) < 8:
|
||||||
logging.debug(f'{game_state["pitcher"]["team"]["sname"]} are warming up {n_pitcher}.')
|
|
||||||
ai_note += f'- go to the pen if the pitcher fatigues (`/log ai-pitcher-sub`)\n'
|
ai_note += f'- go to the pen if the pitcher fatigues (`/log ai-pitcher-sub`)\n'
|
||||||
else:
|
else:
|
||||||
logging.warning(f'{game_state["pitcher"]["team"]["sname"]} are out of pitchers.')
|
|
||||||
ai_note += f' - continue with {game_state["pitcher"]["p_name"]}\n'
|
ai_note += f' - continue with {game_state["pitcher"]["p_name"]}\n'
|
||||||
|
|
||||||
logging.debug(f'past the first conditional in AI stuff')
|
logging.debug(f'past the first conditional in AI stuff')
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user