blib/lib/Games/Solitaire/Verify/Move.pm

filter: Statementstmt 100% 50 / 50 Branchbran 92.8% 13 / 14 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 6 / 6 Podpod n/a totaltotal 98.5% 69 / 70 CC 8 SCAR 14.8
CC
8
Cov
98%
_from_fcs_string
7.0
_init
2.0
BEGIN
1.0
CRAP 4.4
« blib/lib/Games/Solitaire/Verify/App/CmdLine/From_Patsolve.pm ↑ Summary blib/lib/Games/Solitaire/Verify/State/LaxParser.pm »
1 package Games::Solitaire::Verify::Move;
2 17 $Games::Solitaire::Verify::Move::VERSION = '0.2301';
3 17 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 17 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6  
7 17 ▶use parent 'Games::Solitaire::Verify::Base';
Subroutine BEGIN: called CC=1 SCAR=0.0
8  
9 17 ▶use Games::Solitaire::Verify::Exception ();
Subroutine BEGIN: called CC=1 SCAR=0.0
10  
11 17 __PACKAGE__->mk_acc_ref(
12 [
13 qw(
14 source_type
15 dest_type
16 source
17 dest
18 num_cards
19 _game
20 )
21 ]
22 );
23  
24  
25 sub _from_fcs_string
26 {
27 2382 ▶ my ( $self, $str ) = @_;
Subroutine _from_fcs_string: called CC=7 SCAR=19.5
28  
29 2382 ▶ if ( $str =~ m{\AMove a card from stack (\d+) to the foundations\z} )
Branch: 6 branches
BranchTrueFalseTotal
if ($str =~ /\AMove a card from stack (\d+) to the foundations\z/) { } 572 1810 2382
elsif ($str =~ /\AMove a card from freecell (\d+) to the foundations\z/) { } 99 1711 1810
elsif ($str =~ /\AMove a card from freecell (\d+) to stack (\d+)\z/) { } 470 1241 1711
elsif ($str =~ /\AMove a card from stack (\d+) to freecell (\d+)\z/) { } 569 672 1241
elsif ($str =~ /\AMove (\d+) cards from stack (\d+) to stack (\d+)\z/) { } 664 8 672
elsif ($str =~ /\AMove the sequence on top of Stack (\d+) to the foundations\z/) { } 7 1 8
30 {
31 572 my $source = $1;
32  
33 572 $self->source_type("stack");
34 572 $self->dest_type("foundation");
35  
36 572 $self->source($source);
37 }
38 elsif ( $str =~ m{\AMove a card from freecell (\d+) to the foundations\z} )
39 {
40 99 my $source = $1;
41  
42 99 $self->source_type("freecell");
43 99 $self->dest_type("foundation");
44  
45 99 $self->source($source);
46 }
47 elsif ( $str =~ m{\AMove a card from freecell (\d+) to stack (\d+)\z} )
48 {
49 470 my ( $source, $dest ) = ( $1, $2 );
50  
51 470 $self->source_type("freecell");
52 470 $self->dest_type("stack");
53  
54 470 $self->source($source);
55 470 $self->dest($dest);
56 }
57 elsif ( $str =~ m{\AMove a card from stack (\d+) to freecell (\d+)\z} )
58 {
59 569 my ( $source, $dest ) = ( $1, $2 );
60  
61 569 $self->source_type("stack");
62 569 $self->dest_type("freecell");
63  
64 569 $self->source($source);
65 569 $self->dest($dest);
66 }
67 elsif ( $str =~ m{\AMove (\d+) cards from stack (\d+) to stack (\d+)\z} )
68 {
69 664 my ( $num_cards, $source, $dest ) = ( $1, $2, $3 );
70  
71 664 $self->source_type("stack");
72 664 $self->dest_type("stack");
73  
74 664 $self->source($source);
75 664 $self->dest($dest);
76 664 $self->num_cards($num_cards);
77 }
78 elsif ( $str =~
79 m{\AMove the sequence on top of Stack (\d+) to the foundations\z} )
80 {
81 7 my $source = $1;
82  
83 7 $self->source_type("stack_seq");
84 7 $self->dest_type("foundation");
85  
86 7 $self->source($source);
87 }
88 else
89 {
90 1 Games::Solitaire::Verify::Exception::Parse::FCS->throw(
91 error => "Cannot parse 'FCS' String", );
92 }
93 }
94  
95 sub _init
96 {
97 2382 ▶ my ( $self, $args ) = @_;
Subroutine _init: called CC=2 SCAR=7.0
98  
99 2382 $self->_game( $args->{game} );
100  
101 2382 ▶ if ( exists( $args->{fcs_string} ) )
Branch: 1 branch
BranchTrueFalseTotal
if (exists $args->{"fcs_string"}) 2382 0 2382
102 {
103 2382 return $self->_from_fcs_string( $args->{fcs_string} );
104 }
105 }
106  
107  
108 17 1; # End of Games::Solitaire::Verify::Move
109  
110 __END__
« blib/lib/Games/Solitaire/Verify/App/CmdLine/From_Patsolve.pm ↑ Summary blib/lib/Games/Solitaire/Verify/State/LaxParser.pm »