From 8b8fa65023a70a0d1791faeabcbe8154b6c75ac8 Mon Sep 17 00:00:00 2001 From: Cal Corum Date: Fri, 28 Feb 2025 22:24:11 -0600 Subject: [PATCH] Add lineup embed field without links --- command_logic/logic_gameplay.py | 4 ++-- in_game/gameplay_models.py | 10 +++++++--- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/command_logic/logic_gameplay.py b/command_logic/logic_gameplay.py index 5b4f95c..e20b0fa 100644 --- a/command_logic/logic_gameplay.py +++ b/command_logic/logic_gameplay.py @@ -256,11 +256,11 @@ async def get_scorebug_embed(session: Session, this_game: Game, full_length: boo if full_length: embed.add_field( name=f'{this_game.away_team.abbrev} Lineup', - value=this_game.team_lineup(session, this_game.away_team) + value=this_game.team_lineup(session, this_game.away_team, with_links=False) ) embed.add_field( name=f'{this_game.home_team.abbrev} Lineup', - value=this_game.team_lineup(session, this_game.home_team) + value=this_game.team_lineup(session, this_game.home_team, with_links=False) ) else: logger.info(f'There is no play in game {this_game.id}, posting lineups') diff --git a/in_game/gameplay_models.py b/in_game/gameplay_models.py index d5e9d39..c2d0118 100644 --- a/in_game/gameplay_models.py +++ b/in_game/gameplay_models.py @@ -229,12 +229,16 @@ class Game(SQLModel, table=True): return new_play - def team_lineup(self, session: Session, team: Team) -> str: + def team_lineup(self, session: Session, team: Team, with_links: bool = True) -> str: all_lineups = session.exec(select(Lineup).where(Lineup.team == team, Lineup.game == self).order_by(Lineup.batting_order)).all() lineup_val = '' for line in all_lineups: - lineup_val += f'{line.batting_order}. {line.player.name_card_link("batting" if line.position != "P" else "pitching")} {line.position}\n' + if with_links: + name_string = {line.player.name_card_link("batting" if line.position != "P" else "pitching")} + else: + name_string = {line.player.name_with_desc} + lineup_val += f'{line.batting_order}. {name_string} {line.position}\n' return lineup_val @@ -936,7 +940,7 @@ class BatterScouting(BatterScoutingBase, table=True): ratings_vr: BattingRatings = Relationship( sa_relationship_kwargs=dict(foreign_keys="[BatterScouting.ratings_vr_id]",single_parent=True), cascade_delete=True ) - cards: list['Card'] = Relationship(back_populates='batterscouting') + cards: list['Card'] = Relationship(back_populates='batterscouting', cascade_delete=False) class PitchingCardBase(SQLModel):