Update gauntlets.py

Added randomized Mario round in draft
This commit is contained in:
Cal Corum 2023-03-27 16:48:34 -05:00
parent 7daee29dca
commit a83bc10581

View File

@ -1,6 +1,7 @@
import copy import copy
import datetime import datetime
import logging import logging
import random
import discord import discord
import requests import requests
@ -136,7 +137,7 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
embed_title = f'{main_team["lname"]} - {this_event["name"]} Draft' embed_title = f'{main_team["lname"]} - {this_event["name"]} Draft'
embed_description = f'{this_event["name"]}' embed_description = f'{this_event["name"]}'
base_params = ai_manager.MAJOR_CARDSET_PARAMS base_params = ai_manager.MAJOR_CARDSET_PARAMS
base_params.append(('limit', 8)) base_params.extend([('limit', 8), ('cardset_id', 8)])
else: else:
logging.error(f'run_draft - Event ID {this_event["id"]} not recognized') logging.error(f'run_draft - Event ID {this_event["id"]} not recognized')
raise KeyError(f'Draft data not found for Gauntlet {this_event["id"]}') raise KeyError(f'Draft data not found for Gauntlet {this_event["id"]}')
@ -183,6 +184,25 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
round_num = 1 round_num = 1
counter = 0 counter = 0
view = helpers.Confirm([interaction.user])
view.confirm.label = 'Let\'s Go!'
intro_embed = get_embed(this_event=this_event)
intro_embed.title += ' - Are you ready?'
await interaction.edit_original_response(
content=None,
embed=intro_embed,
view=view
)
await view.wait()
if not view.value:
await interaction.edit_original_response(content=None, embed=intro_embed, view=None)
await interaction.channel.send('You\'ll be back')
return
def get_embeds(include_links=True): def get_embeds(include_links=True):
top_embed = helpers.get_team_embed(f'{embed_title} - Round {round_num}') top_embed = helpers.get_team_embed(f'{embed_title} - Round {round_num}')
top_embed.description = f'Rarity Counts' top_embed.description = f'Rarity Counts'
@ -246,6 +266,7 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
) )
if this_event['id'] == 1: if this_event['id'] == 1:
mario_round = None
while round_num <= 26 and counter < 50: while round_num <= 26 and counter < 50:
counter += 1 counter += 1
# Set params based on current round # Set params based on current round
@ -267,17 +288,32 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
('min_rarity', RARITY['Reserve']), ('max_rarity', RARITY['Reserve']) ('min_rarity', RARITY['Reserve']), ('max_rarity', RARITY['Reserve'])
]) ])
elif round_num == 10: elif round_num == 10:
params.extend([ if random.randint(1, 2) == 1:
('min_rarity', RARITY['MVP']), ('max_rarity', RARITY['MVP']), ('pos_exc', 'RP') params = [
]) ('min_rarity', RARITY['MVP']), ('max_rarity', RARITY['MVP']), ('cardset_id', 8)
]
else:
params.extend([
('min_rarity', RARITY['MVP']), ('max_rarity', RARITY['MVP']), ('pos_exc', 'RP')
])
elif round_num == 11: elif round_num == 11:
params.extend([ if random.randint(1, 2) == 1 and mario_round is None:
('min_rarity', RARITY['All-Star']), ('max_rarity', RARITY['All-Star']) params = [
]) ('min_rarity', RARITY['All-Star']), ('max_rarity', RARITY['All-Star']), ('cardset_id', 8)
]
else:
params.extend([
('min_rarity', RARITY['All-Star']), ('max_rarity', RARITY['All-Star'])
])
elif round_num == 12: elif round_num == 12:
params.extend([ if mario_round is None:
('min_rarity', RARITY['Starter']), ('max_rarity', RARITY['Starter']) params = [
]) ('min_rarity', RARITY['Starter']), ('max_rarity', RARITY['Starter']), ('cardset_id', 8)
]
else:
params.extend([
('min_rarity', RARITY['Starter']), ('max_rarity', RARITY['Starter'])
])
elif round_num <= 15: elif round_num <= 15:
params.extend([ params.extend([
('min_rarity', RARITY['Replacement']), ('max_rarity', RARITY['Replacement']) ('min_rarity', RARITY['Replacement']), ('max_rarity', RARITY['Replacement'])
@ -476,17 +512,20 @@ async def post_result(run_id: int, is_win: bool, this_team, bot, ctx):
f'**{this_event["name"]} Gauntlet** with a record of {this_run["wins"]}-' f'**{this_event["name"]} Gauntlet** with a record of {this_run["wins"]}-'
f'{this_run["losses"]}!' 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"]}!'
else: else:
final_message = f'Big win there! Your {this_event["name"]} record is now **{this_run["wins"]}-' \ final_message = f'Big win there! Your {this_event["name"]} record is now **{this_run["wins"]}-' \
f'{this_run["losses"]}**. ' f'{this_run["losses"]}**. '
if len(reward_string) > 0:
final_message += f"You earned the following rewards:\n{reward_string}"
final_message += f'\n\nGo share the highlights in {get_channel(ctx, "pd-news-ticker").mention}!'
await ctx.send( if len(reward_string) > 0:
content=final_message, final_message += f"You earned the following rewards:\n{reward_string}"
embed=get_embed(this_run) final_message += f'\n\nGo share the highlights in {get_channel(ctx, "pd-news-ticker").mention}!'
)
await ctx.send(
content=final_message,
embed=get_embed(this_run)
)
else: else:
this_run = db_patch( this_run = db_patch(
'gauntletruns', 'gauntletruns',