From f6b2520b5105f2613ccf3ffccc608c4e37776a88 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Sun, 31 May 2020 23:24:57 -0400 Subject: [PATCH] Euchre::Host/Dealer: Add 'settings' object to Dealer This can be provided at table creation time and will be passed to the players as part of the broadcast gamestate. It will be on the client to obey the settings, for now, so the server will just accept whatever hash-ref the client gives. --- lib/Euchre/Dealer.pm | 2 ++ lib/Euchre/Host.pm | 2 ++ 2 files changed, 4 insertions(+) diff --git a/lib/Euchre/Dealer.pm b/lib/Euchre/Dealer.pm index e89d0ac..e7e17c2 100644 --- a/lib/Euchre/Dealer.pm +++ b/lib/Euchre/Dealer.pm @@ -13,6 +13,7 @@ use Class::Tiny qw(id), { password => '', game => sub { Euchre::Game->new() }, players => sub { {} }, + settings => sub { {} }, start_time => sub { time }, }; @@ -220,6 +221,7 @@ sub broadcast_gamestate { game => $msg, is_spectator => $p->is_spectator ? 1 : 0, table_id => $self->id, + settings => $self->settings, }; if (!$p->is_spectator) { diff --git a/lib/Euchre/Host.pm b/lib/Euchre/Host.pm index e80c4ab..d6b5f46 100644 --- a/lib/Euchre/Host.pm +++ b/lib/Euchre/Host.pm @@ -117,6 +117,7 @@ sub pong { # player_name # table # password (opt) +# settings (hash-ref, opt) sub join_table { my ($p, $msg) = @_; @@ -139,6 +140,7 @@ sub join_table { if (!exists $DEALERS{$tid}) { $DEALERS{$tid} = Euchre::Dealer->new( id => $tid, + (exists $msg->{settings} ? (settings => $msg->{settings}) : ()), (exists $msg->{password} ? (password => $msg->{password}) : ()), ); $TOTAL_TABLES++; -- libgit2 1.1.1