line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Solitaire::Verify::VariantParams; |
2
|
|
|
|
|
|
|
$Games::Solitaire::Verify::VariantParams::VERSION = '0.2403'; |
3
|
8
|
|
|
8
|
|
56
|
use warnings; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
274
|
|
4
|
8
|
|
|
8
|
|
46
|
use strict; |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
189
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
8
|
|
|
8
|
|
38
|
use parent 'Games::Solitaire::Verify::Base'; |
|
8
|
|
|
|
|
22
|
|
|
8
|
|
|
|
|
47
|
|
8
|
|
|
|
|
|
|
|
9
|
8
|
|
|
8
|
|
1436
|
use Games::Solitaire::Verify::Exception (); |
|
8
|
|
|
|
|
21
|
|
|
8
|
|
|
|
|
4796
|
|
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
|
|
893
|
my ( $self, $args ) = @_; |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
# Set the variant |
36
|
|
|
|
|
|
|
# |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
{ |
39
|
427
|
|
|
|
|
747
|
my $seq_build_by = $args->{seq_build_by}; |
40
|
|
|
|
|
|
|
|
41
|
427
|
50
|
|
|
|
1067
|
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
|
|
|
|
|
1157
|
$self->seq_build_by($seq_build_by); |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
{ |
53
|
427
|
|
|
|
|
687
|
my $esf = $args->{empty_stacks_filled_by}; |
|
427
|
|
|
|
|
742
|
|
54
|
|
|
|
|
|
|
|
55
|
427
|
50
|
|
|
|
978
|
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
|
|
|
|
|
924
|
$self->empty_stacks_filled_by($esf); |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
|
67
|
|
|
|
|
|
|
{ |
68
|
427
|
|
|
|
|
666
|
my $num_decks = $args->{num_decks}; |
|
427
|
|
|
|
|
675
|
|
69
|
|
|
|
|
|
|
|
70
|
427
|
50
|
66
|
|
|
1124
|
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
|
|
|
|
|
790
|
$self->num_decks($num_decks); |
79
|
|
|
|
|
|
|
} |
80
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
{ |
82
|
427
|
|
|
|
|
657
|
my $num_columns = $args->{num_columns}; |
|
427
|
|
|
|
|
767
|
|
83
|
|
|
|
|
|
|
|
84
|
427
|
50
|
33
|
|
|
2087
|
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
|
|
|
|
|
1008
|
$self->num_columns($num_columns) |
94
|
|
|
|
|
|
|
} |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
{ |
97
|
427
|
|
|
|
|
625
|
my $num_freecells = $args->{num_freecells}; |
|
427
|
|
|
|
|
742
|
|
98
|
|
|
|
|
|
|
|
99
|
427
|
50
|
|
|
|
998
|
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
|
|
|
|
|
892
|
$self->num_freecells($num_freecells); |
108
|
|
|
|
|
|
|
} |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
{ |
111
|
427
|
|
|
|
|
632
|
my $seq_move = $args->{sequence_move}; |
|
427
|
|
|
|
|
732
|
|
112
|
|
|
|
|
|
|
|
113
|
427
|
50
|
|
|
|
943
|
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
|
|
|
|
|
965
|
$self->sequence_move($seq_move); |
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
{ |
126
|
427
|
|
100
|
|
|
672
|
my $rules = $args->{rules} || "freecell"; |
|
427
|
|
|
|
|
632
|
|
|
427
|
|
|
|
|
1126
|
|
127
|
|
|
|
|
|
|
|
128
|
427
|
50
|
|
|
|
984
|
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
|
|
|
|
|
992
|
$self->rules($rules); |
137
|
|
|
|
|
|
|
} |
138
|
|
|
|
|
|
|
|
139
|
427
|
|
|
|
|
901
|
return 0; |
140
|
|
|
|
|
|
|
} |
141
|
|
|
|
|
|
|
|
142
|
|
|
|
|
|
|
|
143
|
|
|
|
|
|
|
|
144
|
|
|
|
|
|
|
sub clone |
145
|
|
|
|
|
|
|
{ |
146
|
296
|
|
|
296
|
1
|
506
|
my $self = shift; |
147
|
|
|
|
|
|
|
|
148
|
296
|
|
|
|
|
2560
|
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__ |