blib/lib/Acme/Mahjong/Rule/CC.pm

filter: Statementstmt 70.4% 43 / 61 Branchbran 25.0% 3 / 12 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 87.5% 7 / 8 Podpod 100% 4 / 4 totaltotal 60.6% 57 / 94 CC 11 SCAR 34.9
CC
11
Cov
58%
mahjong_table
72.0
nondealer
2.0
dealer
2.0
CRAP 32.9
↑ Summary
1 package Acme::Mahjong::Rule::CC;
2  
3 1 ▶use 5.008008;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5 1 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 1 ▶use Carp;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 1 require Exporter;
9  
10 1 our @ISA = qw(Exporter);
11  
12 # Items to export into callers namespace by default. Note: do not export
13 # names by default without a very good reason. Use EXPORT_OK instead.
14 # Do not simply export all your public functions/methods/constants.
15  
16 # This allows declaration use Acme::Mahjong::Rule::CC ':all';
17 # If you do not need this, moving things directly into @EXPORT or @EXPORT_OK
18 # will save memory.
19 1 our %EXPORT_TAGS = (
20 'all' => [ qw(
21 mahjong_table
22 dealer
23 nondealer
24 draw
25 ) ],
26 'tables' =>[qw(
27 dealer
28 nondealer
29 draw
30 )] );
31  
32 1 our @EXPORT_OK = ( @{ $EXPORT_TAGS{'all'} } );
33  
34 1 our @EXPORT = qw(
35
36 );
37  
38 1 our $VERSION = '0.22';
39  
40  
41 0 ▶sub mahjong_table{
Subroutine mahjong_table: not called CC=8 SCAR=42.8
Pod documented
42 0 my $ans = 7;
43 0 ▶ while($ans!=0 && $ans!=1 && $ans!=2){
Branch: 1 branch
BranchTrueFalseTotal
if ($ans != 0 and $ans != 1 and $ans != 2) 0 0 0
Condition0%0/6
$ans != 0 and $ans != 1 and $ans != 2
!ll&&!rl&&r
000
$ans != 0 and $ans != 1
!ll&&!rl&&r
000
MC/DC0%0/3
$ans != 0 and $ans != 1 and $ans != 2
$ans != 0 $ans != 1 $ans != 2
Truth table0%0/4
A and B and C
A= $ans != 0B= $ans != 1C= $ans != 2
ABCresult
0XX0
10X0
1100
1111
44 0 print("0.Nondealer , 1.Dealer, or 2.Draw : ");
45 0 $ans=<STDIN>;
46 }
47 0 my @subs = (\&nondealer, \&dealer, \&draw);
48 0 my @players = (qw/dealer player2 player3 player4/);
49 0 ▶ $players[0]='winner' if ($ans != 2);
Branch: 1 branch
BranchTrueFalseTotal
if $ans != 2 0 0 0
50 0 ▶ $players[1]='dealer' if ($ans == 0);
Branch: 1 branch
BranchTrueFalseTotal
if $ans == 0 0 0 0
51 0 my @points;
52 0 foreach $a(@players){
53 0 print("$a : ");
54 0 my $pts =<STDIN>;
55 0 push @points,$pts;
56 }
57 0 print "===========================\n";
58 0 foreach (&{$subs[$ans]}(@points)){
59 0 my $p = shift @players;
60 0 print "$p : $_\n";
61 }
62 }
63 1 ▶sub nondealer{
Subroutine nondealer: called CC=2 SCAR=7.0
Pod documented
64 1 ▶ croak "Wrong number of arguments, needs 4.\n" unless (@_==4);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 4 0 1 1
65 1 my @score;
66 1 my($w, $deal, $l2 , $l3)=@_;
67 1 $score[0]=$w*4;
68 1 $score[1]=4*$deal-(2*$w+2*$l2+2*$l3);
69 1 $score[2]=3*$l2-($w+2*$deal+$l3);
70 1 $score[3]=3*$l3-($w+2*$deal+$l2);
71 1 @score;
72 }
73 1 ▶sub dealer{
Subroutine dealer: called CC=2 SCAR=7.0
Pod documented
74 1 ▶ croak "Wrong number of arguments, needs 4.\n" unless (@_==4);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 4 0 1 1
75 1 my @score;
76 1 my($w, $l2 ,$l3 ,$l4)=@_;
77 1 $score[0]=$w*6;
78 1 $score[1]=2*$l2-($w*2+$l3+$l4);
79 1 $score[2]=2*$l3-($w*2+$l2+$l4);
80 1 $score[3]=2*$l4-($w*2+$l3+$l2);
81 1 @score;
82 }
83 1 ▶sub draw{
Subroutine draw: called CC=2 SCAR=7.0
Pod documented
84 1 ▶ croak "Wrong number of arguments, needs 4.\n" unless (@_==4);
Branch: 1 branch
BranchTrueFalseTotal
unless @_ == 4 0 1 1
85 1 my @score;
86 1 my($l1, $l2 ,$l3 ,$l4)=@_;
87 1 $score[0]=$l1*6-2*($l2+$l3+$l4);
88 1 $score[1]=$l2*4-($l1*2+$l3+$l4);
89 1 $score[2]=$l3*4-($l1*2+$l2+$l4);
90 1 $score[3]=$l4*4-($l1*2+$l3+$l2);
91 1 @score;
92 }
93  
94 1 1;
95 __END__
↑ Summary