commit 0435ad10d57629088963e1a548c9770f645d86bb (patch) parent e1b95898018238eaf9a3bcec8fcdf1e2bff06c23 Author: Alex Karle <alex@karle.co> Date: Sat, 28 Mar 2020 15:25:00 -0400 Dealer: Broadcast readable human names for players As opposed to the unique object identifier. Diffstat:
M | lib/Euchre/Dealer.pm | | | 8 | +++++++- |
1 file changed, 7 insertions(+), 1 deletion(-)
diff --git a/lib/Euchre/Dealer.pm b/lib/Euchre/Dealer.pm @@ -147,7 +147,13 @@ sub broadcast_gamestate { # Get all players in the game my @all_ws = map { $PLAYERS{$_}->{ws} } @{$game->{players}}; - my $json = encode_json({ msg_type => 'game_state', game => $game }); + my @names = map { $PLAYERS{$_}->{name} } @{$game->{players}}; + my $msg = { + %$game, + players => \@names, + }; + + my $json = encode_json({ msg_type => 'game_state', game => $msg }); for my $ws (@all_ws) { $ws->send({ json => $json}); }