line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Solitaire::Verify::Column; |
2
|
|
|
|
|
|
|
$Games::Solitaire::Verify::Column::VERSION = '0.2403'; |
3
|
10
|
|
|
10
|
|
70330
|
use warnings; |
|
10
|
|
|
|
|
30
|
|
|
10
|
|
|
|
|
347
|
|
4
|
10
|
|
|
10
|
|
62
|
use strict; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
223
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
491
|
use parent 'Games::Solitaire::Verify::Base'; |
|
10
|
|
|
|
|
344
|
|
|
10
|
|
|
|
|
73
|
|
8
|
|
|
|
|
|
|
|
9
|
10
|
|
|
10
|
|
1026
|
use Games::Solitaire::Verify::Exception (); |
|
10
|
|
|
|
|
23
|
|
|
10
|
|
|
|
|
197
|
|
10
|
10
|
|
|
10
|
|
568
|
use Games::Solitaire::Verify::Card (); |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
7947
|
|
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
__PACKAGE__->mk_acc_ref( |
13
|
|
|
|
|
|
|
[ |
14
|
|
|
|
|
|
|
qw( |
15
|
|
|
|
|
|
|
_cards |
16
|
|
|
|
|
|
|
_s |
17
|
|
|
|
|
|
|
) |
18
|
|
|
|
|
|
|
] |
19
|
|
|
|
|
|
|
); |
20
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
sub _from_string |
23
|
|
|
|
|
|
|
{ |
24
|
2237
|
|
|
2237
|
|
4171
|
my ( $self, $str ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
2237
|
100
|
|
|
|
10454
|
if ( $str !~ s{\A:(?: )?}{} ) |
27
|
|
|
|
|
|
|
{ |
28
|
2
|
|
|
|
|
30
|
Games::Solitaire::Verify::Exception::Parse::Column::Prefix->throw( |
29
|
|
|
|
|
|
|
error => "String does not start with \": \"", ); |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
# Ignore trailing whitespace, so we don't have -1. |
33
|
2235
|
|
|
|
|
10450
|
my @cards = split( / +/, $str ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$self->_cards( |
36
|
|
|
|
|
|
|
[ |
37
|
2235
|
|
|
|
|
4962
|
map { Games::Solitaire::Verify::Card->new( { string => $_ } ) } |
|
10733
|
|
|
|
|
30865
|
|
38
|
|
|
|
|
|
|
@cards |
39
|
|
|
|
|
|
|
] |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
2235
|
|
|
|
|
6042
|
$self->_recalc; |
43
|
|
|
|
|
|
|
|
44
|
2235
|
|
|
|
|
5530
|
return (); |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _init |
48
|
|
|
|
|
|
|
{ |
49
|
2311
|
|
|
2311
|
|
4234
|
my ( $self, $args ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
2311
|
100
|
|
|
|
4860
|
if ( exists( $args->{string} ) ) |
|
|
50
|
|
|
|
|
|
52
|
|
|
|
|
|
|
{ |
53
|
2237
|
|
|
|
|
4365
|
return $self->_from_string( $args->{string} ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
elsif ( exists( $args->{cards} ) ) |
56
|
|
|
|
|
|
|
{ |
57
|
74
|
|
|
|
|
145
|
$self->_cards( $args->{cards} ); |
58
|
|
|
|
|
|
|
|
59
|
74
|
|
|
|
|
169
|
$self->_recalc; |
60
|
74
|
|
|
|
|
180
|
return (); |
61
|
|
|
|
|
|
|
} |
62
|
|
|
|
|
|
|
else |
63
|
|
|
|
|
|
|
{ |
64
|
0
|
|
|
|
|
0
|
die "Cannot init - no 'string' or 'cards' specified."; |
65
|
|
|
|
|
|
|
} |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
sub len |
70
|
|
|
|
|
|
|
{ |
71
|
9847
|
|
|
9847
|
1
|
14643
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
9847
|
|
|
|
|
13068
|
return scalar( @{ $self->_cards() } ); |
|
9847
|
|
|
|
|
28489
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub pos |
78
|
|
|
|
|
|
|
{ |
79
|
6014
|
|
|
6014
|
1
|
8608
|
my $self = shift; |
80
|
6014
|
|
|
|
|
8307
|
my $idx = shift; |
81
|
|
|
|
|
|
|
|
82
|
6014
|
|
|
|
|
14722
|
return $self->_cards->[$idx]; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub top |
87
|
|
|
|
|
|
|
{ |
88
|
3272
|
|
|
3272
|
1
|
5076
|
my $self = shift; |
89
|
|
|
|
|
|
|
|
90
|
3272
|
|
|
|
|
6013
|
return $self->pos(-1); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub clone |
95
|
|
|
|
|
|
|
{ |
96
|
58
|
|
|
58
|
1
|
86
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $new_col = Games::Solitaire::Verify::Column->new( |
99
|
|
|
|
|
|
|
{ |
100
|
58
|
|
|
|
|
98
|
cards => [ map { $_->clone() } @{ $self->_cards() } ], |
|
222
|
|
|
|
|
440
|
|
|
58
|
|
|
|
|
129
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
58
|
|
|
|
|
207
|
return $new_col; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub append_cards |
109
|
|
|
|
|
|
|
{ |
110
|
613
|
|
|
613
|
1
|
1178
|
my ( $S, $c ) = @_; |
111
|
613
|
|
|
|
|
988
|
push @{ $S->_cards() }, @$c; |
|
613
|
|
|
|
|
1455
|
|
112
|
613
|
|
|
|
|
1514
|
$S->_recalc; |
113
|
613
|
|
|
|
|
1100
|
return (); |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub append |
118
|
|
|
|
|
|
|
{ |
119
|
1
|
|
|
1
|
1
|
19
|
my ( $self, $more_cards ) = @_; |
120
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
4
|
my $more_copy = $more_cards->clone(); |
122
|
|
|
|
|
|
|
|
123
|
1
|
|
|
|
|
9
|
return $self->append_cards( $more_copy->_cards ); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub push |
128
|
|
|
|
|
|
|
{ |
129
|
466
|
|
|
466
|
1
|
1089
|
my ( $self, $card ) = @_; |
130
|
|
|
|
|
|
|
|
131
|
466
|
|
|
|
|
749
|
push @{ $self->_cards() }, $card; |
|
466
|
|
|
|
|
1031
|
|
132
|
|
|
|
|
|
|
|
133
|
466
|
|
|
|
|
1174
|
$self->_recalc; |
134
|
|
|
|
|
|
|
|
135
|
466
|
|
|
|
|
916
|
return (); |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub pop |
140
|
|
|
|
|
|
|
{ |
141
|
1508
|
|
|
1508
|
1
|
2544
|
my $self = shift; |
142
|
|
|
|
|
|
|
|
143
|
1508
|
|
|
|
|
2130
|
my $card = pop( @{ $self->_cards() } ); |
|
1508
|
|
|
|
|
2925
|
|
144
|
|
|
|
|
|
|
|
145
|
1508
|
|
|
|
|
3762
|
$self->_recalc; |
146
|
|
|
|
|
|
|
|
147
|
1508
|
|
|
|
|
3611
|
return $card; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub popN |
152
|
|
|
|
|
|
|
{ |
153
|
612
|
|
|
612
|
1
|
1345
|
my ( $S, $c ) = @_; |
154
|
|
|
|
|
|
|
|
155
|
612
|
|
|
|
|
980
|
my @r = splice( @{ $S->_cards() }, -$c ); |
|
612
|
|
|
|
|
1986
|
|
156
|
|
|
|
|
|
|
|
157
|
612
|
|
|
|
|
1613
|
$S->_recalc; |
158
|
|
|
|
|
|
|
|
159
|
612
|
|
|
|
|
1884
|
return \@r; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub _recalc |
164
|
|
|
|
|
|
|
{ |
165
|
5508
|
|
|
5508
|
|
8852
|
my $self = shift; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
$self->_s( |
168
|
5508
|
|
|
|
|
8616
|
join( ' ', ':', ( map { $_->fast_s() } @{ $self->_cards() } ) ) ); |
|
23191
|
|
|
|
|
44769
|
|
|
5508
|
|
|
|
|
12194
|
|
169
|
|
|
|
|
|
|
|
170
|
5508
|
|
|
|
|
11564
|
return (); |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub to_string |
174
|
|
|
|
|
|
|
{ |
175
|
18170
|
|
|
18170
|
1
|
47189
|
return shift->_s; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; # End of Games::Solitaire::Verify::Column |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
__END__ |