line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Bingo::ColumnCollection; |
2
|
|
|
|
|
|
|
|
3
|
18
|
|
|
18
|
|
7402
|
use strict; |
|
18
|
|
|
|
|
37
|
|
|
18
|
|
|
|
|
684
|
|
4
|
18
|
|
|
18
|
|
117
|
use warnings; |
|
18
|
|
|
|
|
29
|
|
|
18
|
|
|
|
|
546
|
|
5
|
18
|
|
|
18
|
|
5335
|
use integer; |
|
18
|
|
|
|
|
75
|
|
|
18
|
|
|
|
|
156
|
|
6
|
18
|
|
|
18
|
|
3175
|
use Games::Bingo; |
|
18
|
|
|
|
|
37
|
|
|
18
|
|
|
|
|
448
|
|
7
|
18
|
|
|
18
|
|
4404
|
use Games::Bingo::Column; |
|
18
|
|
|
|
|
32
|
|
|
18
|
|
|
|
|
485
|
|
8
|
18
|
|
|
18
|
|
100
|
use vars qw(@ISA $VERSION); |
|
18
|
|
|
|
|
36
|
|
|
18
|
|
|
|
|
879
|
|
9
|
18
|
|
|
18
|
|
112
|
use Carp; |
|
18
|
|
|
|
|
53
|
|
|
18
|
|
|
|
|
15422
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
@ISA = qw(Games::Bingo); |
12
|
|
|
|
|
|
|
$VERSION = '0.17'; |
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
sub new { |
15
|
892
|
|
|
892
|
1
|
3845
|
my $class = shift; |
16
|
|
|
|
|
|
|
|
17
|
892
|
|
|
|
|
2904
|
my $self = bless [], $class; |
18
|
|
|
|
|
|
|
|
19
|
892
|
100
|
|
|
|
1904
|
push @{$self}, @_ if (@_); |
|
5
|
|
|
|
|
33
|
|
20
|
|
|
|
|
|
|
|
21
|
892
|
|
|
|
|
2270
|
return $self; |
22
|
|
|
|
|
|
|
} |
23
|
|
|
|
|
|
|
|
24
|
|
|
|
|
|
|
sub divide { |
25
|
179
|
|
|
179
|
1
|
240
|
my $self = shift; |
26
|
179
|
|
|
|
|
218
|
my $number_of_columns = shift; |
27
|
179
|
|
|
|
|
1284
|
my @numbers = @_; |
28
|
|
|
|
|
|
|
|
29
|
179
|
|
|
|
|
516
|
for (my $number = 0; $number < $number_of_columns; $number++) { |
30
|
1611
|
|
|
|
|
2161
|
my @s = (); |
31
|
1611
|
100
|
|
|
|
3199
|
if ($number == 0) { |
|
|
100
|
|
|
|
|
|
32
|
179
|
|
|
|
|
459
|
@s = splice(@numbers, 0, 9); |
33
|
|
|
|
|
|
|
} elsif ($number == 8) { |
34
|
179
|
|
|
|
|
449
|
@s = splice(@numbers, 0, 11); |
35
|
|
|
|
|
|
|
} else { |
36
|
1253
|
|
|
|
|
2834
|
@s = splice(@numbers, 0, 10); |
37
|
|
|
|
|
|
|
} |
38
|
1611
|
|
|
|
|
5395
|
my $column = Games::Bingo::Column->new($number, @s); |
39
|
|
|
|
|
|
|
|
40
|
1611
|
|
|
|
|
3549
|
$self->add_column($column); |
41
|
|
|
|
|
|
|
} |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub add_column { |
45
|
6177
|
|
|
6177
|
1
|
11937
|
my ($self, $column, $index) = @_; |
46
|
|
|
|
|
|
|
|
47
|
6177
|
100
|
|
|
|
11969
|
if ($index) { |
48
|
1
|
|
|
|
|
5
|
$self->[$index] = $column; |
49
|
|
|
|
|
|
|
} else { |
50
|
6176
|
|
|
|
|
6382
|
push(@{$self}, $column); |
|
6176
|
|
|
|
|
21876
|
|
51
|
|
|
|
|
|
|
} |
52
|
|
|
|
|
|
|
} |
53
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub _remove_column { |
55
|
3718
|
|
|
3718
|
|
5463
|
my ($self, $idx) = @_; |
56
|
|
|
|
|
|
|
|
57
|
3718
|
100
|
|
|
|
5448
|
if ($idx < 0 ) { |
|
3717
|
100
|
|
|
|
7824
|
|
58
|
1
|
|
|
|
|
201
|
carp "cannot remove column, index cannot be a negative number ($idx)\n"; |
59
|
1
|
|
|
|
|
61
|
return undef; |
60
|
|
|
|
|
|
|
} elsif ($idx > (scalar @{$self})) { |
61
|
1
|
|
|
|
|
115
|
carp "cannot remove column, no column with that index ($idx)\n"; |
62
|
1
|
|
|
|
|
39
|
return undef; |
63
|
|
|
|
|
|
|
} |
64
|
|
|
|
|
|
|
|
65
|
3716
|
|
|
|
|
4271
|
splice(@{$self}, $idx, 1); |
|
3716
|
|
|
|
|
7821
|
|
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
sub get_column { |
69
|
6408
|
|
|
6408
|
1
|
13823
|
my ($self, $index, $do_splice, $auto_splice) = @_; |
70
|
|
|
|
|
|
|
|
71
|
6408
|
100
|
|
|
|
32341
|
if ($index !~ m/^(-)?\d+$/) { |
72
|
1
|
|
|
|
|
260
|
carp "no or illegal index specified"; |
73
|
1
|
|
|
|
|
175
|
return undef; |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
|
76
|
6407
|
100
|
|
|
|
10643
|
if ($index < 0 ) { |
|
6406
|
100
|
|
|
|
13210
|
|
77
|
1
|
|
|
|
|
95
|
carp "cannot get column, index cannot be a negative number ($index)\n"; |
78
|
1
|
|
|
|
|
88
|
return undef; |
79
|
|
|
|
|
|
|
} elsif ($index > (scalar @{$self})) { |
80
|
1
|
|
|
|
|
114
|
carp "cannot get column, no columns with that index ($index)\n"; |
81
|
1
|
|
|
|
|
88
|
return undef; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
|
84
|
6405
|
|
|
|
|
8570
|
my $column = $self->[$index]; |
85
|
|
|
|
|
|
|
|
86
|
6405
|
50
|
33
|
|
|
22265
|
if ($auto_splice and $column) { |
87
|
0
|
|
|
|
|
0
|
my $length = $column->count_numbers(); |
88
|
0
|
0
|
|
|
|
0
|
if ($length < 2) { |
89
|
0
|
|
|
|
|
0
|
$do_splice = 1; |
90
|
|
|
|
|
|
|
} else { |
91
|
0
|
|
|
|
|
0
|
$do_splice = 0; |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
} |
94
|
|
|
|
|
|
|
|
95
|
6405
|
100
|
|
|
|
14385
|
if ($do_splice) { |
96
|
3715
|
|
|
|
|
6591
|
my $v = $self->_remove_column($index); |
97
|
|
|
|
|
|
|
} |
98
|
6405
|
|
|
|
|
13531
|
return $column; |
99
|
|
|
|
|
|
|
} |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
sub get_random_column { |
102
|
3715
|
|
|
3715
|
1
|
5759
|
my ($self, $do_splice, $auto_splice) = @_; |
103
|
|
|
|
|
|
|
|
104
|
3715
|
|
|
|
|
3615
|
my $index = $self->random(scalar @{$self}); |
|
3715
|
|
|
|
|
10486
|
|
105
|
3715
|
|
|
|
|
4505
|
my $column; |
106
|
|
|
|
|
|
|
|
107
|
3715
|
|
|
|
|
4019
|
eval { |
108
|
3715
|
|
|
|
|
6345
|
$column = $self->get_column($index, $do_splice, $auto_splice); |
109
|
|
|
|
|
|
|
}; |
110
|
|
|
|
|
|
|
|
111
|
3715
|
50
|
|
|
|
6250
|
if (@!) { |
112
|
0
|
|
|
|
|
0
|
warn "unable to get random column: $@"; |
113
|
0
|
|
|
|
|
0
|
return undef; |
114
|
|
|
|
|
|
|
} else { |
115
|
3715
|
|
|
|
|
11589
|
return $column; |
116
|
|
|
|
|
|
|
} |
117
|
|
|
|
|
|
|
} |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
sub count_columns { |
120
|
1
|
|
|
1
|
1
|
5
|
my $self = shift; |
121
|
|
|
|
|
|
|
|
122
|
1
|
|
|
|
|
3
|
return scalar(@{$self}); |
|
1
|
|
|
|
|
7
|
|
123
|
|
|
|
|
|
|
} |
124
|
|
|
|
|
|
|
|
125
|
|
|
|
|
|
|
1; |
126
|
|
|
|
|
|
|
|
127
|
|
|
|
|
|
|
__END__ |