Removed add player guess to resolve
This commit is contained in:
parent
20cfcdcd4f
commit
e9154711c0
@ -12,42 +12,20 @@ from game.process_guess import ProcessGuess
|
||||
|
||||
|
||||
class EndGameManager(BaseGameManager):
|
||||
"""Commands that run at the end of a game"""
|
||||
"""Commands that run at the end of a play"""
|
||||
|
||||
def __init__(self):
|
||||
super().__init__()
|
||||
self.commands.append(("resolve", self.stop))
|
||||
|
||||
def __stop_args__(self):
|
||||
pieces = self.message.content.split()
|
||||
|
||||
if len(pieces) == 2:
|
||||
return pieces[1], False, None, None
|
||||
|
||||
if len(pieces) == 4:
|
||||
return pieces[1], True, pieces[2], pieces[3]
|
||||
|
||||
return None, False, None, None
|
||||
|
||||
async def update_pitch_value(self):
|
||||
"""Update game state database for closing arguments"""
|
||||
# Determine arguments
|
||||
pitch_value, has_batter, batter_id, batter_guess = self.__stop_args__()
|
||||
pitch_value = self.message.content.split()[1]
|
||||
if not pitch_value:
|
||||
return await self.message.channel.send(
|
||||
f"Invalid command <@{ str(self.message.author.id) }>!"
|
||||
)
|
||||
|
||||
if has_batter:
|
||||
player_id = batter_id[3:]
|
||||
player_name = await self.discord.get_user(int(player_id).name)
|
||||
Guess.create(
|
||||
game_id=self.game.game_id,
|
||||
player_id=player_id,
|
||||
player_name=player_name,
|
||||
guess=int(batter_guess),
|
||||
).save()
|
||||
|
||||
# Save the pitch value
|
||||
Game.update(
|
||||
{
|
||||
@ -76,7 +54,7 @@ class EndGameManager(BaseGameManager):
|
||||
)
|
||||
|
||||
# Discard the game if there weren't enough players
|
||||
if guess_count < 3:
|
||||
if guess_count < 2:
|
||||
self.game = None
|
||||
self.is_running = False
|
||||
return await self.message.channel.send(
|
||||
@ -85,7 +63,7 @@ class EndGameManager(BaseGameManager):
|
||||
|
||||
message = (
|
||||
"Closed this play! Here are the results\n"
|
||||
+ "PLAYER | GUESS | DIFFERENCE | POINTS GAINED | TOTAL POINTS\n"
|
||||
+ "__PLAYER | GUESS | DIFFERENCE | POINTS GAINED | TOTAL POINTS__\n"
|
||||
)
|
||||
|
||||
pitch_value = await self.update_pitch_value()
|
||||
|
Loading…
Reference in New Issue
Block a user