From 6d5e9081e6cfca3b1b11db00738296fea96688e3 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Fri, 3 Apr 2020 23:34:35 -0400 Subject: [PATCH] Euchre::Dealer: Add smarter stand/sit logic You can now swap seats without standing up first :) This also prevents someone sitting in two places, which is nice --- lib/Euchre/Dealer.pm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/Euchre/Dealer.pm b/lib/Euchre/Dealer.pm index 9d35924..7470407 100644 --- a/lib/Euchre/Dealer.pm +++ b/lib/Euchre/Dealer.pm @@ -162,7 +162,8 @@ sub take_seat { if (defined $game->{players}->[$seat]) { send_error($p, 'Seat is taken'); } else { - # Move from standing to sitting + # Move from standing (or sitting) to sitting + stand_up($p) if defined $p->{seat}; $game->{players}->[$seat] = $p; $p->{seat} = $seat; for (my $i = 0; $i < @{$game->{spectators}}; $i++) { @@ -185,6 +186,7 @@ sub stand_up { } else { # Move from sitting to standing push @{$game->{spectators}}, $p; + delete $p->{seat}; $game->{players}->[$seat] = undef; broadcast_gamestate($game); } -- libgit2 1.1.1