| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
package Games::Solitaire::Verify::VariantParams; |
|
2
|
|
|
|
|
|
|
$Games::Solitaire::Verify::VariantParams::VERSION = '0.2401'; |
|
3
|
8
|
|
|
8
|
|
53
|
use warnings; |
|
|
8
|
|
|
|
|
20
|
|
|
|
8
|
|
|
|
|
305
|
|
|
4
|
8
|
|
|
8
|
|
47
|
use strict; |
|
|
8
|
|
|
|
|
17
|
|
|
|
8
|
|
|
|
|
175
|
|
|
5
|
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
37
|
use parent 'Games::Solitaire::Verify::Base'; |
|
|
8
|
|
|
|
|
16
|
|
|
|
8
|
|
|
|
|
56
|
|
|
8
|
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
1484
|
use Games::Solitaire::Verify::Exception (); |
|
|
8
|
|
|
|
|
21
|
|
|
|
8
|
|
|
|
|
4850
|
|
|
10
|
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
__PACKAGE__->mk_acc_ref( |
|
12
|
|
|
|
|
|
|
[ |
|
13
|
|
|
|
|
|
|
qw( |
|
14
|
|
|
|
|
|
|
empty_stacks_filled_by |
|
15
|
|
|
|
|
|
|
num_columns |
|
16
|
|
|
|
|
|
|
num_decks |
|
17
|
|
|
|
|
|
|
num_freecells |
|
18
|
|
|
|
|
|
|
rules |
|
19
|
|
|
|
|
|
|
seq_build_by |
|
20
|
|
|
|
|
|
|
sequence_move |
|
21
|
|
|
|
|
|
|
) |
|
22
|
|
|
|
|
|
|
] |
|
23
|
|
|
|
|
|
|
); |
|
24
|
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
my %seqs_build_by = ( map { $_ => 1 } (qw(alt_color suit rank)) ); |
|
27
|
|
|
|
|
|
|
my %empty_stacks_filled_by_map = ( map { $_ => 1 } (qw(kings any none)) ); |
|
28
|
|
|
|
|
|
|
my %seq_moves = ( map { $_ => 1 } (qw(limited unlimited)) ); |
|
29
|
|
|
|
|
|
|
my %rules_collection = ( map { $_ => 1 } (qw(freecell simple_simon)) ); |
|
30
|
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub _init |
|
32
|
|
|
|
|
|
|
{ |
|
33
|
427
|
|
|
427
|
|
890
|
my ( $self, $args ) = @_; |
|
34
|
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Set the variant |
|
36
|
|
|
|
|
|
|
# |
|
37
|
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
{ |
|
39
|
427
|
|
|
|
|
750
|
my $seq_build_by = $args->{seq_build_by}; |
|
40
|
|
|
|
|
|
|
|
|
41
|
427
|
50
|
|
|
|
1057
|
if ( !exists( $seqs_build_by{$seq_build_by} ) ) |
|
42
|
|
|
|
|
|
|
{ |
|
43
|
0
|
|
|
|
|
0
|
Games::Solitaire::Verify::Exception::VariantParams::Param::SeqBuildBy |
|
44
|
|
|
|
|
|
|
->throw( |
|
45
|
|
|
|
|
|
|
error => "Unrecognised seq_build_by", |
|
46
|
|
|
|
|
|
|
value => $seq_build_by, |
|
47
|
|
|
|
|
|
|
); |
|
48
|
|
|
|
|
|
|
} |
|
49
|
427
|
|
|
|
|
1085
|
$self->seq_build_by($seq_build_by); |
|
50
|
|
|
|
|
|
|
} |
|
51
|
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
{ |
|
53
|
427
|
|
|
|
|
688
|
my $esf = $args->{empty_stacks_filled_by}; |
|
|
427
|
|
|
|
|
720
|
|
|
54
|
|
|
|
|
|
|
|
|
55
|
427
|
50
|
|
|
|
996
|
if ( !exists( $empty_stacks_filled_by_map{$esf} ) ) |
|
56
|
|
|
|
|
|
|
{ |
|
57
|
0
|
|
|
|
|
0
|
Games::Solitaire::Verify::Exception::VariantParams::Param::EmptyStacksFill |
|
58
|
|
|
|
|
|
|
->throw( |
|
59
|
|
|
|
|
|
|
error => "Unrecognised empty_stacks_filled_by", |
|
60
|
|
|
|
|
|
|
value => $esf, |
|
61
|
|
|
|
|
|
|
); |
|
62
|
|
|
|
|
|
|
} |
|
63
|
|
|
|
|
|
|
|
|
64
|
427
|
|
|
|
|
890
|
$self->empty_stacks_filled_by($esf); |
|
65
|
|
|
|
|
|
|
} |
|
66
|
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
{ |
|
68
|
427
|
|
|
|
|
667
|
my $num_decks = $args->{num_decks}; |
|
|
427
|
|
|
|
|
757
|
|
|
69
|
|
|
|
|
|
|
|
|
70
|
427
|
50
|
66
|
|
|
1142
|
if ( !( ( $num_decks == 1 ) || ( $num_decks == 2 ) ) ) |
|
71
|
|
|
|
|
|
|
{ |
|
72
|
0
|
|
|
|
|
0
|
Games::Solitaire::Verify::Exception::VariantParams::Param::NumDecks |
|
73
|
|
|
|
|
|
|
->throw( |
|
74
|
|
|
|
|
|
|
error => "Wrong Number of Decks", |
|
75
|
|
|
|
|
|
|
value => $num_decks, |
|
76
|
|
|
|
|
|
|
); |
|
77
|
|
|
|
|
|
|
} |
|
78
|
427
|
|
|
|
|
813
|
$self->num_decks($num_decks); |
|
79
|
|
|
|
|
|
|
} |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
{ |
|
82
|
427
|
|
|
|
|
619
|
my $num_columns = $args->{num_columns}; |
|
|
427
|
|
|
|
|
764
|
|
|
83
|
|
|
|
|
|
|
|
|
84
|
427
|
50
|
33
|
|
|
2054
|
if ( ( $num_columns =~ /\D/ ) |
|
85
|
|
|
|
|
|
|
|| ( $num_columns == 0 ) ) |
|
86
|
|
|
|
|
|
|
{ |
|
87
|
0
|
|
|
|
|
0
|
Games::Solitaire::Verify::Exception::VariantParams::Param::Stacks |
|
88
|
|
|
|
|
|
|
->throw( |
|
89
|
|
|
|
|
|
|
error => "num_columns is not a number", |
|
90
|
|
|
|
|
|
|
value => $num_columns, |
|
91
|
|
|
|
|
|
|
); |
|
92
|
|
|
|
|
|
|
} |
|
93
|
427
|
|
|
|
|
997
|
$self->num_columns($num_columns) |
|
94
|
|
|
|
|
|
|
} |
|
95
|
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
{ |
|
97
|
427
|
|
|
|
|
622
|
my $num_freecells = $args->{num_freecells}; |
|
|
427
|
|
|
|
|
697
|
|
|
98
|
|
|
|
|
|
|
|
|
99
|
427
|
50
|
|
|
|
975
|
if ( $num_freecells =~ /\D/ ) |
|
100
|
|
|
|
|
|
|
{ |
|
101
|
0
|
|
|
|
|
0
|
Games::Solitaire::Verify::Exception::VariantParams::Param::Freecells |
|
102
|
|
|
|
|
|
|
->throw( |
|
103
|
|
|
|
|
|
|
error => "num_freecells is not a number", |
|
104
|
|
|
|
|
|
|
value => $num_freecells, |
|
105
|
|
|
|
|
|
|
); |
|
106
|
|
|
|
|
|
|
} |
|
107
|
427
|
|
|
|
|
891
|
$self->num_freecells($num_freecells); |
|
108
|
|
|
|
|
|
|
} |
|
109
|
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
{ |
|
111
|
427
|
|
|
|
|
662
|
my $seq_move = $args->{sequence_move}; |
|
|
427
|
|
|
|
|
775
|
|
|
112
|
|
|
|
|
|
|
|
|
113
|
427
|
50
|
|
|
|
958
|
if ( !exists( $seq_moves{$seq_move} ) ) |
|
114
|
|
|
|
|
|
|
{ |
|
115
|
0
|
|
|
|
|
0
|
Games::Solitaire::Verify::Exception::VariantParams::Param::SeqMove |
|
116
|
|
|
|
|
|
|
->throw( |
|
117
|
|
|
|
|
|
|
error => "Unrecognised sequence_move", |
|
118
|
|
|
|
|
|
|
value => $seq_move, |
|
119
|
|
|
|
|
|
|
); |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
|
|
122
|
427
|
|
|
|
|
929
|
$self->sequence_move($seq_move); |
|
123
|
|
|
|
|
|
|
} |
|
124
|
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
{ |
|
126
|
427
|
|
100
|
|
|
680
|
my $rules = $args->{rules} || "freecell"; |
|
|
427
|
|
|
|
|
774
|
|
|
|
427
|
|
|
|
|
1058
|
|
|
127
|
|
|
|
|
|
|
|
|
128
|
427
|
50
|
|
|
|
1328
|
if ( !exists( $rules_collection{$rules} ) ) |
|
129
|
|
|
|
|
|
|
{ |
|
130
|
0
|
|
|
|
|
0
|
Games::Solitaire::Verify::Exception::VariantParams::Param::Rules |
|
131
|
|
|
|
|
|
|
->throw( |
|
132
|
|
|
|
|
|
|
error => "Unrecognised rules", |
|
133
|
|
|
|
|
|
|
value => $rules, |
|
134
|
|
|
|
|
|
|
); |
|
135
|
|
|
|
|
|
|
} |
|
136
|
427
|
|
|
|
|
949
|
$self->rules($rules); |
|
137
|
|
|
|
|
|
|
} |
|
138
|
|
|
|
|
|
|
|
|
139
|
427
|
|
|
|
|
861
|
return 0; |
|
140
|
|
|
|
|
|
|
} |
|
141
|
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub clone |
|
145
|
|
|
|
|
|
|
{ |
|
146
|
296
|
|
|
296
|
1
|
545
|
my $self = shift; |
|
147
|
|
|
|
|
|
|
|
|
148
|
296
|
|
|
|
|
2616
|
return __PACKAGE__->new( |
|
149
|
|
|
|
|
|
|
{ |
|
150
|
|
|
|
|
|
|
empty_stacks_filled_by => $self->empty_stacks_filled_by(), |
|
151
|
|
|
|
|
|
|
num_columns => $self->num_columns(), |
|
152
|
|
|
|
|
|
|
num_decks => $self->num_decks(), |
|
153
|
|
|
|
|
|
|
num_freecells => $self->num_freecells(), |
|
154
|
|
|
|
|
|
|
rules => $self->rules(), |
|
155
|
|
|
|
|
|
|
seq_build_by => $self->seq_build_by(), |
|
156
|
|
|
|
|
|
|
sequence_move => $self->sequence_move(), |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
); |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
1; |
|
162
|
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
__END__ |