euchre-live

Euchre web-app for the socially distant family
git clone git://git.alexkarle.com/euchre-live.git
Log | Files | Refs | README | LICENSE

commit 1003ff9a3c3db67c83f20a427572018b5046b21b (patch)
parent 1a453145330647ef67a95bea03f13f022dc8a0c5
Author: Alex Karle <alex@karle.co>
Date:   Sat, 25 Apr 2020 21:00:10 -0400

Euchre::Dealer: Add restart_game action for end game

At the end of the game, players should be able to decide if they want to
play again or if they want to leave. Restart game just resets the score
and throws you back into the 'lobby' phase (for seat picking, etc)

start_game will then work from there, dealing new hands and all that.

Diffstat:
Mlib/Euchre/Dealer.pm | 12++++++++++--
1 file changed, 10 insertions(+), 2 deletions(-)

diff --git a/lib/Euchre/Dealer.pm b/lib/Euchre/Dealer.pm @@ -136,6 +136,7 @@ sub handle_msg { take_seat => [\&take_seat, 'lobby', "Can't change seats during game"], stand_up => [\&stand_up, 'lobby', "Can't change seats during game"], start_game => [\&start_game, 'lobby', "Game already started"], + restart_game => [\&restart_game, 'end', "Game hasn't ended"], # Gameplay order => [\&order, 'vote', "Not time for a vote", 1], @@ -294,11 +295,18 @@ sub start_game { return; } - # TODO: kick spectators out? - # TODO: deal! start_new_round($game); } +sub restart_game { + my ($p) = @_; + my $game = $p->{game}; + + $game->{score} = $ENV{END_DEBUG} ? [9,9] : [0,0]; + $game->{phase} = 'lobby'; + broadcast_gamestate($game); +} + sub num_players { my ($gid) = @_; return scalar grep { defined } @{$GAMES{$gid}->{players}}