line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Solitaire::Verify::Column; |
2
|
|
|
|
|
|
|
$Games::Solitaire::Verify::Column::VERSION = '0.2402'; |
3
|
10
|
|
|
10
|
|
70433
|
use warnings; |
|
10
|
|
|
|
|
32
|
|
|
10
|
|
|
|
|
350
|
|
4
|
10
|
|
|
10
|
|
55
|
use strict; |
|
10
|
|
|
|
|
21
|
|
|
10
|
|
|
|
|
227
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
|
7
|
10
|
|
|
10
|
|
526
|
use parent 'Games::Solitaire::Verify::Base'; |
|
10
|
|
|
|
|
314
|
|
|
10
|
|
|
|
|
48
|
|
8
|
|
|
|
|
|
|
|
9
|
10
|
|
|
10
|
|
1067
|
use Games::Solitaire::Verify::Exception (); |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
176
|
|
10
|
10
|
|
|
10
|
|
577
|
use Games::Solitaire::Verify::Card (); |
|
10
|
|
|
|
|
22
|
|
|
10
|
|
|
|
|
7875
|
|
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
|
|
4085
|
my ( $self, $str ) = @_; |
25
|
|
|
|
|
|
|
|
26
|
2237
|
100
|
|
|
|
9527
|
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
|
|
|
|
|
10071
|
my @cards = split( / +/, $str ); |
34
|
|
|
|
|
|
|
|
35
|
|
|
|
|
|
|
$self->_cards( |
36
|
|
|
|
|
|
|
[ |
37
|
2235
|
|
|
|
|
5252
|
map { Games::Solitaire::Verify::Card->new( { string => $_ } ) } |
|
10733
|
|
|
|
|
31948
|
|
38
|
|
|
|
|
|
|
@cards |
39
|
|
|
|
|
|
|
] |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
2235
|
|
|
|
|
6433
|
$self->_recalc; |
43
|
|
|
|
|
|
|
|
44
|
2235
|
|
|
|
|
5659
|
return; |
45
|
|
|
|
|
|
|
} |
46
|
|
|
|
|
|
|
|
47
|
|
|
|
|
|
|
sub _init |
48
|
|
|
|
|
|
|
{ |
49
|
2311
|
|
|
2311
|
|
4239
|
my ( $self, $args ) = @_; |
50
|
|
|
|
|
|
|
|
51
|
2311
|
100
|
|
|
|
4907
|
if ( exists( $args->{string} ) ) |
|
|
50
|
|
|
|
|
|
52
|
|
|
|
|
|
|
{ |
53
|
2237
|
|
|
|
|
4579
|
return $self->_from_string( $args->{string} ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
elsif ( exists( $args->{cards} ) ) |
56
|
|
|
|
|
|
|
{ |
57
|
74
|
|
|
|
|
158
|
$self->_cards( $args->{cards} ); |
58
|
|
|
|
|
|
|
|
59
|
74
|
|
|
|
|
164
|
$self->_recalc; |
60
|
74
|
|
|
|
|
136
|
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
|
14501
|
my $self = shift; |
72
|
|
|
|
|
|
|
|
73
|
9847
|
|
|
|
|
13216
|
return scalar( @{ $self->_cards() } ); |
|
9847
|
|
|
|
|
28411
|
|
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
|
77
|
|
|
|
|
|
|
sub pos |
78
|
|
|
|
|
|
|
{ |
79
|
6014
|
|
|
6014
|
1
|
8814
|
my $self = shift; |
80
|
6014
|
|
|
|
|
8577
|
my $idx = shift; |
81
|
|
|
|
|
|
|
|
82
|
6014
|
|
|
|
|
14544
|
return $self->_cards->[$idx]; |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
sub top |
87
|
|
|
|
|
|
|
{ |
88
|
3272
|
|
|
3272
|
1
|
5088
|
my $self = shift; |
89
|
|
|
|
|
|
|
|
90
|
3272
|
|
|
|
|
6170
|
return $self->pos(-1); |
91
|
|
|
|
|
|
|
} |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub clone |
95
|
|
|
|
|
|
|
{ |
96
|
58
|
|
|
58
|
1
|
93
|
my $self = shift; |
97
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
my $new_col = Games::Solitaire::Verify::Column->new( |
99
|
|
|
|
|
|
|
{ |
100
|
58
|
|
|
|
|
84
|
cards => [ map { $_->clone() } @{ $self->_cards() } ], |
|
222
|
|
|
|
|
466
|
|
|
58
|
|
|
|
|
129
|
|
101
|
|
|
|
|
|
|
} |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
58
|
|
|
|
|
171
|
return $new_col; |
105
|
|
|
|
|
|
|
} |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub append_cards |
109
|
|
|
|
|
|
|
{ |
110
|
613
|
|
|
613
|
1
|
1592
|
my ( $S, $c ) = @_; |
111
|
613
|
|
|
|
|
914
|
push @{ $S->_cards() }, @$c; |
|
613
|
|
|
|
|
1519
|
|
112
|
613
|
|
|
|
|
1471
|
$S->_recalc; |
113
|
613
|
|
|
|
|
1180
|
return; |
114
|
|
|
|
|
|
|
} |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
sub append |
118
|
|
|
|
|
|
|
{ |
119
|
1
|
|
|
1
|
1
|
20
|
my ( $self, $more_cards ) = @_; |
120
|
|
|
|
|
|
|
|
121
|
1
|
|
|
|
|
4
|
my $more_copy = $more_cards->clone(); |
122
|
|
|
|
|
|
|
|
123
|
1
|
|
|
|
|
6
|
return $self->append_cards( $more_copy->_cards ); |
124
|
|
|
|
|
|
|
} |
125
|
|
|
|
|
|
|
|
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
sub push |
128
|
|
|
|
|
|
|
{ |
129
|
466
|
|
|
466
|
1
|
888
|
my ( $self, $card ) = @_; |
130
|
|
|
|
|
|
|
|
131
|
466
|
|
|
|
|
799
|
push @{ $self->_cards() }, $card; |
|
466
|
|
|
|
|
1070
|
|
132
|
|
|
|
|
|
|
|
133
|
466
|
|
|
|
|
1242
|
$self->_recalc; |
134
|
|
|
|
|
|
|
|
135
|
466
|
|
|
|
|
858
|
return; |
136
|
|
|
|
|
|
|
} |
137
|
|
|
|
|
|
|
|
138
|
|
|
|
|
|
|
|
139
|
|
|
|
|
|
|
sub pop |
140
|
|
|
|
|
|
|
{ |
141
|
1508
|
|
|
1508
|
1
|
2824
|
my $self = shift; |
142
|
|
|
|
|
|
|
|
143
|
1508
|
|
|
|
|
2179
|
my $card = pop( @{ $self->_cards() } ); |
|
1508
|
|
|
|
|
2896
|
|
144
|
|
|
|
|
|
|
|
145
|
1508
|
|
|
|
|
3897
|
$self->_recalc; |
146
|
|
|
|
|
|
|
|
147
|
1508
|
|
|
|
|
3554
|
return $card; |
148
|
|
|
|
|
|
|
} |
149
|
|
|
|
|
|
|
|
150
|
|
|
|
|
|
|
|
151
|
|
|
|
|
|
|
sub popN |
152
|
|
|
|
|
|
|
{ |
153
|
612
|
|
|
612
|
1
|
1319
|
my ( $S, $c ) = @_; |
154
|
|
|
|
|
|
|
|
155
|
612
|
|
|
|
|
986
|
my @r = splice( @{ $S->_cards() }, -$c ); |
|
612
|
|
|
|
|
1939
|
|
156
|
|
|
|
|
|
|
|
157
|
612
|
|
|
|
|
1618
|
$S->_recalc; |
158
|
|
|
|
|
|
|
|
159
|
612
|
|
|
|
|
1874
|
return \@r; |
160
|
|
|
|
|
|
|
} |
161
|
|
|
|
|
|
|
|
162
|
|
|
|
|
|
|
|
163
|
|
|
|
|
|
|
sub _recalc |
164
|
|
|
|
|
|
|
{ |
165
|
5508
|
|
|
5508
|
|
8555
|
my $self = shift; |
166
|
|
|
|
|
|
|
|
167
|
|
|
|
|
|
|
$self->_s( |
168
|
5508
|
|
|
|
|
9004
|
join( ' ', ':', ( map { $_->fast_s() } @{ $self->_cards() } ) ) ); |
|
23191
|
|
|
|
|
44752
|
|
|
5508
|
|
|
|
|
12184
|
|
169
|
|
|
|
|
|
|
|
170
|
5508
|
|
|
|
|
12006
|
return; |
171
|
|
|
|
|
|
|
} |
172
|
|
|
|
|
|
|
|
173
|
|
|
|
|
|
|
sub to_string |
174
|
|
|
|
|
|
|
{ |
175
|
18170
|
|
|
18170
|
1
|
47133
|
return shift->_s; |
176
|
|
|
|
|
|
|
} |
177
|
|
|
|
|
|
|
|
178
|
|
|
|
|
|
|
1; # End of Games::Solitaire::Verify::Column |
179
|
|
|
|
|
|
|
|
180
|
|
|
|
|
|
|
__END__ |