commit 6225ecd2f409bd7fc26c664917aab0cea714e8a6 (patch)
parent 8a53c2c2c394da68effb73fbd3f5306acdeb85c1
Author: Alex Karle <alex@karle.co>
Date: Wed, 29 Apr 2020 23:47:45 -0400
Euchre::Dealer: Convert all players to spectators at end
When the game is over, we move all players to the spectator role. If
they want to play another game, they can pick their seats again. If they
want to exit, that's cool too. The important thing is that we don't want
any grandpa's walking away from a screen with an open tab preventing
someone who WAS spectating from taking that seat :)
Diffstat:
1 file changed, 8 insertions(+), 2 deletions(-)
diff --git a/lib/Euchre/Dealer.pm b/lib/Euchre/Dealer.pm
@@ -585,9 +585,15 @@ sub play_card {
sub signal_game_end {
my ($game) = @_;
- # TODO: send message with winners and end the game
- # (maybe put game no longer in progress?)
$game->{phase} = 'end';
+
+ # Put all players into spectator roles. This is crucial so that one player
+ # doesn't walk away and hold up a seat (assuming others want to play again)
+ for my $p (grep { defined } @{$game->{players}}) {
+ delete $p->{seat};
+ push @{$game->{spectators}}, $p;
+ }
+ $game->{players} = [undef, undef, undef, undef];
}