blib/lib/Games/ABC_Path/Generator/FinalLayoutObj.pm

filter: Statementstmt 100% 45 / 45 Branchbran 75.0% 3 / 4 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 14 / 14 Podpod 100% 5 / 5 totaltotal 98.5% 67 / 68 CC 3 SCAR 2.2
CC
3
Cov
98%
__ANON__
2.0
_s
2.0
as_string
1.0
CRAP 1.3
« blib/script/abc-path-gen--multi.pl ↑ Summary bin/abc-path-gen »
1 package Games::ABC_Path::Generator::FinalLayoutObj;
2 9 $Games::ABC_Path::Generator::FinalLayoutObj::VERSION = '0.6.0';
3 9 ▶use 5.006;
Subroutine BEGIN: called CC=1 SCAR=0.0
4  
5 9 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
6 9 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 9 ▶use integer;
Subroutine BEGIN: called CC=1 SCAR=0.0
9  
10 9 ▶use parent 'Games::ABC_Path::Generator::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
11  
12 9 ▶use Games::ABC_Path::Solver::Constants;
Subroutine BEGIN: called CC=1 SCAR=0.0
13  
14  
15 sub _s
16 {
17 109 ▶ my $self = shift;
Subroutine _s: called CC=2 SCAR=6.9
18  
19 109 ▶ if (@_)
Branch: 1 branch
BranchTrueFalseTotal
if (@_) 4 105 109
20 {
21 4 $self->{_s} = shift;
22 }
23  
24 109 return $self->{_s};
25 }
26  
27 sub _init
28 {
29 4 ▶ my $self = shift;
Subroutine _init: called CC=1 SCAR=0.0
30 4 my $args = shift;
31  
32 4 $self->_s( $args->{layout_string} );
33  
34 4 return;
35 }
36  
37  
38 sub get_A_pos
39 {
40 5 ▶ my ($self) = @_;
Subroutine get_A_pos: called CC=1 SCAR=0.0
Pod documented
41  
42 5 return index( $self->_s, chr(1) );
43 }
44  
45  
46 sub get_A_xy
47 {
48 1 ▶ my ($self) = @_;
Subroutine get_A_xy: called CC=1 SCAR=0.0
Pod documented
49  
50 1 my ( $y, $x ) = $self->_to_xy( $self->get_A_pos() );
51  
52 1 return { y => $y, x => $x, };
53 }
54  
55  
56 sub get_cell_contents
57 {
58 100 ▶ my ( $self, $index ) = @_;
Subroutine get_cell_contents: called CC=1 SCAR=0.0
Pod documented
59  
60 100 return vec( $self->_s, $index, 8 );
61 }
62  
63  
64 sub get_letter_at_pos
65 {
66 3 ▶ my ( $self, $pos ) = @_;
Subroutine get_letter_at_pos: called CC=1 SCAR=0.0
Pod documented
67  
68 return $letters[
69 $self->get_cell_contents(
70 3 $self->_xy_to_int( [ $pos->{'y'}, $pos->{'x'} ], )
71 ) - 1,
72 ];
73 }
74  
75  
76 sub as_string
77 {
78 1 ▶ my ( $l, $args ) = @_;
Subroutine as_string: called CC=1 SCAR=0.0
Pod documented
79  
80 my $render_row = sub {
81 5 ▶ my $y = shift;
Subroutine __ANON__: called CC=2 SCAR=7.0
82  
83 return join(
84 " | ",
85 map {
86 5 my $x = $_;
87 25 my $v = $l->get_cell_contents( $l->_xy_to_int( [ $y, $x ] ) );
88 25 ▶ $v ? $letters[ $v - 1 ] : '*'
Branch: 1 branch
BranchTrueFalseTotal
$v ? : 25 0 25
89 } ( 0 .. $LEN - 1 )
90 );
91 1 };
92  
93 1 return join( '', map { $render_row->($_) . "\n" } ( 0 .. $LEN - 1 ) );
94 }
95  
96  
97 9 1; # End of Games::ABC_Path::Generator
98  
99 __END__
« blib/script/abc-path-gen--multi.pl ↑ Summary bin/abc-path-gen »