Add support for Promo Choice pack
This commit is contained in:
parent
fdfcd05899
commit
731862e006
@ -705,6 +705,8 @@ class Economy(commands.Cog):
|
||||
p_group = f'All Star-Cardset-{pack["pack_cardset"]["id"]}-{pack["pack_cardset"]["name"]}'
|
||||
elif pack['pack_type']['name'] == 'MVP':
|
||||
p_group = f'MVP-Cardset-{pack["pack_cardset"]["id"]}-{pack["pack_cardset"]["name"]}'
|
||||
elif pack['pack_type']['name'] == 'Promo Choice':
|
||||
p_group = f'Promo Choice-Cardset-{pack["pack_cardset"]["id"]}-{pack["pack_cardset"]["name"]}'
|
||||
|
||||
logging.info(f'p_group: {p_group}')
|
||||
if p_group is not None:
|
||||
@ -956,8 +958,12 @@ class Economy(commands.Cog):
|
||||
@app_commands.command(name='selldupes', description='Sell all of your duplicate cards')
|
||||
@app_commands.checks.has_any_role(PD_PLAYERS)
|
||||
@commands.check(legal_channel)
|
||||
@app_commands.describe(immediately='Skip all prompts and sell dupes immediately; default False')
|
||||
async def sell_dupes_command(self, interaction: discord.Interaction, immediately: bool = False):
|
||||
@app_commands.describe(
|
||||
immediately='Skip all prompts and sell dupes immediately; default False',
|
||||
skip_live='Skip all live series cards; default True'
|
||||
)
|
||||
async def sell_dupes_command(
|
||||
self, interaction: discord.Interaction, skip_live: bool = True, immediately: bool = False):
|
||||
team = await get_team_by_owner(interaction.user.id)
|
||||
if not team:
|
||||
await interaction.response.send_message(
|
||||
@ -988,7 +994,9 @@ class Economy(commands.Cog):
|
||||
if len(dupe_strings[str_count]) > 1500:
|
||||
str_count += 1
|
||||
logging.debug(f'card: {card}')
|
||||
if card['player']['player_id'] not in player_ids:
|
||||
if skip_live and (card['player']['cardset']['id'] == LIVE_CARDSET_ID):
|
||||
logging.debug(f'live series card - skipping')
|
||||
elif card['player']['player_id'] not in player_ids:
|
||||
logging.debug(f'not a dupe')
|
||||
player_ids.append(card['player']['player_id'])
|
||||
else:
|
||||
|
||||
38
helpers.py
38
helpers.py
@ -19,6 +19,7 @@ from typing import Optional, Literal
|
||||
|
||||
SBA_SEASON = 9
|
||||
PD_SEASON = 7
|
||||
LIVE_CARDSET_ID = 17
|
||||
SBA_COLOR = 'a6ce39'
|
||||
PD_PLAYERS = 'Paper Dynasty Players'
|
||||
SBA_PLAYERS_ROLE_NAME = f'Season {SBA_SEASON} Players'
|
||||
@ -591,6 +592,9 @@ class SelectOpenPack(discord.ui.Select):
|
||||
params.append(('pack_type_id', 3))
|
||||
elif 'Daily' in pack_vals:
|
||||
params.append(('pack_type_id', 4))
|
||||
elif 'Promo Choice' in pack_vals:
|
||||
open_type = 'choice'
|
||||
params.append(('pack_type_id', 9))
|
||||
elif 'MVP' in pack_vals:
|
||||
open_type = 'choice'
|
||||
params.append(('pack_type_id', 5))
|
||||
@ -2992,9 +2996,37 @@ async def open_choice_pack(this_pack, team: dict, context, cardset_id: Optional[
|
||||
params=params
|
||||
)
|
||||
if pl['count'] >= 0:
|
||||
players.extend(pl['players'])
|
||||
for x in pl['players']:
|
||||
if x not in players:
|
||||
players.append(x)
|
||||
if len(players) < 4:
|
||||
rarity_id += 3
|
||||
min_rarity += 1
|
||||
rarity_id += 1
|
||||
elif pack_type == 'Promo Choice':
|
||||
if this_pack['pack_cardset'] is None:
|
||||
raise KeyError(f'Cardset not listed for Promo Choice pack')
|
||||
|
||||
d1000 = random.randint(1, 1000)
|
||||
pack_cover = IMAGES['mvp-hype']
|
||||
cardset_id = this_pack['pack_cardset']['id']
|
||||
rarity_id = 5
|
||||
if d1000 > 800:
|
||||
rarity_id = 8
|
||||
|
||||
while len(players) < 4 and rarity_id < 10:
|
||||
pl = await db_get(
|
||||
'players/random',
|
||||
params=[('cardset_id', cardset_id), ('min_rarity', rarity_id), ('max_rarity', rarity_id),
|
||||
('limit', 8)]
|
||||
)
|
||||
if pl['count'] >= 0:
|
||||
for x in pl['players']:
|
||||
if len(players) >= 4:
|
||||
break
|
||||
if x not in players:
|
||||
players.append(x)
|
||||
if len(players) < 4:
|
||||
cardset_id = 17
|
||||
else:
|
||||
# Get 4 MVP cards
|
||||
rarity_id = 5
|
||||
@ -3026,6 +3058,8 @@ async def open_choice_pack(this_pack, team: dict, context, cardset_id: Optional[
|
||||
else:
|
||||
author = context.user
|
||||
|
||||
logging.info(f'helpers - open_choice_pack - players: {players}')
|
||||
|
||||
# Display them with pagination, prev/next/select
|
||||
card_embeds = [
|
||||
await get_card_embeds(
|
||||
|
||||
Loading…
Reference in New Issue
Block a user