| 1 | package Games::Solitaire::Verify::State::LaxParser; | ||||||||||
| 2 | 7 | $Games::Solitaire::Verify::State::LaxParser::VERSION = '0.2601'; | |||||||||
| 3 | 7 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 7 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | |||||||||||
| 7 | 7 | ▶ | use parent 'Games::Solitaire::Verify::State'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | sub _from_string | ||||||||||
| 10 | 6 | ▶ | { | ||||||||
|
Subroutine
_from_string: called CC=6 SCAR=17.9
| |||||||||||
| 11 | 6 | my ( $self, $str ) = @_; | |||||||||
| 12 | |||||||||||
| 13 | 6 | my $rank_re = '[0A1-9TJQK]'; | |||||||||
| 14 | |||||||||||
| 15 | 6 | my $founds_s; | |||||||||
| 16 | 6 | ▶ | if ( $str =~ m{\A(Foundations:[^\n]*)\n}cgms ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 17 | { | ||||||||||
| 18 | 3 | $founds_s = $1; | |||||||||
| 19 | } | ||||||||||
| 20 | else | ||||||||||
| 21 | { | ||||||||||
| 22 | 3 | $founds_s = "Foundations: H-0 C-0 D-0 S-0"; | |||||||||
| 23 | } | ||||||||||
| 24 | |||||||||||
| 25 | 6 | $self->set_foundations( | |||||||||
| 26 | Games::Solitaire::Verify::Foundations->new( | ||||||||||
| 27 | { | ||||||||||
| 28 | num_decks => $self->num_decks(), | ||||||||||
| 29 | string => $founds_s, | ||||||||||
| 30 | } | ||||||||||
| 31 | ) | ||||||||||
| 32 | ); | ||||||||||
| 33 | |||||||||||
| 34 | 6 | my $fc = 'Freecells:'; | |||||||||
| 35 | 6 | ▶ | if ( $str =~ m{\G(Freecells:[^\n]*)\n}cgms ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 36 | { | ||||||||||
| 37 | 3 | $fc = $1; | |||||||||
| 38 | } | ||||||||||
| 39 | 6 | $self->_assign_freecells_from_string($fc); | |||||||||
| 40 | |||||||||||
| 41 | 6 | foreach my $col_idx ( 0 .. ( $self->num_columns() - 1 ) ) | |||||||||
| 42 | { | ||||||||||
| 43 | 48 | ▶ | if ( $str !~ m{\G([^\n]*)\n}msg ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 44 | { | ||||||||||
| 45 | 0 | Games::Solitaire::Verify::Exception::Parse::State::Column->throw( | |||||||||
| 46 | error => "Cannot parse column", | ||||||||||
| 47 | index => $col_idx, | ||||||||||
| 48 | ); | ||||||||||
| 49 | } | ||||||||||
| 50 | 48 | my $column_str = $1; | |||||||||
| 51 | 48 | ▶ | if ( $column_str !~ /\A:/ ) | ||||||||
|
Branch: 1 branch
| |||||||||||
| 52 | { | ||||||||||
| 53 | 24 | $column_str =~ s/\A\s*/: /; | |||||||||
| 54 | } | ||||||||||
| 55 | |||||||||||
| 56 | $self->add_column( | ||||||||||
| 57 | 48 | Games::Solitaire::Verify::Column->new( | |||||||||
| 58 | { | ||||||||||
| 59 | string => $column_str, | ||||||||||
| 60 | } | ||||||||||
| 61 | ) | ||||||||||
| 62 | ); | ||||||||||
| 63 | } | ||||||||||
| 64 | |||||||||||
| 65 | 6 | return; | |||||||||
| 66 | } | ||||||||||
| 67 | |||||||||||
| 68 | 7 | 1; # End of Games::Solitaire::Verify::State | |||||||||
| 69 | |||||||||||
| 70 | __END__ | ||||||||||