blib/lib/Game/Schnapsen/Error.pm

filter: Statementstmt 94.1% 16 / 17 Branchbran n/a Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 80.0% 4 / 5 Podpod 100% 2 / 2 totaltotal 79.3% 23 / 29 CC 2 SCAR 4.6
CC
2
Cov
85%
new_code
2.3
codes
2.0
BEGIN
1.0
CRAP 1.6
« blib/lib/Game/Schnapsen/Variant.pm ↑ Summary bin/schnapsen »
1 package Game::Schnapsen::Error;
2  
3 25 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 25 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 25 ▶use Object::Proto::Sugar -types;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 25 our $VERSION = '0.04';
9  
10 25 my %MESSAGE = (
11 bad_variant => 'that is not a game this engine plays',
12 no_seed => 'a deal needs a seed',
13 bad_deal => 'a deal number counts from one',
14 deal_over => 'the deal is over',
15 game_over => 'the match is over',
16 not_your_turn => 'it is not your turn',
17 not_legal => 'the rules do not offer that',
18 not_held => 'that card is not in your hand',
19 must_follow => 'you must follow suit, and beat the card led if you can',
20 must_lead => 'you must lead one of the two cards you married',
21 no_marriage => 'you do not hold that marriage',
22 no_exchange => 'you cannot exchange for the trump card now',
23 cannot_close => 'the talon cannot be closed now',
24 cannot_claim => 'you may only claim just after taking a trick or declaring a marriage',
25 );
26  
27 25 has code => (is => 'ro', isa => Str);
28 25 has message => (is => 'ro', isa => Str);
29  
30 41 ▶sub new_code {
Subroutine new_code: called CC=2 SCAR=8.1
Pod documented
31 41 my ($class, $code) = @_;
32 return $class->new(
33 code => $code,
34 41 ▶ message => $MESSAGE{$code} // $code,
Condition33%1/3
$MESSAGE{$code} // $code
l!l&&r!l&&!r
4100
MC/DC0%0/2
$MESSAGE{$code} // $code
$MESSAGE{$code} $code
Truth table33%1/3
A // B
A= $MESSAGE{$code}B= $code
ABresult
1X1
011
000
35 );
36 }
37  
38 0 ▶sub codes { return sort keys %MESSAGE }
Subroutine codes: not called CC=1 SCAR=6.9
Pod documented
39  
40 25 1;
41  
42 __END__
« blib/lib/Game/Schnapsen/Variant.pm ↑ Summary bin/schnapsen »