Prep for gauntlet 1.0
This commit is contained in:
parent
1a36b60565
commit
aeb17cb7d1
@ -568,10 +568,8 @@ class Economy(commands.Cog):
|
||||
}
|
||||
for pack in p_query['packs']:
|
||||
p_group = None
|
||||
logging.info(f'this pack type: {pack["pack_type"]["name"]}')
|
||||
if pack['pack_team'] is None and pack['pack_cardset'] is None:
|
||||
if pack['pack_type']['name'] in p_data:
|
||||
logging.info(f'adding this pack')
|
||||
p_group = pack['pack_type']['name']
|
||||
|
||||
elif pack['pack_team'] is not None:
|
||||
@ -1152,6 +1150,7 @@ class Economy(commands.Cog):
|
||||
roster_counts = {
|
||||
'SP': 0,
|
||||
'RP': 0,
|
||||
'CP': 0,
|
||||
'C': 0,
|
||||
'1B': 0,
|
||||
'2B': 0,
|
||||
|
||||
197
cogs/gameplay.py
197
cogs/gameplay.py
@ -1384,22 +1384,9 @@ class Gameplay(commands.Cog):
|
||||
)
|
||||
|
||||
if r_query['count'] == 0:
|
||||
try:
|
||||
await gauntlets.run_draft(interaction, main_team, this_event, draft_team=team)
|
||||
except Exception as e:
|
||||
logging.error(f'Failed to run {event_name} draft for the {team["sname"]}: {e}')
|
||||
await gauntlets.wipe_team(team, interaction)
|
||||
await interaction.channel.send(
|
||||
content=f'Shoot - it looks like we ran into an issue running the draft. I had to clear it all out '
|
||||
f'for now. I let {get_cal_user(interaction).mention} know what happened so he better '
|
||||
f'fix it quick.'
|
||||
)
|
||||
return
|
||||
|
||||
await interaction.channel.send(
|
||||
f'Good luck, champ in the making! To start playing, follow these steps:\n\n'
|
||||
f'1) Update your Gauntlet lineups here: {get_roster_sheet(team)}`\n'
|
||||
f'2) Go play your first game with `/new-game gauntlet {this_event["name"]}`'
|
||||
f'I don\'t see an active run for you. If you would like to start a new one, run '
|
||||
f'`/new-game gauntlet {this_event["name"]}` and we can get you started in no time!'
|
||||
)
|
||||
return
|
||||
|
||||
@ -1929,182 +1916,20 @@ class Gameplay(commands.Cog):
|
||||
if gauntlet_team is None:
|
||||
await ctx.send(f'Good game! Go share the highlights in {get_channel(ctx, "pd-news-ticker").mention}!')
|
||||
|
||||
@app_commands.command(
|
||||
name='setlineup',
|
||||
description='Manually set lineups for for SBa games',
|
||||
)
|
||||
@app_commands.describe(
|
||||
order_1_player='SBa: Player Name; PD: Card #',
|
||||
order_1_pos='C for Catcher, 1B for first base, P for pitcher, etc.',
|
||||
order_2_player='SBa: Player Name; PD: Card #',
|
||||
order_2_pos='C for Catcher, 1B for first base, P for pitcher, etc.',
|
||||
order_3_player='SBa: Player Name; PD: Card #',
|
||||
order_3_pos='C for Catcher, 1B for first base, P for pitcher, etc.',
|
||||
order_4_player='SBa: Player Name; PD: Card #',
|
||||
order_4_pos='C for Catcher, 1B for first base, P for pitcher, etc.',
|
||||
order_5_player='SBa: Player Name; PD: Card #',
|
||||
order_5_pos='C for Catcher, 1B for first base, P for pitcher, etc.',
|
||||
order_6_player='SBa: Player Name; PD: Card #',
|
||||
order_6_pos='C for Catcher, 1B for first base, P for pitcher, etc.',
|
||||
order_7_player='SBa: Player Name; PD: Card #',
|
||||
order_7_pos='C for Catcher, 1B for first base, P for pitcher, etc.',
|
||||
order_8_player='SBa: Player Name; PD: Card #',
|
||||
order_8_pos='C for Catcher, 1B for first base, P for pitcher, etc.',
|
||||
order_9_player='SBa: Player Name; PD: Card #',
|
||||
order_9_pos='C for Catcher, 1B for first base, P for pitcher, etc.',
|
||||
order_10_player='SBa: Player Name; PD: Card #; only used with a DH',
|
||||
order_10_pos='P for pitcher; only used with a DH'
|
||||
)
|
||||
@app_commands.checks.has_any_role(SBA_PLAYERS_ROLE_NAME, PD_PLAYERS_ROLE_NAME)
|
||||
async def set_lineup_command(
|
||||
self, interaction: discord.Interaction, team_abbrev: str, order_1_player: str, order_1_pos: str,
|
||||
order_2_player: str, order_2_pos: str, order_3_player: str, order_3_pos: str, order_4_player: str,
|
||||
order_4_pos: str, order_5_player: str, order_5_pos: str, order_6_player: str, order_6_pos: str,
|
||||
order_7_player: str, order_7_pos: str, order_8_player: str, order_8_pos: str, order_9_player: str,
|
||||
order_9_pos: str, order_10_player: Optional[str] = None, order_10_pos: Optional[str] = 'P'):
|
||||
this_game = get_one_game(channel_id=interaction.channel_id, active=True)
|
||||
if not this_game:
|
||||
await interaction.response.send_message(f'I dont\'t see an active game in this channel!')
|
||||
return
|
||||
|
||||
owner_team = await get_game_team(this_game, interaction.user.id)
|
||||
lineup_team = await get_game_team(this_game, team_abbrev=team_abbrev)
|
||||
|
||||
if not owner_team['id'] in [this_game.away_team_id, this_game.home_team_id]:
|
||||
await interaction.response.send_message('Bruh. Only GMs of the active teams can set lineups.')
|
||||
return
|
||||
if not lineup_team['id'] in [this_game.away_team_id, this_game.home_team_id]:
|
||||
await interaction.response.send_message(
|
||||
f'I do not see {lineup_team["sname"]} in this game. Please check the team abbrev and try again'
|
||||
)
|
||||
return
|
||||
|
||||
existing_lineups = await get_team_lineups(this_game.id, lineup_team['id'])
|
||||
if not existing_lineups or not len(existing_lineups):
|
||||
await interaction.response.send_message(
|
||||
f'It looks like the {lineup_team["sname"]} already have a lineup. Run `/substitution` to make changes.'
|
||||
)
|
||||
return
|
||||
|
||||
await interaction.response.defer()
|
||||
|
||||
all_lineups = []
|
||||
all_pos = []
|
||||
lineup_data = [
|
||||
(order_1_pos, order_1_player), (order_2_pos, order_2_player), (order_3_pos, order_3_player),
|
||||
(order_4_pos, order_4_player), (order_5_pos, order_5_player), (order_6_pos, order_6_player),
|
||||
(order_7_pos, order_7_player), (order_8_pos, order_8_player), (order_9_pos, order_9_player),
|
||||
(order_10_pos, order_10_player)
|
||||
]
|
||||
for index, pair in enumerate(lineup_data):
|
||||
if not pair[1]:
|
||||
break
|
||||
|
||||
if pair[0].upper() not in all_pos:
|
||||
all_pos.append(pair[0].upper())
|
||||
else:
|
||||
raise SyntaxError(f'You have more than one {pair[0].upper()} in this lineup. Please update and set the '
|
||||
f'lineup again.')
|
||||
|
||||
if this_game.is_pd:
|
||||
this_card = db_get(f'cards', object_id=int(pair[1]))
|
||||
if this_card['team']['id'] != lineup_team['id']:
|
||||
raise SyntaxError(f'Easy there, champ. Looks like card ID {pair[1]} belongs to the '
|
||||
f'{this_card["team"]["sname"]}. Try again with only cards you own.')
|
||||
player_id = this_card['player']['player_id']
|
||||
card_id = pair[1]
|
||||
else:
|
||||
this_player = get_sba_player(pair[1], season=SBA_SEASON)
|
||||
if this_player['team']['id'] != lineup_team['id']:
|
||||
raise SyntaxError(f'Easy there, champ. Looks like {pair[1]} is on '
|
||||
f'{this_player["team"]["sname"]}. Try again with only your own players.')
|
||||
player_id = this_player['id']
|
||||
card_id = None
|
||||
|
||||
this_lineup = {
|
||||
'game_id': this_game.id,
|
||||
'team_id': lineup_team['id'],
|
||||
'player_id': player_id,
|
||||
'card_id': card_id,
|
||||
'position': pair[0].upper(),
|
||||
'batting_order': index + 1,
|
||||
'after_play': 0
|
||||
}
|
||||
|
||||
all_lineups.append(this_lineup)
|
||||
|
||||
if len(all_lineups) < 9:
|
||||
await interaction.edit_original_response(
|
||||
content=f'Looks like the {lineup_team["sname"]} lineup card didn\'t come through clearly. I\'ll sort '
|
||||
f'this out with {lineup_team["gmname"]} and {get_cal_user(interaction).mention}. I\'ll end '
|
||||
f'this game - why don\'t you play against somebody else for now?'
|
||||
)
|
||||
patch_game(this_game.id, active=False)
|
||||
return
|
||||
|
||||
logging.info(f'Setting lineup for {owner_team["sname"]} in {"PD" if this_game.is_pd else "SBa"} game')
|
||||
post_lineups(all_lineups)
|
||||
|
||||
try:
|
||||
await interaction.edit_original_response(content=None, embed=await self.get_game_state_embed(this_game))
|
||||
except IntegrityError as e:
|
||||
logging.debug(f'Unable to pull game_state for game_id {this_game.id} until both lineups are in: {e}')
|
||||
await interaction.response.send_message(f'Game state will be posted once both lineups are in')
|
||||
return
|
||||
|
||||
# @app_commands.command(name='starting-pitcher')
|
||||
# @app_commands.checks.has_any_role(SBA_PLAYERS_ROLE_NAME, PD_PLAYERS_ROLE_NAME)
|
||||
# async def starting_pitcher_command(
|
||||
# self, interaction: discord.Interaction, team_abbrev: str, sp_card_id: int, batting_order: int = 10):
|
||||
# this_game = get_one_game(channel_id=interaction.channel_id, active=True)
|
||||
# if not this_game:
|
||||
# await interaction.response.send_message(f'I dont\'t see an active game in this channel!')
|
||||
# return
|
||||
#
|
||||
# await interaction.response.defer()
|
||||
#
|
||||
# owner_team = await get_game_team(this_game, interaction.user.id)
|
||||
# lineup_team = await get_game_team(this_game, team_abbrev=team_abbrev)
|
||||
# this_card = db_get(f'cards', object_id=sp_card_id)
|
||||
# if this_card['team']['id'] != lineup_team['id']:
|
||||
# await interaction.edit_original_response(
|
||||
# content=f'Uh oh, it looks like that copy of {this_card["player"]["p_name"]} doesn\'t belong to you. '
|
||||
# f'Please enter the card_id of a card from your collection.'
|
||||
# )
|
||||
# return
|
||||
#
|
||||
# this_lineup = {
|
||||
# 'game_id': this_game.id,
|
||||
# 'team_id': lineup_team['id'],
|
||||
# 'player_id': this_card['player']['player_id'],
|
||||
# 'card_id': sp_card_id,
|
||||
# 'position': 'P',
|
||||
# 'batting_order': batting_order,
|
||||
# 'after_play': 0
|
||||
# }
|
||||
# post_lineups([this_lineup])
|
||||
#
|
||||
# try:
|
||||
# await interaction.edit_original_response(content=None, embed=await self.get_game_state_embed(this_game))
|
||||
# except IntegrityError as e:
|
||||
# logging.debug(f'Unable to pull game_state for game_id {this_game.id} until both lineups are in: {e}')
|
||||
# await interaction.response.send_message(f'Game state will be posted once both lineups are in')
|
||||
# return
|
||||
|
||||
@app_commands.command(
|
||||
name='readlineup',
|
||||
description='Import a saved lineup directly from the team sheet for PD games'
|
||||
)
|
||||
@app_commands.describe(
|
||||
team_abbrev='The 2- to 4-digit abbreviation for the team being set',
|
||||
roster_num='1, 2, or 3: 1 is Primary, 2 is Secondary, 3 is Tertiary; Enter 1 for AI team',
|
||||
lineup_num='Technically not a number anymore, huh?',
|
||||
roster='Which roster to pull from your sheet?',
|
||||
lineup='Which handedness lineup are you using?',
|
||||
sp_card_id='Light gray number to the left of the pitcher\'s name on your depth chart'
|
||||
)
|
||||
@app_commands.checks.has_any_role(PD_PLAYERS_ROLE_NAME)
|
||||
async def read_lineup_command(
|
||||
self, interaction: discord.Interaction, team_abbrev: str, roster_num: Literal[1, 2, 3],
|
||||
lineup_num: Literal['v Right', 'v Left'], sp_card_id: int):
|
||||
self, interaction: discord.Interaction, team_abbrev: str, roster: Literal['Primary', 'Secondary', 'Ranked'],
|
||||
lineup: Literal['v Right', 'v Left'], sp_card_id: int):
|
||||
this_game = get_one_game(channel_id=interaction.channel_id, active=True)
|
||||
if not this_game:
|
||||
await interaction.response.send_message(f'I dont\'t see an active game in this channel!')
|
||||
@ -2138,10 +1963,18 @@ class Gameplay(commands.Cog):
|
||||
return
|
||||
|
||||
await interaction.response.send_message(f'Let\'s put this lineup card together...')
|
||||
if lineup_num == 'v Right':
|
||||
|
||||
if lineup == 'v Right':
|
||||
l_num = 1
|
||||
else:
|
||||
l_num = 2
|
||||
|
||||
if roster == 'Primary':
|
||||
roster_num = 1
|
||||
elif roster == 'Secondary':
|
||||
roster_num = 2
|
||||
else:
|
||||
roster_num = 3
|
||||
lineup_cells = get_roster_lineups(lineup_team, self.bot, roster_num, l_num)
|
||||
|
||||
all_lineups = []
|
||||
|
||||
@ -756,7 +756,16 @@ class Players(commands.Cog):
|
||||
this_team = t_query['teams'][0]
|
||||
r_query = db_get('gauntletruns', params=[('team_id', this_team['id']), ('is_active', True)])
|
||||
|
||||
this_run = r_query['runs'][0]
|
||||
if r_query['count'] != 0:
|
||||
this_run = r_query['runs'][0]
|
||||
else:
|
||||
await interaction.channel.send(
|
||||
content=f'I do not see an active run for the {this_team["lname"]}.'
|
||||
)
|
||||
else:
|
||||
await interaction.channel.send(
|
||||
content=f'I do not see an active run for {team_abbrev.upper()}.'
|
||||
)
|
||||
|
||||
await interaction.edit_original_response(
|
||||
content=None,
|
||||
|
||||
@ -262,7 +262,8 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
|
||||
|
||||
await interaction.edit_original_response(
|
||||
content=None,
|
||||
embeds=get_embeds()
|
||||
embeds=get_embeds(),
|
||||
view=None
|
||||
)
|
||||
|
||||
if this_event['id'] == 1:
|
||||
@ -292,6 +293,7 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
|
||||
params = [
|
||||
('min_rarity', RARITY['MVP']), ('max_rarity', RARITY['MVP']), ('cardset_id', 8)
|
||||
]
|
||||
mario_round = 10
|
||||
else:
|
||||
params.extend([
|
||||
('min_rarity', RARITY['MVP']), ('max_rarity', RARITY['MVP']), ('pos_exc', 'RP')
|
||||
@ -301,6 +303,7 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
|
||||
params = [
|
||||
('min_rarity', RARITY['All-Star']), ('max_rarity', RARITY['All-Star']), ('cardset_id', 8)
|
||||
]
|
||||
mario_round = 11
|
||||
else:
|
||||
params.extend([
|
||||
('min_rarity', RARITY['All-Star']), ('max_rarity', RARITY['All-Star'])
|
||||
@ -310,6 +313,7 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
|
||||
params = [
|
||||
('min_rarity', RARITY['Starter']), ('max_rarity', RARITY['Starter']), ('cardset_id', 8)
|
||||
]
|
||||
mario_round = 12
|
||||
else:
|
||||
params.extend([
|
||||
('min_rarity', RARITY['Starter']), ('max_rarity', RARITY['Starter'])
|
||||
@ -513,7 +517,7 @@ async def post_result(run_id: int, is_win: bool, this_team, bot, ctx):
|
||||
f'{this_run["losses"]}!'
|
||||
)
|
||||
final_message = f'That\'s number 10! Way to go - you have completed the **{this_event["name"]} Gauntlet** ' \
|
||||
f'with a record of {this_run["wins"]}-{this_run["losses"]}!'
|
||||
f'with a record of {this_run["wins"]}-{this_run["losses"]}! '
|
||||
else:
|
||||
final_message = f'Big win there! Your {this_event["name"]} record is now **{this_run["wins"]}-' \
|
||||
f'{this_run["losses"]}**. '
|
||||
|
||||
@ -64,7 +64,7 @@ IMAGES = {
|
||||
'mvp-hype': f'{PD_CARD_URL}/mvp.png',
|
||||
'pack-sta': f'{PD_CARD_URL}/pack-standard.png',
|
||||
'pack-pre': f'{PD_CARD_URL}/pack-premium.png',
|
||||
'pack-mar': f'{PD_CARD_URL}/mario/mario-gauntlet.png',
|
||||
'pack-mar': f'{PD_CARD_URL}/sluggers/mario-gauntlet.png',
|
||||
'mvp': {
|
||||
'Arizona Diamondbacks': f'{PD_CARD_URL}/mvp/arizona-diamondbacks.gif',
|
||||
'Atlanta Braves': f'{PD_CARD_URL}/mvp/atlanta-braves.gif',
|
||||
|
||||
Loading…
Reference in New Issue
Block a user