blib/lib/Games/RolePlay/MapGen/MapQueue/Object.pm

filter: Statementstmt 98.1% 54 / 55 Branchbran 85.0% 17 / 20 Conditioncond 33.3% 1 / 3 MC/DCmcdc 0.0% 0 / 2 Subroutinesub 92.8% 13 / 14 Podpod 0.0% 0 / 11 totaltotal 80.9% 85 / 105 CC 12 SCAR 8.1
CC
12
Cov
92%
set_item_number
3.3
attr
3.0
desc
3.0
CRAP 2.2
« blib/lib/Games/RolePlay/MapGen/Generator/Blank.pm ↑ Summary blib/lib/Games/RolePlay/MapGen/Editor/_jQuery.pm »
1 # vi:filetype=perl:
2  
3 package Games::RolePlay::MapGen::MapQueue::Object;
4  
5 1 ▶use common::sense;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 0 ▶use overload fallback => 1, bool => sub{1}, '0+' => \&n, '""' => \&q, "-=" => \&me, "+=" => \&pe;
Subroutine BEGIN: called CC=1 SCAR=0.2
Subroutine __ANON__: not called CC=1 SCAR=0.2
7  
8 5 ▶sub new { my $class = shift; my $val = shift; bless {q=>1, u=>1, v=>$val}, $class }
Subroutine new: called CC=1 SCAR=0.0
Pod undocumented
9  
10 4 ▶sub desc {
Subroutine desc: called CC=3 SCAR=11.0
Pod undocumented
11 4 my $this = shift;
12  
13 4 my $r = $this->{v};
14 4 ▶ $r .= " ($this->{q})" if $this->{q} != 1;
Branch: 1 branch
BranchTrueFalseTotal
if $this->{"q"} != 1 3 1 4
15 4 ▶ $r .= " #$this->{c}" unless $this->{u};
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{"u"} 2 2 4
16  
17 4 return $r;
18 }
19  
20 4 ▶sub attr {
Subroutine attr: called CC=3 SCAR=11.0
Pod undocumented
21 4 my $this = shift;
22 4 my $name = shift;
23 4 my $that = shift;
24  
25 4 ▶ return undef unless $name;
Branch: 1 branch
BranchTrueFalseTotal
unless $name 0 4 4
26  
27 4 ▶ $this->{a}{$name} = $that if defined $that;
Branch: 1 branch
BranchTrueFalseTotal
if defined $that 2 2 4
28 4 $this->{a}{$name};
29 }
30  
31 8 ▶sub q {
Subroutine q: called CC=2 SCAR=6.9
Pod undocumented
32 8 my $this = shift;
33  
34 8 ▶ return lc("$this->{v} #$this->{c}") unless $this->{u};
Branch: 1 branch
BranchTrueFalseTotal
unless $this->{"u"} 5 3 8
35 3 return lc($this->{v});
36 }
37  
38 6 ▶sub n {
Subroutine n: called CC=1 SCAR=0.0
Pod undocumented
39 6 my $this = shift;
40  
41 6 return $this->{q};
42 }
43  
44 1 ▶sub pe {
Subroutine pe: called CC=1 SCAR=0.0
Pod undocumented
45 1 my $this = shift;
46 1 my $that = shift;
47  
48 1 $this->{q} += $that;
49 1 $this;
50 }
51  
52 1 ▶sub me {
Subroutine me: called CC=2 SCAR=7.0
Pod undocumented
53 1 my $this = shift;
54 1 my $that = shift;
55 1 my $ordr = shift;
56  
57 1 ▶ return ($this->{q} = ($that - $this->{q})) if $ordr;
Branch: 1 branch
BranchTrueFalseTotal
if $ordr 0 1 1
58 1 $this->{q} -= $that;
59 1 $this;
60 }
61  
62 1 my %item_counts;
63 2 ▶sub quantity { my $this = shift; my $q = shift; $this->{q}=$q if defined $q; $this->{q} }
Subroutine quantity: called CC=2 SCAR=6.9
Pod undocumented
Branch: 1 branch
BranchTrueFalseTotal
if defined $q 1 1 2
64 1 ▶sub unique { my $this = shift; $this->{u}=1; }
Subroutine unique: called CC=1 SCAR=0.0
Pod undocumented
65 5 ▶sub nonunique { my $this = shift; $this->{u}=0; my $num = shift;
Subroutine nonunique: called CC=3 SCAR=11.0
Pod undocumented
66 5 ▶ if( defined $num ) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $num) { } 1 4 5
67 1 $this->set_item_number($num);
68  
69 } else {
70 4 ▶ unless( exists $this->{c} ) {
Branch: 1 branch
BranchTrueFalseTotal
unless (exists $this->{"c"}) 3 1 4
71 3 $this->{c} = ++ $item_counts{$this->{v}};
72 }
73 }
74 }
75 2 ▶sub set_item_number {
Subroutine set_item_number: called CC=3 SCAR=12.0
Pod undocumented
76 2 my $this = shift;
77 2 my $num = 0+shift;
78  
79 2 ▶ $item_counts{$this->{v}} = $num if not exists $item_counts{$this->{v}} or $num > $item_counts{$this->{v}};
Branch: 1 branch
BranchTrueFalseTotal
if not exists $item_counts{$this->{"v"}} or $num > $item_counts{$this->{"v"}} 2 0 2
Condition33%1/3
not exists $item_counts{$this->{"v"}} or $num > $item_counts{$this->{"v"}}
l!l&&r!l&&!r
020
MC/DC0%0/2
not exists $item_counts{$this->{"v"}} or $num > $item_counts{$this->{"v"}}
not exists $item_counts{$this->{"v"}} $num > $item_counts{$this->{"v"}}
Truth table33%1/3
not(A) or B
A= not exists $item_counts{$this->{"v"}}B= $num > $item_counts{$this->{"v"}}
ABresult
1X1
011
000
80 2 $this->{c} = $num;
81 }
82  
83 1 "I like GD::Graph.";
84  
85  
86 __END__
« blib/lib/Games/RolePlay/MapGen/Generator/Blank.pm ↑ Summary blib/lib/Games/RolePlay/MapGen/Editor/_jQuery.pm »