| 1 | package Games::Solitaire::Verify::Solution::Base; | ||||||||||
| 2 | 14 | $Games::Solitaire::Verify::Solution::Base::VERSION = '0.2601'; | |||||||||
| 3 | 14 | ▶ | use strict; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 4 | 14 | ▶ | use warnings; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 5 | |||||||||||
| 6 | |||||||||||
| 7 | 14 | ▶ | use parent 'Games::Solitaire::Verify::Base'; | ||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||
| 8 | |||||||||||
| 9 | # "_ln" is line number | ||||||||||
| 10 | # "_st" is the "state" (or board/layout). | ||||||||||
| 11 | # "_i" is input filehandle. | ||||||||||
| 12 | # "_V" is short for variant arguments. | ||||||||||
| 13 | 14 | __PACKAGE__->mk_acc_ref( | |||||||||
| 14 | [ | ||||||||||
| 15 | qw( | ||||||||||
| 16 | _V | ||||||||||
| 17 | _i | ||||||||||
| 18 | _ln | ||||||||||
| 19 | _variant | ||||||||||
| 20 | _variant_params | ||||||||||
| 21 | _st | ||||||||||
| 22 | _max_rank | ||||||||||
| 23 | _move | ||||||||||
| 24 | _reached_end | ||||||||||
| 25 | ) | ||||||||||
| 26 | ] | ||||||||||
| 27 | ); | ||||||||||
| 28 | |||||||||||
| 29 | # _l is short for _get_line() | ||||||||||
| 30 | sub _l | ||||||||||
| 31 | 28800 | ▶ | { | ||||||||
|
Subroutine
_l: called CC=1 SCAR=0.0
| |||||||||||
| 32 | 28800 | my $s = shift; | |||||||||
| 33 | |||||||||||
| 34 | # We use this instead of the accessor for speed. | ||||||||||
| 35 | 28800 | ++$s->{_ln}; | |||||||||
| 36 | |||||||||||
| 37 | 28800 | return shift( @{ $s->{_i} } ); | |||||||||
| 38 | } | ||||||||||
| 39 | |||||||||||
| 40 | sub _calc_variant_args | ||||||||||
| 41 | 18 | ▶ | { | ||||||||
|
Subroutine
_calc_variant_args: called CC=2 SCAR=6.9
| |||||||||||
| 42 | 18 | my $self = shift; | |||||||||
| 43 | |||||||||||
| 44 | return [ | ||||||||||
| 45 | 18 | ▶ | variant => $self->_variant(), | ||||||||
|
Branch: 1 branch
| |||||||||||
| 46 | ( | ||||||||||
| 47 | ( $self->_variant eq 'custom' ) | ||||||||||
| 48 | ? ( 'variant_params' => $self->_variant_params() ) | ||||||||||
| 49 | : () | ||||||||||
| 50 | ) | ||||||||||
| 51 | ]; | ||||||||||
| 52 | } | ||||||||||
| 53 | |||||||||||
| 54 | sub _init | ||||||||||
| 55 | 18 | ▶ | { | ||||||||
|
Subroutine
_init: called CC=3 SCAR=11.0
| |||||||||||
| 56 | 18 | my ( $self, $args ) = @_; | |||||||||
| 57 | |||||||||||
| 58 | 18 | ▶ | $self->_max_rank( exists( $args->{max_rank} ) ? $args->{max_rank} : 13 ); | ||||||||
|
Branch: 1 branch
| |||||||||||
| 59 | $self->_i( | ||||||||||
| 60 | [ | ||||||||||
| 61 | split /^/ms, | ||||||||||
| 62 | do | ||||||||||
| 63 | 18 | { | |||||||||
| 64 | 18 | local $/; | |||||||||
| 65 | 18 | my $t = readline( $args->{input_fh} ); | |||||||||
| 66 | 18 | $t =~ s/ +$//gms; | |||||||||
| 67 | 18 | $t; | |||||||||
| 68 | } | ||||||||||
| 69 | ] | ||||||||||
| 70 | ); | ||||||||||
| 71 | 18 | $self->_ln(0); | |||||||||
| 72 | |||||||||||
| 73 | 18 | $self->_variant( $args->{variant} ); | |||||||||
| 74 | |||||||||||
| 75 | $self->_variant_params( | ||||||||||
| 76 | $self->_variant eq 'custom' | ||||||||||
| 77 | ? $args->{variant_params} | ||||||||||
| 78 | 18 | ▶ | : Games::Solitaire::Verify::VariantsMap->get_variant_by_id( | ||||||||
|
Branch: 1 branch
| |||||||||||
| 79 | $self->_variant() | ||||||||||
| 80 | ) | ||||||||||
| 81 | ); | ||||||||||
| 82 | |||||||||||
| 83 | 18 | $self->_V( $self->_calc_variant_args() ); | |||||||||
| 84 | |||||||||||
| 85 | 18 | return; | |||||||||
| 86 | } | ||||||||||
| 87 | |||||||||||
| 88 | 14 | 1; | |||||||||
| 89 | |||||||||||
| 90 | __END__ | ||||||||||