Update gameplay.py

Add /new-game gauntlet command
This commit is contained in:
Cal Corum 2023-03-14 00:48:46 -05:00
parent ac7c98f480
commit 568d030c3c

View File

@ -16,7 +16,8 @@ from typing import Optional, Literal
from dice import sa_fielding_roll
from helpers import SBA_PLAYERS_ROLE_NAME, PD_PLAYERS_ROLE_NAME, random_conf_gif, SBA_SEASON, PD_SEASON, IMAGES, \
get_team_embed, Confirm, get_pos_abbrev, SBA_COLOR, get_roster_lineups, Question, give_packs, send_to_channel, \
get_channel, get_or_create_role, team_role, get_cal_user, get_card_embeds, ButtonOptions, get_ratings_guide
get_channel, get_or_create_role, team_role, get_cal_user, get_card_embeds, ButtonOptions, get_ratings_guide, \
get_team_by_owner
from gameplay_helpers import *
from db_calls import db_get, db_patch, db_post, db_delete, get_team_by_abbrev
from db_calls_gameplay import StratGame, StratPlay, StratLineup, StratManagerAi, get_sba_team, get_sba_player, \
@ -950,7 +951,7 @@ class Gameplay(commands.Cog):
@group_new_game.command(name='mlb-campaign', description='Start a new MLB Campaign game against an AI')
@commands.has_any_role(PD_PLAYERS_ROLE_NAME)
async def new_game_command(
async def new_game_campaign_command(
self, interaction: discord.Interaction, league: Literal['Minor League', 'Major League', 'Hall of Fame'],
away_team_abbrev: str, home_team_abbrev: str, num_innings: Literal[9, 3]):
await interaction.response.defer()
@ -1134,7 +1135,7 @@ class Gameplay(commands.Cog):
@group_new_game.command(name='ranked', description='Start a new Ranked game against another human')
@commands.has_any_role(PD_PLAYERS_ROLE_NAME)
async def new_game_command(
async def new_game_ranked_command(
self, interaction: discord.Interaction, away_team_abbrev: str, home_team_abbrev: str,
num_innings: Literal[9, 3]):
await interaction.response.defer()
@ -1225,7 +1226,7 @@ class Gameplay(commands.Cog):
@group_new_game.command(name='unlimited', description='Start a new Unlimited game against another human')
@commands.has_any_role(PD_PLAYERS_ROLE_NAME)
async def new_game_command(
async def new_game_unlimited_command(
self, interaction: discord.Interaction, away_team_abbrev: str, home_team_abbrev: str,
num_innings: Literal[9, 3]):
await interaction.response.defer()
@ -1314,6 +1315,47 @@ class Gameplay(commands.Cog):
)
return
@group_new_game.command(name='gauntlet', description='Start a new Gauntlet game against an AI')
@commands.has_any_role(PD_PLAYERS_ROLE_NAME)
async def new_game_gauntlet_command(self, interaction: discord.Interaction, event_name: Literal['Test Gauntlet']):
await interaction.response.defer()
conflict = get_one_game(channel_id=interaction.channel.id, active=True)
if conflict:
await interaction.edit_original_response(
content=f'Ope. There is already a game going on in this channel. Please wait for it to complete '
f'before starting a new one.')
return
try:
if interaction.channel.category.name != 'Public Fields':
await interaction.response.send_message(
f'Why don\'t you head down to one of the Public Fields that way other humans can help if anything '
f'pops up?'
)
return
except Exception as e:
logging.error(f'Could not check channel category: {e}')
team = get_team_by_owner(interaction.user.id)
if not team:
await interaction.edit_original_response(
content=f'I don\'t see a team for you, yet. You can sign up with the `/newteam` command!'
)
return
conflict = count_team_games(team['id'])
if conflict['count']:
await interaction.edit_original_response(
content=f'Ope. The {team["sname"]} are already playing over in '
f'{interaction.guild.get_channel(conflict["games"][0]["channel_id"]).mention}'
)
return
# Get or create Gauntlet run
# If a new run, perform draft
# If not new or after draft, create new AI game
@commands.command(name='force-endgame', help='Mod: Force a game to end without stats')
@commands.is_owner()
async def force_end_game_command(self, ctx: commands.Context):