From 1f0af442eceba8f385689fc495a2751f39c0ad85 Mon Sep 17 00:00:00 2001 From: Alex Karle Date: Sun, 29 Mar 2020 23:56:39 -0400 Subject: [PATCH] Euchre::Game: Update score_round API to take caller ID When I first envisioned this, I thought the game state would hold the id of the calling team. ~ckarle mentioned that it would be likely easier to just store the seat number that called it. This commit makes that update / updates the test for coverage. --- lib/Euchre/Dealer.pm | 2 +- lib/Euchre/Game.pm | 5 +++-- t/Game.t | 4 ++-- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/Euchre/Dealer.pm b/lib/Euchre/Dealer.pm index ccc745f..eb794af 100644 --- a/lib/Euchre/Dealer.pm +++ b/lib/Euchre/Dealer.pm @@ -33,7 +33,7 @@ our @EXPORT = qw( # dealer => 0-3, # turn => 0-3, # trump => 0-3, -# callers => 0-3, # player XXX +# caller => 0-3, # table => [ c1, c2, c3, c4 ], # up to 4 cards # score => [X, Y], # } diff --git a/lib/Euchre/Game.pm b/lib/Euchre/Game.pm index ba143ca..7c5cd80 100644 --- a/lib/Euchre/Game.pm +++ b/lib/Euchre/Game.pm @@ -75,11 +75,12 @@ sub trick_winner { } # Given # tricks per player, who won? What score? -# Use X to indicate sat-out. $callers either 0 or 1 +# Use X to indicate sat-out. $caller is a seat_no # Returns idx of team, points to give sub score_round { - my ($callers, @tricks) = @_; + my ($caller, @tricks) = @_; + my $callers = $caller % 2; my $setters = 1 - $callers; my $loner = 0; my @totals; diff --git a/t/Game.t b/t/Game.t index 78da3ec..3243822 100644 --- a/t/Game.t +++ b/t/Game.t @@ -50,10 +50,10 @@ sub test_score_round { my @tests = ( [[0, 1,2,1,1], [1, 2], 'Euched!'], [[1, 2,1,1,1], [0, 2], 'Euched again!'], - [[1, 2,3,0,0], [1,1], 'Made your point'], + [[3, 2,3,0,0], [1,1], 'Made your point'], [[1, 0,3,0,2], [1,2], 'Got em all!'], [[0, 5,0,'X',0], [0,4], 'Loneeeer!'], - [[0, 3,1,'X',1], [0,1], 'Failed loner'], + [[2, 3,1,'X',1], [0,1], 'Failed loner'], ); for my $t (@tests) { -- libgit2 1.1.1