feat: implement ranked game mode (#24)
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m16s
All checks were successful
Build Docker Image / build (pull_request) Successful in 1m16s
Adds `/new-game ranked` slash command for human-vs-human ranked games. Sets `game_type='ranked'` and `ranked=True` on the Game model. Also adds 'ranked' case to `get_scorebug_embed` so scorebug title shows '- Ranked' instead of falling through to '- Unlimited'. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
a1b0e676c2
commit
7a865f1fc8
1919
cogs/gameplay.py
1919
cogs/gameplay.py
File diff suppressed because it is too large
Load Diff
@ -75,7 +75,6 @@ from utilities.dropdown import (
|
||||
from utilities.embeds import image_embed
|
||||
from utilities.pages import Pagination
|
||||
|
||||
|
||||
logger = logging.getLogger("discord_app")
|
||||
WPA_DF = pd.read_csv(f"storage/wpa_data.csv").set_index("index")
|
||||
TO_BASE = {2: "to second", 3: "to third", 4: "home"}
|
||||
@ -156,6 +155,8 @@ async def get_scorebug_embed(
|
||||
gt_string = " - Flashback"
|
||||
elif "exhibition" in this_game.game_type:
|
||||
gt_string = " - Exhibition"
|
||||
elif this_game.game_type == "ranked":
|
||||
gt_string = " - Ranked"
|
||||
logger.info(f"get_scorebug_embed - this_game: {this_game} / gt_string: {gt_string}")
|
||||
|
||||
curr_play = this_game.current_play_or_none(session)
|
||||
@ -612,9 +613,11 @@ async def read_lineup(
|
||||
this_game,
|
||||
this_team=lineup_team,
|
||||
lineup_num=lineup_num,
|
||||
roster_num=this_game.away_roster_id
|
||||
if this_game.home_team.is_ai
|
||||
else this_game.home_roster_id,
|
||||
roster_num=(
|
||||
this_game.away_roster_id
|
||||
if this_game.home_team.is_ai
|
||||
else this_game.home_roster_id
|
||||
),
|
||||
)
|
||||
|
||||
await interaction.edit_original_response(
|
||||
@ -759,7 +762,11 @@ def complete_play(session: Session, this_play: Play):
|
||||
opponent_play = get_last_team_play(
|
||||
session, this_play.game, this_play.pitcher.team
|
||||
)
|
||||
nbo = opponent_play.batting_order + 1 if opponent_play.pa == 1 else opponent_play.batting_order
|
||||
nbo = (
|
||||
opponent_play.batting_order + 1
|
||||
if opponent_play.pa == 1
|
||||
else opponent_play.batting_order
|
||||
)
|
||||
except PlayNotFoundException as e:
|
||||
logger.info(
|
||||
f"logic_gameplay - complete_play - No last play found for {this_play.pitcher.team.sname}, setting upcoming batting order to 1"
|
||||
@ -1106,7 +1113,8 @@ async def get_lineups_from_sheets(
|
||||
position = row[0].upper()
|
||||
if position != "DH":
|
||||
player_positions = [
|
||||
getattr(this_card.player, f"pos_{i}") for i in range(1, 9)
|
||||
getattr(this_card.player, f"pos_{i}")
|
||||
for i in range(1, 9)
|
||||
if getattr(this_card.player, f"pos_{i}") is not None
|
||||
]
|
||||
if position not in player_positions:
|
||||
@ -1216,7 +1224,10 @@ async def get_full_roster_from_sheets(
|
||||
|
||||
|
||||
async def checks_log_interaction(
|
||||
session: Session, interaction: discord.Interaction, command_name: str, lock_play: bool = True
|
||||
session: Session,
|
||||
interaction: discord.Interaction,
|
||||
command_name: str,
|
||||
lock_play: bool = True,
|
||||
) -> tuple[Game, Team, Play]:
|
||||
"""
|
||||
Validates interaction permissions and optionally locks the current play for processing.
|
||||
@ -3862,7 +3873,14 @@ async def xchecks(
|
||||
this_play.run,
|
||||
this_play.triple,
|
||||
this_play.batter_final,
|
||||
) = 1, 1, 1, 1, 1, 4
|
||||
) = (
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
4,
|
||||
)
|
||||
this_play = advance_runners(session, this_play, num_bases=4, earned_bases=3)
|
||||
|
||||
session.add(this_play)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user