Merge branch 'master' into sqlmodel-alembic-pytests-rebuild

This commit is contained in:
Cal Corum 2024-11-03 18:20:01 -06:00
commit 8da859b63a
8 changed files with 287 additions and 213 deletions

4
.gitignore vendored
View File

@ -130,6 +130,6 @@ dmypy.json
# Project specifics
.idea/
storage*
docker-compose.yml
# Project Specific
storage*

View File

@ -7,14 +7,11 @@ import aiohttp
import os
AUTH_TOKEN = {'Authorization': f'Bearer {os.environ.get("API_TOKEN")}'}
DB_URL = 'https://pd.manticorum.com/api'
ENV_DATABASE = os.environ.get('DATABASE').lower()
DB_URL = 'https://pd.manticorum.com/api' if 'prod' in ENV_DATABASE else 'https://pddev.manticorum.com/api'
master_debug = True
alt_database = 'dev'
PLAYER_CACHE = {}
if alt_database == 'dev':
DB_URL = 'https://pddev.manticorum.com/api'
def param_char(other_params):
if other_params:

View File

@ -139,38 +139,63 @@ class Admins(commands.Cog):
@group_give.command(name='packs')
async def give_packs_subcommand(
self, interaction: discord.Interaction, num_packs: int, pack_type: Literal['Standard', 'Premium', 'MVP'],
team_abbrevs: str):
self, interaction: discord.Interaction, team_abbrevs: str, num_packs: int, pack_type: Literal['Standard', 'Premium', 'MVP'], cardset_id: int = None):
if not owner_only(interaction):
await interaction.response.send_message(random_no_gif())
return
current = await db_get('current')
await interaction.response.defer()
p_query = await db_get('packtypes', params=[('name', pack_type)])
p_query = await db_get('packtypes', params=[('name', pack_type)])
if p_query['count'] == 0:
raise KeyError(f'Packtype not found')
this_packtype = p_query['packtypes'][0]
c_id = None
if cardset_id is not None:
cardset = await db_get('cardsets', object_id=cardset_id, none_okay=False)
c_id = cardset['id']
response = ''
for x in team_abbrevs.split(' '):
t_query = await db_get('teams', params=[('abbrev', x), ('season', current['season'])])
team = t_query['teams'][0]
if team:
total_packs = await give_packs(team, num_packs, pack_type=p_query['packtypes'][0])
response += f'Just gave {num_packs} {pack_type} pack{"s" if num_packs > 1 else ""} to the ' \
f'{team["sname"]}. They now have {total_packs["count"]} ' \
f'pack{"s" if total_packs["count"] > 1 else ""}.\n'
elif x.upper() == 'LEAGUE':
if x.upper() == 'LEAGUE':
all_teams = await db_get('teams', params=[('season', current['season'])])
total_teams = 0
for y in all_teams['teams']:
logging.warning(f'Giving {num_packs} pack(s) to team: {y["abbrev"]}')
await give_packs(team, num_packs)
response = f'Just gave all {all_teams["count"]} teams {num_packs} ' \
f'standard pack{"s" if num_packs > 1 else ""}!'
if not y['is_ai'] and 'gauntlet' not in y['abbrev'].lower():
logging.warning(f'Giving {num_packs} pack(s) to team: {y["abbrev"]}')
await db_post(
'packs',
payload={'packs': [{
'team_id': y['id'],
'pack_type_id': this_packtype['id'],
'pack_cardset_id': c_id
} for x in range(num_packs)]}
)
total_teams += 1
response = f'Just gave all {total_teams} teams {num_packs} ' \
f'{pack_type} pack{"s" if num_packs > 1 else ""}!'
else:
await interaction.edit_original_response(content=f'Hmm...I\'m not sure who **{x.upper()}** is.')
return
t_query = await db_get('teams', params=[('abbrev', x), ('season', current['season'])])
if t_query['count'] > 0:
team = t_query['teams'][0]
await db_post(
'packs',
payload={'packs': [{
'team_id': team['id'],
'pack_type_id': this_packtype['id'],
'pack_cardset_id': c_id
} for x in range(num_packs)]}
)
response += f'Just gave {num_packs} {pack_type} pack{"s" if num_packs > 1 else ""} to the {team["sname"]}.'
else:
await interaction.edit_original_response(content=f'Hmm...I\'m not sure who **{x.upper()}** is.')
return
logging.info(f'give info: {response}')
await interaction.edit_original_response(content=f'{response if len(response) > 0 else "All done!"}')

View File

@ -92,7 +92,7 @@ class Owner(commands.Cog):
#
# await ctx.send(f'Just ran the sync. Here is the output:\n{sync}')
@commands.command()
@commands.command(name='sync', help='~ current guild, * global -> current, ! clear and sync current')
@commands.is_owner()
async def sync(self, ctx: Context, guilds: Greedy[Object], spec: Optional[Literal['~', "*", '!']] = None) -> None:
"""
@ -109,9 +109,13 @@ class Owner(commands.Cog):
ctx.bot.tree.copy_global_to(guild=ctx.guild)
fmt = await ctx.bot.tree.sync(guild=ctx.guild)
elif spec == '!':
fmt = await ctx.bot.tree.sync()
await ctx.send(f'Synced {len(fmt)} commands globally.')
ctx.bot.tree.clear_commands(guild=ctx.guild)
await ctx.send(f'Cleared all local commands.')
fmt = await ctx.bot.tree.sync(guild=ctx.guild)
if len(fmt) > 0:
fmt = await ctx.bot.tree.sync(guild=ctx.guild)
await ctx.send(f'Synced global commands to this guild.')
else:
fmt = await ctx.bot.tree.sync()

View File

@ -186,6 +186,32 @@ async def get_opponent(this_team, this_event, this_run):
else:
raise KeyError(f'Hmm...I do not know who you should be playing right now.')
return await db_get('teams', object_id=t_id, none_okay=False)
elif this_event['id'] == 6:
if gp == 0:
t_id = 30
elif gp == 1:
t_id = 22
elif gp == 2:
t_id = 7
elif gp == 3:
t_id = 8
elif gp == 4:
t_id = 16
elif gp == 5:
t_id = 6
elif gp == 6:
t_id = 24
elif gp == 7:
t_id = 15
elif gp == 8:
t_id = 13
elif gp == 9:
t_id = 1
elif gp == 10:
t_id = 29
else:
raise KeyError(f'Hmm...I do not know who you should be playing right now.')
return await db_get('teams', object_id=t_id, none_okay=False)
else:
return None
@ -280,7 +306,7 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
if this_event['id'] == 1:
embed_title = f'{main_team["lname"]} - {this_event["name"]} Draft'
embed_description = f'{this_event["name"]}'
base_params = copy.deepcopy(ai_manager.MAJOR_CARDSET_PARAMS)
base_params = copy.deepcopy(ai_manager.GAUNTLET1_PARAMS)
base_params.extend([('limit', 8), ('cardset_id', 8)])
elif this_event['id'] == 2:
embed_title = f'{main_team["lname"]} - {this_event["name"]} Draft'
@ -301,6 +327,11 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
embed_description = f'{this_event["name"]}'
base_params = [('cardset_id', 17), ('cardset_id', 18), ('cardset_id', 19), ('cardset_id', 16),
('cardset_id', 8), ('limit', 8)]
elif this_event['id'] == 6:
embed_title = f'{main_team['lname']} - {this_event['name']} Draft'
embed_description = f'{this_event["name"]}'
base_params = [('cardset_id', 20), ('cardset_id', 21), ('cardset_id', 22), ('cardset_id', 16),
('cardset_id', 8), ('limit', 8)]
else:
logging.error(f'run_draft - Event ID {this_event["id"]} not recognized')
raise KeyError(f'Draft data not found for Gauntlet {this_event["id"]}')
@ -355,10 +386,10 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
}
if this_event['id'] in [1, 2]:
max_counts['MVP'] = 2
elif this_event['id'] == 5:
elif this_event['id'] in [5, 6]:
g_query = await db_get(
'games',
params=[('season', draft_team['season']), ('team1_id', draft_team['id']), ('gauntlet_id', 5)]
params=[('season', draft_team['season']), ('team1_id', draft_team['id']), ('gauntlet_id', this_event['id'])]
)
if g_query['count'] > 4:
game_count = g_query['count']
@ -520,7 +551,7 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
view=None
)
def get_embeds(include_links=True):
def get_embeds(include_links=True, round_num=1):
top_embed = helpers.get_team_embed(f'{embed_title} - Round {round_num}')
top_embed.description = f'Rarity Counts'
bot_embed = helpers.get_team_embed(f'{embed_title} - Round {round_num}')
@ -587,6 +618,163 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
logging.info(f'getting last message')
last_message = await interaction.channel.send(content=None, embeds=get_embeds(include_links=False))
async def draft_loop():
round_num = 1
counter = 0
while round_num <= 26 and counter < 50:
counter += 1
params = copy.deepcopy(base_params)
logging.info(f'gauntlets.py - run_draft - event_id {this_event["id"]} / round_num: {round_num} / counter: {counter} / counts: {counts} / max_counts: {max_counts}')
# Set rarity based on remaining counts
if counts['Hall of Fame'] < max_counts['Hall of Fame']:
params.extend([
('min_rarity', RARITY['HoF']), ('max_rarity', RARITY['HoF'])
])
elif counts['MVP'] < max_counts['MVP']:
params.extend([
('min_rarity', RARITY['MVP']), ('max_rarity', RARITY['MVP'])
])
elif counts['All-Star'] < max_counts['All-Star']:
params.extend([
('min_rarity', RARITY['All-Star']), ('max_rarity', RARITY['All-Star'])
])
elif counts['Starter'] < max_counts['Starter']:
params.extend([
('min_rarity', RARITY['Starter']), ('max_rarity', RARITY['Starter'])
])
elif counts['Reserve'] < max_counts['Reserve']:
params.extend([
('min_rarity', RARITY['Reserve']), ('max_rarity', RARITY['Reserve'])
])
else:
params.extend([
('min_rarity', RARITY['Replacement']), ('max_rarity', RARITY['Replacement'])
])
this_batch = []
for x in ['SP', 'RP', 'IF', 'OF']:
# Slot 1 - SP
if x == 'SP':
if counts['SP'] > 5:
slot_params = [('pos_exc', 'SP')]
if counts['RP'] > 7:
slot_params = [('pos_exc', 'RP')]
else:
slot_params = [('pos_inc', 'SP')]
# if counts['SP'] > 5:
# slot_params = [('pos_exc', 'SP')]
# elif counts['RP'] < 6:
# slot_params = [('pos_inc', 'RP')]
# else:
# slot_params = [('pos_exc', 'SP'), ('pos_exc', 'RP')]
# Slot 2 - RP
elif x == 'RP':
logging.info(f'counts[RP]: {counts["RP"]}')
if counts['RP'] > 7:
slot_params = [('pos_exc', 'RP')]
if counts['SP'] > 5:
slot_params = [('pos_exc', 'SP')]
else:
slot_params = [('pos_inc', 'RP')]
# Slot 3 - IF
elif x == 'IF':
slot_params = []
for y in ['1B', '2B', '3B', 'SS', 'C']:
if (counts[y] > 1) and 0 in [
counts['C'], counts['1B'], counts['2B'], counts['3B'], counts['SS']
]:
slot_params.append(('pos_exc', y))
elif (y == 'C' and counts['C'] < 3) or (y != 'C' and counts[y] < 4):
slot_params.append(('pos_inc', y))
# if counts['C'] < 2:
# slot_params.append(('pos_inc', 'C'))
# if len(slot_params) == 0:
# slot_params = [('pos_exc', 'C'), ('pos_exc', '1B'), ('pos_exc', '2B'), ('pos_exc', '3B'),
# ('pos_exc', 'SS')]
# Slot 4 - OF
else:
slot_params = []
for y in ['LF', 'CF', 'RF']:
if counts[y] > 4:
slot_params.append(('pos_exc', y))
elif counts[y] > 1 and 0 in [counts['LF'], counts['CF'], counts['RF']]:
slot_params.append(('pos_exc', y))
elif counts[y] < 5:
slot_params.append(('pos_inc', y))
# if len(slot_params) == 0:
# slot_params = [('pos_exc', 'LF'), ('pos_exc', 'CF'), ('pos_exc', 'RF')]
logging.info(f'this_batch: {this_batch}')
logging.info(f'slot_params: {slot_params}')
logging.info(f'params: {params}')
# No position explicitly requested or denied
if len(slot_params) == 0:
if (counts['SP'] + counts['RP']) > (
counts['C'] + counts['1B'] + counts['2B'] + counts['SS'] + counts['LF'] + counts['CF'] +
counts['RF']):
pos_counts = [
('C', counts['C']), ('1B', counts['1B']), ('2B', counts['2B']), ('3B', counts['3B']),
('SS', counts['SS']), ('LF', counts['LF']), ('CF', counts['CF']), ('RF', counts['RF'])
]
pos_counts.sort(key=lambda z: z[1])
slot_params = [('pos_inc', pos_counts[0][0])]
else:
if counts['SP'] >= counts['RP']:
slot_params = [('pos_inc', 'RP')]
else:
slot_params = [('pos_inc', 'SP')]
slot_params.extend(params)
p_query = await db_get('players/random', params=slot_params)
if p_query['count'] > 0:
# test_player_list = ''
# for z in p_query['players']:
# test_player_list += f'{z["rarity"]["name"]} - {z["description"]} - {helpers.get_all_pos(x)}\n'
# Collect 1 cards with no repeat player names
for i in p_query['players']:
if i['p_name'] not in p_names and i not in this_batch:
this_batch.append(i)
break
if len(this_batch) < 4:
logging.error(f'Pulled less than 4 players in gauntlet draft')
p_query = await db_get('players/random', params=params)
for i in p_query['players']:
if i['p_name'] not in p_names and i not in this_batch:
this_batch.append(i)
if len(this_batch) >= 4:
break
if len(this_batch) < 4:
raise KeyError(f'This is embarassing, but I couldn\'t find enough players for you to draft from.')
# Present choices and capture selection
p_choice = await helpers.get_choice_from_cards(interaction, this_batch, delete_message=True)
# Add player to list and update counts
p_names.append(p_choice['p_name'])
counts[p_choice['rarity']['name']] += 1
all_players.append(p_choice)
if p_choice['pos_1'] in ['SP', 'RP']:
counts[p_choice['pos_1']] += 1
else:
for x in helpers.get_all_pos(p_choice):
if x in counts:
counts[x] += 1
# Update roster embed
round_num += 1
await last_message.edit(content=None, embeds=get_embeds(include_links=False, round_num=round_num))
logging.info(f'going into draft')
backyard_round = None
custom_player_round = None
@ -1317,162 +1505,8 @@ async def run_draft(interaction: discord.Interaction, main_team, this_event, dra
# Update roster embed
round_num += 1
await last_message.edit(content=None, embeds=get_embeds(include_links=False))
elif this_event['id'] == 5:
while round_num <= 26 and counter < 50:
counter += 1
params = copy.deepcopy(base_params)
logging.info(f'gauntlets.py - run_draft - event_id 5 / round_num: {round_num} / counter: {counter} '
f'/ counts: {counts} / max_counts: {max_counts}')
# Set rarity based on remaining counts
if counts['Hall of Fame'] < max_counts['Hall of Fame']:
params.extend([
('min_rarity', RARITY['HoF']), ('max_rarity', RARITY['HoF'])
])
elif counts['MVP'] < max_counts['MVP']:
params.extend([
('min_rarity', RARITY['MVP']), ('max_rarity', RARITY['MVP'])
])
elif counts['All-Star'] < max_counts['All-Star']:
params.extend([
('min_rarity', RARITY['All-Star']), ('max_rarity', RARITY['All-Star'])
])
elif counts['Starter'] < max_counts['Starter']:
params.extend([
('min_rarity', RARITY['Starter']), ('max_rarity', RARITY['Starter'])
])
elif counts['Reserve'] < max_counts['Reserve']:
params.extend([
('min_rarity', RARITY['Reserve']), ('max_rarity', RARITY['Reserve'])
])
else:
params.extend([
('min_rarity', RARITY['Replacement']), ('max_rarity', RARITY['Replacement'])
])
this_batch = []
for x in ['SP', 'RP', 'IF', 'OF']:
# Slot 1 - SP
if x == 'SP':
if counts['SP'] > 5:
slot_params = [('pos_exc', 'SP')]
if counts['RP'] > 7:
slot_params = [('pos_exc', 'RP')]
else:
slot_params = [('pos_inc', 'SP')]
# if counts['SP'] > 5:
# slot_params = [('pos_exc', 'SP')]
# elif counts['RP'] < 6:
# slot_params = [('pos_inc', 'RP')]
# else:
# slot_params = [('pos_exc', 'SP'), ('pos_exc', 'RP')]
# Slot 2 - RP
elif x == 'RP':
logging.info(f'counts[RP]: {counts["RP"]}')
if counts['RP'] > 7:
slot_params = [('pos_exc', 'RP')]
if counts['SP'] > 5:
slot_params = [('pos_exc', 'SP')]
else:
slot_params = [('pos_inc', 'RP')]
# Slot 3 - IF
elif x == 'IF':
slot_params = []
for y in ['1B', '2B', '3B', 'SS', 'C']:
if (counts[y] > 1) and 0 in [
counts['C'], counts['1B'], counts['2B'], counts['3B'], counts['SS']
]:
slot_params.append(('pos_exc', y))
elif (y == 'C' and counts['C'] < 3) or (y != 'C' and counts[y] < 4):
slot_params.append(('pos_inc', y))
# if counts['C'] < 2:
# slot_params.append(('pos_inc', 'C'))
# if len(slot_params) == 0:
# slot_params = [('pos_exc', 'C'), ('pos_exc', '1B'), ('pos_exc', '2B'), ('pos_exc', '3B'),
# ('pos_exc', 'SS')]
# Slot 4 - OF
else:
slot_params = []
for y in ['LF', 'CF', 'RF']:
if counts[y] > 4:
slot_params.append(('pos_exc', y))
elif counts[y] > 1 and 0 in [counts['LF'], counts['CF'], counts['RF']]:
slot_params.append(('pos_exc', y))
elif counts[y] < 5:
slot_params.append(('pos_inc', y))
# if len(slot_params) == 0:
# slot_params = [('pos_exc', 'LF'), ('pos_exc', 'CF'), ('pos_exc', 'RF')]
logging.info(f'this_batch: {this_batch}')
logging.info(f'slot_params: {slot_params}')
logging.info(f'params: {params}')
# No position explicitly requested or denied
if len(slot_params) == 0:
if (counts['SP'] + counts['RP']) > (
counts['C'] + counts['1B'] + counts['2B'] + counts['SS'] + counts['LF'] + counts['CF'] +
counts['RF']):
pos_counts = [
('C', counts['C']), ('1B', counts['1B']), ('2B', counts['2B']), ('3B', counts['3B']),
('SS', counts['SS']), ('LF', counts['LF']), ('CF', counts['CF']), ('RF', counts['RF'])
]
pos_counts.sort(key=lambda z: z[1])
slot_params = [('pos_inc', pos_counts[0][0])]
else:
if counts['SP'] >= counts['RP']:
slot_params = [('pos_inc', 'RP')]
else:
slot_params = [('pos_inc', 'SP')]
slot_params.extend(params)
p_query = await db_get('players/random', params=slot_params)
if p_query['count'] > 0:
# test_player_list = ''
# for z in p_query['players']:
# test_player_list += f'{z["rarity"]["name"]} - {z["description"]} - {helpers.get_all_pos(x)}\n'
# Collect 1 cards with no repeat player names
for i in p_query['players']:
if i['p_name'] not in p_names and i not in this_batch:
this_batch.append(i)
break
if len(this_batch) < 4:
logging.error(f'Pulled less than 4 players in gauntlet draft')
p_query = await db_get('players/random', params=params)
for i in p_query['players']:
if i['p_name'] not in p_names and i not in this_batch:
this_batch.append(i)
if len(this_batch) >= 4:
break
if len(this_batch) < 4:
raise KeyError(f'This is embarassing, but I couldn\'t find enough players for you to draft from.')
# Present choices and capture selection
p_choice = await helpers.get_choice_from_cards(interaction, this_batch, delete_message=True)
# Add player to list and update counts
p_names.append(p_choice['p_name'])
counts[p_choice['rarity']['name']] += 1
all_players.append(p_choice)
if p_choice['pos_1'] in ['SP', 'RP']:
counts[p_choice['pos_1']] += 1
else:
for x in helpers.get_all_pos(p_choice):
if x in counts:
counts[x] += 1
# Update roster embed
round_num += 1
await last_message.edit(content=None, embeds=get_embeds(include_links=False))
elif this_event['id'] in [5, 6]:
await draft_loop()
else:
logging.error(f'run_draft - No draft logic for Event ID {this_event["id"]}')
raise KeyError(f'Draft data not found for Gauntlet {this_event["id"]}')
@ -1632,18 +1666,23 @@ async def post_result(run_id: int, is_win: bool, this_team, bot, channel):
await helpers.give_cards_to_team(
main_team, player_ids=[x['reward']['player']['player_id']], pack_id=this_pack['id'])
reward_string += f'- {helpers.player_desc(x["reward"]["player"])}\n'
elif x['reward']['pack_type'] and this_event['id'] in [3, 4, 5]:
elif x['reward']['pack_type'] and this_event['id'] in [3, 4, 5, 6]:
if this_event['id'] == 3:
cardset_id = 13
team_id = 58
elif this_event['id'] == 4:
cardset_id = 16
team_id = 79
else:
elif this_event['id'] == 5:
cardset_id = 17
team_id = None
if x['reward']['pack_type']['id'] == 9:
cardset_id = 18
else:
cardset_id = 20
team_id = None
if x['reward']['pack_type']['id'] == 9:
cardset_id = 21
await db_post(
'packs', payload={'packs': [{
'team_id': main_team['id'],

View File

@ -37,6 +37,7 @@ HELP_NEWGAME = (
f'- Run `/new-game` and select a game mode:\n'
f'** **- gauntlet: Draft a team and attempt to go 10-0 against the AI teams\n'
f'** **- mlb-campaign: Progress from Minors -> Majors -> Hall of Fame by defeating all 30 MLB teams\n'
f'** **- exhibition: Play against the AI and choose the cardsets it uses to build a team\n'
f'** **- ranked/unlimited: Play against another human player\n'
f'- Set starting lineups with `/read-lineup` for each team\n\n'
f'From here, the game scorebug will be posted and you are ready to start rolling dice!'
@ -49,7 +50,7 @@ HELP_PLAYGAME = (
f'nested commands (e.g. `/log flyball b`)\n'
f'- When you mess up a result, run `/log undo-play` and it will roll back one play\n'
f'- Run `/gamestate` to see the scorebug with both lineups\n'
f'- Run `/substitution` to make lineup changes (for you and the AI in single player)\n'
f'- Run `/substitution` to make lineup changes\n'
f'- Run `/show-card` to see upcoming batters or the current defenders'
)

View File

@ -20,10 +20,10 @@ from typing import Optional, Literal
from in_game.gameplay_models import Team
SBA_SEASON = 9
PD_SEASON = 7
LIVE_CARDSET_ID = 17
LIVE_PROMO_CARDSET_ID = 18
SBA_SEASON = 10
PD_SEASON = 8
LIVE_CARDSET_ID = 20
LIVE_PROMO_CARDSET_ID = 21
SBA_COLOR = 'a6ce39'
PD_PLAYERS = 'Paper Dynasty Players'
SBA_PLAYERS_ROLE_NAME = f'Season {SBA_SEASON} Players'
@ -227,6 +227,8 @@ RARITY = {
'Replacement': 0
}
SELECT_CARDSET_OPTIONS = [
discord.SelectOption(label='1998 Live', value='20'),
discord.SelectOption(label='1998 Promos', value='21'),
discord.SelectOption(label='2024 Season', value='17'),
discord.SelectOption(label='2024 Promos', value='18'),
discord.SelectOption(label='2023 Season', value='9'),
@ -241,6 +243,7 @@ SELECT_CARDSET_OPTIONS = [
discord.SelectOption(label='2013 Season', value='6'),
discord.SelectOption(label='2012 Season', value='7')
]
ACTIVE_EVENT_LITERAL = Literal['1998 Season']
class Question:
@ -634,7 +637,10 @@ class SelectOpenPack(discord.ui.Select):
cardset_id = None
if 'Team Choice' in pack_vals and 'Cardset' in pack_vals:
cardset_id = pack_vals[2]
# cardset_id = pack_vals[2]
cardset_index = pack_vals.index('Cardset')
cardset_id = pack_vals[cardset_index + 1]
params.append(('pack_cardset_id', cardset_id))
if 'Team' not in pack_vals:
view = SelectView(
[SelectChoicePackTeam('AL', self.owner_team, cardset_id),
@ -646,11 +652,14 @@ class SelectOpenPack(discord.ui.Select):
view=view
)
return
elif 'Team' in pack_vals:
params.append(('pack_team_id', pack_vals[2]))
elif 'Cardset' in pack_vals:
params.append(('pack_cardset_id', pack_vals[2]))
cardset_id = pack_vals[2]
params.append(('pack_team_id', pack_vals[pack_vals.index('Team') + 1]))
else:
if 'Team' in pack_vals:
params.append(('pack_team_id', pack_vals[pack_vals.index('Team') + 1]))
if 'Cardset' in pack_vals:
cardset_id = pack_vals[pack_vals.index('Cardset') + 1]
params.append(('pack_cardset_id', cardset_id))
p_query = await db_get('packs', params=params)
if p_query['count'] == 0:
@ -667,6 +676,7 @@ class SelectOpenPack(discord.ui.Select):
class SelectPaperdexCardset(discord.ui.Select):
def __init__(self):
options = [
discord.SelectOption(label='1998 Live'),
discord.SelectOption(label='2024 Season'),
discord.SelectOption(label='2023 Season'),
discord.SelectOption(label='2022 Season'),
@ -711,6 +721,8 @@ class SelectPaperdexCardset(discord.ui.Select):
cardset_id = 17
elif self.values[0] == '2024 Promos':
cardset_id = 18
elif self.values[0] == '1998 Live':
cardset_id = 20
c_query = await db_get('cardsets', object_id=cardset_id, none_okay=False)
await interaction.response.edit_message(content=f'Okay, sifting through your cards...', view=None)
@ -838,6 +850,7 @@ class SelectPaperdexTeam(discord.ui.Select):
class SelectBuyPacksCardset(discord.ui.Select):
def __init__(self, team: dict, quantity: int, pack_type_id: int, pack_embed: discord.Embed, cost: int):
options = [
discord.SelectOption(label='1998 Live'),
discord.SelectOption(label='2024 Season'),
discord.SelectOption(label='2023 Season'),
discord.SelectOption(label='2022 Season'),
@ -879,6 +892,8 @@ class SelectBuyPacksCardset(discord.ui.Select):
cardset_id = 13
elif self.values[0] == '2024 Season':
cardset_id = 17
elif self.values[0] == '1998 Live':
cardset_id = 20
self.pack_embed.description = f'{self.pack_embed.description} - {self.values[0]}'
view = Confirm(responders=[interaction.user], timeout=30)
@ -2218,12 +2233,14 @@ async def roll_for_cards(all_packs: list, extra_val=None) -> list:
if counts[key]['count'] > 0:
params = [
('min_rarity', counts[key]['rarity']), ('max_rarity', counts[key]['rarity']),
('limit', counts[key]['count']), ('in_packs', True)
('limit', counts[key]['count'])
]
if all_packs[0]['pack_team'] is not None:
params.append(('franchise', all_packs[0]['pack_team']['lname']))
params.extend([('franchise', all_packs[0]['pack_team']['lname']), ('in_packs', True)])
elif all_packs[0]['pack_cardset'] is not None:
params.append(('cardset_id', all_packs[0]['pack_cardset']['id']))
else:
params.append(('in_packs', True))
pl = await db_get('players/random', params=params)

View File

@ -25,20 +25,11 @@ db = SqliteDatabase(
}
)
# 2024, Mario
MINOR_CARDSET_PARAMS = [('cardset_id', 17), ('cardset_id', 8)]
# 2018, 2024, Mario,
MAJOR_CARDSET_PARAMS = [
GAUNTLET1_PARAMS = [
('cardset_id', 13), ('cardset_id', 14), ('cardset_id', 17), ('cardset_id', 18), ('cardset_id', 8)
]
# 2008, 2012, 2013, 2016, 2019, 2021, 2022, 2023, Mario
HOF_CARDSET_PARAMS = [
('cardset_id', 1), ('cardset_id', 3), ('cardset_id', 4), ('cardset_id', 5), ('cardset_id', 6), ('cardset_id', 7),
('cardset_id', 8), ('cardset_id', 9), ('cardset_id', 10), ('cardset_id', 11), ('cardset_id', 12), ('cardset_id', 13)
]
# 2008, 2012, 2013, 2016
GAUNTLET2_PARAMS = [
('cardset_id', 8), ('cardset_id', 12), ('cardset_id', 6), ('cardset_id', 7), ('cardset_id', 11)