Add legality check to Major League games
This commit is contained in:
parent
fcc10c27f0
commit
869c5ff6bf
@ -329,22 +329,16 @@ class Admins(commands.Cog):
|
||||
@commands.command(name='tc', help='Mod: Test command')
|
||||
@commands.is_owner()
|
||||
async def test_choices_command(self, ctx):
|
||||
await ctx.send(f'Posting packs now...')
|
||||
|
||||
db_post('packs/one', payload={
|
||||
'team_id': 31,
|
||||
'pack_type_id': 8
|
||||
})
|
||||
db_post('packs/one', payload={
|
||||
'team_id': 31,
|
||||
'pack_type_id': 3
|
||||
})
|
||||
db_post('packs/one', payload={
|
||||
'team_id': 31,
|
||||
'pack_type_id': 3,
|
||||
'pack_team_id': 3
|
||||
})
|
||||
await ctx.send(f'Posted the team choice pack')
|
||||
await ctx.send(f'Checking legality now...')
|
||||
lc = db_post(
|
||||
'cards/legal-check/ranked?card_id=13222&card_id=8375&card_id=15789&card_id=15787&card_id=11449'
|
||||
'&card_id=10073&card_id=2878',
|
||||
payload={
|
||||
'team_id': 31,
|
||||
'pack_type_id': 8
|
||||
}
|
||||
)
|
||||
await ctx.send(f'{lc}')
|
||||
|
||||
|
||||
async def setup(bot):
|
||||
|
||||
@ -1974,6 +1974,7 @@ class Gameplay(commands.Cog):
|
||||
|
||||
all_lineups = []
|
||||
all_pos = []
|
||||
card_ids = []
|
||||
for index, row in enumerate(lineup_cells):
|
||||
if '' in row:
|
||||
break
|
||||
@ -1990,6 +1991,7 @@ class Gameplay(commands.Cog):
|
||||
f'{this_card["team"]["sname"]}. Try again with only cards you own.')
|
||||
player_id = this_card['player']['player_id']
|
||||
card_id = row[1]
|
||||
card_ids.append(str(card_id))
|
||||
|
||||
this_lineup = {
|
||||
'game_id': this_game.id,
|
||||
@ -2035,6 +2037,7 @@ class Gameplay(commands.Cog):
|
||||
return
|
||||
|
||||
else:
|
||||
card_ids.append(str(sp_card_id))
|
||||
all_lineups.append({
|
||||
'game_id': this_game.id,
|
||||
'team_id': lineup_team['id'],
|
||||
@ -2046,6 +2049,19 @@ class Gameplay(commands.Cog):
|
||||
})
|
||||
all_pos.append('P')
|
||||
|
||||
# Check roster legality
|
||||
if this_game.game_type in ['major-league', 'hall-of-fame']:
|
||||
l_string = "&card_id=".join(card_ids)
|
||||
legality = db_post(f'cards/legal-check/ranked?card_id={l_string}')
|
||||
if legality['count'] > 0:
|
||||
il_string = "\n- ".join(legality['bad_cards'])
|
||||
await interaction.edit_original_response(
|
||||
content=f'It looks like this is a Ranked Legal game and I see the following cards as illegal. '
|
||||
f'Please adjust your lineup and re-submit!\n\n'
|
||||
f'- {il_string}'
|
||||
)
|
||||
return
|
||||
|
||||
logging.debug(f'Setting lineup for {lineup_team["sname"]} in PD game')
|
||||
post_lineups(all_lineups)
|
||||
|
||||
@ -2145,6 +2161,16 @@ class Gameplay(commands.Cog):
|
||||
await ctx.send(f'I could not find {new_player.title()}.')
|
||||
return
|
||||
|
||||
legality = db_post(f'cards/legal-check/ranked?card_id={new_player}')
|
||||
if legality['count'] > 0:
|
||||
il_string = "\n- ".join(legality['bad_cards'])
|
||||
await ctx.send(
|
||||
content=f'It looks like this is a Ranked Legal game and I see the following cards as illegal. '
|
||||
f'Please adjust your lineup and re-submit!\n\n'
|
||||
f'- {il_string}'
|
||||
)
|
||||
return
|
||||
|
||||
this_play = get_current_play(this_game.id)
|
||||
batting_order = int(order_number) if order_number != 'this-spot' else this_play.batting_order
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user