Add support for xcheck reswing

This commit is contained in:
Cal Corum 2023-05-02 16:09:57 -05:00
parent a2608fd479
commit 0e56e1992e
3 changed files with 44 additions and 35 deletions

View File

@ -330,38 +330,9 @@ 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'Updating rarities now...')
RAR_IDS = {
'HoF': 99,
'MVP': 1,
'All-Star': 2,
'Starter': 3,
'Reserve': 4,
'Replacement': 5
}
with open('storage/player-json-2023-05-02-553165.csv') as csvfile:
csv_reader = csv.reader(csvfile, delimiter=',')
line_count = 0
update_ids = []
update_names = []
for row in csv_reader:
if line_count == 0:
pass
else:
p_query = db_get('players', params=[('name', row[1]), ('cardset_id', 9)])
if p_query['count'] > 0:
player = p_query['players'][0]
r_name = row[9] if row[9] != 'HoF' else 'Hall of Fame'
if player['rarity']['name'] != r_name:
update_ids.append(player['player_id'])
update_names.append(player['p_name'])
db_patch('players', object_id=player['player_id'], params=[('rarity_id', RAR_IDS[row[9]])])
line_count += 1
try:
await ctx.send(f'Updated {len(update_names)} player rarities:\n\n{", ".join(update_names)}')
except Exception as e:
await ctx.send(f'Updated {len(update_ids)} player rarities:\n\n{", ".join(update_ids)}')
await ctx.send(f'Wiping AI dexes...')
db_post('paperdex/wipe-ai', timeout=15)
await ctx.send(f'All done!')
async def setup(bot):

View File

@ -337,8 +337,18 @@ class Gameplay(commands.Cog):
logging.debug(f'game_state: {game_state}')
gt_string = ' - Unlimited'
if game.game_type == 'minor-league':
gt_string = ' - Minor League'
elif game.game_type == 'major-league':
gt_string = ' - Major League'
elif game.game_type == 'hall-of-fame':
gt_string = ' - Hall of Fame'
elif 'gauntlet' in game.game_type:
gt_string = ' - Gauntlet'
embed = discord.Embed(
title=f'{game_state["away_team"]["sname"]} @ {game_state["home_team"]["sname"]}',
title=f'{game_state["away_team"]["sname"]} @ {game_state["home_team"]["sname"]}{gt_string}',
color=int(SBA_COLOR, 16)
)
@ -3338,6 +3348,28 @@ class Gameplay(commands.Cog):
elif hit_allowed == 'triple':
triple(this_play)
else:
if position.value == 'C':
view = ButtonOptions(
responders=[interaction.user],
labels=['gb A', 'gb B', 'gb C', 'FO', 'PO']
)
question = await interaction.channel.send(f'What was the result of the play?', view=view)
await view.wait()
if not view.value:
await question.edit(
content=f'Hmm...you keep thinking on it and get back to me when you\'re ready.',
view=None
)
return
elif view.value == 'FO':
await question.edit(content=f'**The ball dropped foul; batter swings again.**', view=None)
patch_play(this_play.id, defender_id=False, check_pos='false')
await interaction.channel.send(
content=None, embed=await self.get_game_state_embed(this_game, full_length=False)
)
return
patch_play(this_play.id, error=1)
if error_allowed == '1 base':
num_bases = 1

View File

@ -1019,9 +1019,15 @@ def patch_play(
if balk is not None:
this_play.balk = balk
if defender_id is not None:
this_play.defender_id = defender_id
if not defender_id:
this_play.defender_id = None
else:
this_play.defender_id = defender_id
if check_pos is not None:
this_play.check_pos = check_pos
if check_pos.lower() == 'false':
this_play.check_pos = None
else:
this_play.check_pos = check_pos
if error is not None:
this_play.error = error
if play_num is not None: