Update gameplay.py

Remove old catcher question; skip out type when no hit + no error
This commit is contained in:
Cal Corum 2023-05-03 14:58:47 -05:00
parent 4b59919d57
commit d3ba2f0e96

View File

@ -3162,40 +3162,6 @@ class Gameplay(commands.Cog):
hit_allowed, error_allowed, chaos_allowed = None, None, None
if position.value == 'C':
view = Confirm([interaction.user], label_type='yes')
question = await interaction.channel.send(f'Did {defender["name"]} give up a chaos result?', view=view)
await view.wait()
if view.value:
await question.delete()
view = ButtonOptions(responders=[interaction.user], labels=['WP', 'X (PB)', None, None, None])
question = await interaction.channel.send(
f'Which chaos result did {defender["name"]} allow?', view=view
)
await view.wait()
if view.value == 'WP' or view.value == 'X (PB)':
await question.delete()
if view.value == 'WP':
advance_runners(this_play.id, 1)
patch_play(this_play.id, rbi=0, wp=1)
elif view.value == 'X (PB)':
advance_runners(this_play.id, 1)
patch_play(this_play.id, rbi=0, pb=1)
complete_play(this_play.id)
await interaction.edit_original_response(
content=None, embed=await self.get_game_state_embed(this_game, full_length=False)
)
return
else:
await question.delete()
else:
await question.delete()
view = Confirm([interaction.user], label_type='yes')
question = await interaction.channel.send(f'Did {defender["name"]} give up a hit?', view=view)
await view.wait()
@ -3247,73 +3213,78 @@ class Gameplay(commands.Cog):
# Not hit and no error
if hit_allowed == 'out' and error_allowed == 'no error':
if position.value not in ['LF', 'CF', 'RF']:
view = ButtonOptions(
responders=[interaction.user],
labels=['gb A', 'gb B', 'gb C', None if position.value != 'C' else 'FO',
None if position.value != 'C' else '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.delete()
if view.value == 'gb A':
await self.groundballs(interaction, this_game, this_play, groundball_type='a')
elif view.value == 'gb B':
await self.groundballs(interaction, this_game, this_play, groundball_type='b')
elif view.value == 'gb C':
await self.groundballs(interaction, this_game, this_play, groundball_type='c')
else:
patch_play(this_play.id, pa=1, ab=1, outs=1)
advance_runners(this_play.id, 0)
complete_play(this_play.id)
patch_play(this_play.id, locked=False)
return
else:
await question.delete()
if view.value in ['FO', 'PO']:
patch_play(this_play.id, pa=1, ab=1, outs=1)
advance_runners(this_play.id, 0)
complete_play(this_play.id)
else:
if view.value == 'gb A':
gb_code = 'a'
elif view.value == 'gb B':
gb_code = 'b'
else:
gb_code = 'c'
await self.groundballs(interaction, this_game, this_play, gb_code)
if this_play.on_base_code == 0:
patch_play(this_play.id, pa=1, ab=1, outs=1)
advance_runners(this_play.id, 0)
complete_play(this_play.id)
else:
view = ButtonOptions(responders=[interaction.user], labels=['fly A', 'fly B', 'fly C', None, None])
question = await interaction.channel.send(f'What was the result of the play?', view=view)
await view.wait()
if not view.value:
await question.delete()
await interaction.channel.send(
content=f'Just logged the x-check! Please log the resulting play to continue (e.g. '
f'\'flyball-b\' or \'flyball-c\')'
if position.value not in ['LF', 'CF', 'RF']:
view = ButtonOptions(
responders=[interaction.user],
labels=['gb A', 'gb B', 'gb C', None if position.value != 'C' else 'FO',
None if position.value != 'C' else 'PO']
)
patch_play(this_play.id, locked=False)
return
question = await interaction.channel.send(f'What was the result of the play?', view=view)
await view.wait()
if not view.value:
await question.delete()
if view.value == 'gb A':
await self.groundballs(interaction, this_game, this_play, groundball_type='a')
elif view.value == 'gb B':
await self.groundballs(interaction, this_game, this_play, groundball_type='b')
elif view.value == 'gb C':
await self.groundballs(interaction, this_game, this_play, groundball_type='c')
else:
patch_play(this_play.id, pa=1, ab=1, outs=1)
advance_runners(this_play.id, 0)
complete_play(this_play.id)
patch_play(this_play.id, locked=False)
return
else:
await question.delete()
if view.value in ['FO', 'PO']:
patch_play(this_play.id, pa=1, ab=1, outs=1)
advance_runners(this_play.id, 0)
complete_play(this_play.id)
else:
if view.value == 'gb A':
gb_code = 'a'
elif view.value == 'gb B':
gb_code = 'b'
else:
gb_code = 'c'
await self.groundballs(interaction, this_game, this_play, gb_code)
else:
await question.delete()
if view.value == 'fly A':
fly_code = 'a'
elif view.value == 'fly B':
fly_code = 'b'
else:
fly_code = 'c'
view = ButtonOptions(responders=[interaction.user], labels=['fly A', 'fly B', 'fly C', None, None])
question = await interaction.channel.send(f'What was the result of the play?', view=view)
await view.wait()
await self.flyballs(interaction, this_game, this_play, fly_code)
if not view.value:
await question.delete()
await interaction.channel.send(
content=f'Just logged the x-check! Please log the resulting play to continue (e.g. '
f'\'flyball-b\' or \'flyball-c\')'
)
patch_play(this_play.id, locked=False)
return
else:
await question.delete()
if view.value == 'fly A':
fly_code = 'a'
elif view.value == 'fly B':
fly_code = 'b'
else:
fly_code = 'c'
await self.flyballs(interaction, this_game, this_play, fly_code)
# Hit and error
elif hit_allowed != 'out' and error_allowed != 'no error':