line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Games::Bingo; |
2
|
|
|
|
|
|
|
|
3
|
35
|
|
|
35
|
|
16399
|
use strict; |
|
35
|
|
|
|
|
79
|
|
|
35
|
|
|
|
|
1763
|
|
4
|
35
|
|
|
35
|
|
271
|
use warnings; |
|
35
|
|
|
|
|
67
|
|
|
35
|
|
|
|
|
1238
|
|
5
|
35
|
|
|
35
|
|
16892
|
use integer; |
|
35
|
|
|
|
|
187
|
|
|
35
|
|
|
|
|
212
|
|
6
|
35
|
|
|
35
|
|
1418962
|
use POSIX qw(floor); |
|
35
|
|
|
|
|
11405027
|
|
|
35
|
|
|
|
|
333
|
|
7
|
35
|
|
|
35
|
|
63929
|
use vars qw($VERSION); |
|
35
|
|
|
|
|
159
|
|
|
35
|
|
|
|
|
1906
|
|
8
|
35
|
|
|
35
|
|
22878
|
use Games::Bingo::Constants qw(NUMBER_OF_NUMBERS); |
|
35
|
|
|
|
|
92
|
|
|
35
|
|
|
|
|
44461
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
$VERSION = '0.17'; |
11
|
|
|
|
|
|
|
|
12
|
|
|
|
|
|
|
sub new { |
13
|
192
|
|
|
192
|
1
|
9052
|
my $class = shift; |
14
|
192
|
|
100
|
|
|
844
|
my $ceiling = shift || NUMBER_OF_NUMBERS; |
15
|
|
|
|
|
|
|
|
16
|
192
|
|
|
|
|
1455
|
my $self = bless { |
17
|
|
|
|
|
|
|
_numbers => [], |
18
|
|
|
|
|
|
|
_pulled => [[],[],[],[],[],[],[],[],[],], |
19
|
|
|
|
|
|
|
game => 1, |
20
|
|
|
|
|
|
|
}, $class; |
21
|
|
|
|
|
|
|
|
22
|
192
|
|
|
|
|
328
|
my @ary; |
23
|
192
|
|
|
|
|
568
|
$self->init(\@ary, $ceiling); |
24
|
192
|
|
|
|
|
281
|
push @{$self->{'_numbers'}}, @ary; |
|
192
|
|
|
|
|
2445
|
|
25
|
|
|
|
|
|
|
|
26
|
192
|
|
|
|
|
1016
|
return $self; |
27
|
|
|
|
|
|
|
} |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
sub init { |
30
|
373
|
|
|
373
|
1
|
534
|
my ($self, $numbers, $ceiling) = @_; |
31
|
|
|
|
|
|
|
|
32
|
373
|
|
|
|
|
951
|
for(my $i = 1; $i < ($ceiling + 1); $i++) { |
33
|
33410
|
|
|
|
|
29758
|
push @{$numbers}, $i; |
|
33410
|
|
|
|
|
68371
|
|
34
|
|
|
|
|
|
|
} |
35
|
|
|
|
|
|
|
|
36
|
373
|
|
|
|
|
977
|
return 1; |
37
|
|
|
|
|
|
|
} |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub play { |
40
|
113
|
|
|
113
|
1
|
8480
|
my ($self, $numbers) = @_; |
41
|
|
|
|
|
|
|
|
42
|
113
|
|
|
|
|
119
|
my $number; |
43
|
113
|
100
|
|
|
|
186
|
if ($numbers) { |
44
|
10
|
|
|
|
|
13
|
my $index = $self->random(scalar @{$numbers}); |
|
10
|
|
|
|
|
2067
|
|
45
|
10
|
|
|
|
|
22
|
$number = $numbers->[$index]; |
46
|
10
|
|
|
|
|
11
|
splice(@{$numbers}, $index, 1); |
|
10
|
|
|
|
|
23
|
|
47
|
|
|
|
|
|
|
} else { |
48
|
103
|
|
|
|
|
109
|
my $index = $self->random(scalar @{$self->{'_numbers'}}); |
|
103
|
|
|
|
|
263
|
|
49
|
103
|
|
|
|
|
189
|
$number = $self->{'_numbers'}->[$index]; |
50
|
103
|
|
|
|
|
108
|
splice(@{$self->{'_numbers'}}, $index, 1); |
|
103
|
|
|
|
|
207
|
|
51
|
|
|
|
|
|
|
} |
52
|
113
|
|
|
|
|
226
|
$self->pull($number); |
53
|
|
|
|
|
|
|
|
54
|
113
|
|
|
|
|
446
|
return $number; |
55
|
|
|
|
|
|
|
} |
56
|
|
|
|
|
|
|
|
57
|
|
|
|
|
|
|
sub pulled { |
58
|
32
|
|
|
32
|
1
|
48
|
my ($self, $number) = @_; |
59
|
|
|
|
|
|
|
|
60
|
32
|
|
|
|
|
35
|
my $found = 0; |
61
|
32
|
|
|
|
|
55
|
foreach my $n ($self->_all_pulled()) { |
62
|
636
|
100
|
|
|
|
1079
|
if ($n == $number) { |
63
|
16
|
|
|
|
|
15
|
$found++; |
64
|
16
|
|
|
|
|
22
|
last; |
65
|
|
|
|
|
|
|
}; |
66
|
|
|
|
|
|
|
} |
67
|
|
|
|
|
|
|
|
68
|
32
|
100
|
|
|
|
115
|
if ($found) { |
69
|
16
|
|
|
|
|
70
|
return 1; |
70
|
|
|
|
|
|
|
} else { |
71
|
16
|
|
|
|
|
57
|
return 0; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
|
75
|
|
|
|
|
|
|
sub _all_pulled { |
76
|
37
|
|
|
37
|
|
53
|
my $self = shift; |
77
|
|
|
|
|
|
|
|
78
|
37
|
|
|
|
|
48
|
my @pulled = (); |
79
|
37
|
|
|
|
|
40
|
foreach my $row (@{$self->{'_pulled'}}) { |
|
37
|
|
|
|
|
76
|
|
80
|
348
|
|
|
|
|
307
|
foreach my $number (@{$row}) { |
|
348
|
|
|
|
|
528
|
|
81
|
1395
|
100
|
|
|
|
2538
|
push(@pulled, $number) if $number; |
82
|
|
|
|
|
|
|
} |
83
|
|
|
|
|
|
|
} |
84
|
|
|
|
|
|
|
|
85
|
37
|
|
|
|
|
230
|
return @pulled; |
86
|
|
|
|
|
|
|
} |
87
|
|
|
|
|
|
|
|
88
|
|
|
|
|
|
|
sub pull { |
89
|
116
|
|
|
116
|
1
|
148
|
my ($self, $number) = @_; |
90
|
|
|
|
|
|
|
|
91
|
116
|
|
|
|
|
239
|
return $self->take($self->{'_pulled'}, $number); |
92
|
|
|
|
|
|
|
} |
93
|
|
|
|
|
|
|
|
94
|
|
|
|
|
|
|
sub take { |
95
|
117
|
|
|
117
|
1
|
153
|
my ($self, $taken, $take) = @_; |
96
|
|
|
|
|
|
|
|
97
|
117
|
|
|
|
|
200
|
my ($x, $y, $take_modified) = $self->splitnumber($take); |
98
|
|
|
|
|
|
|
|
99
|
117
|
|
|
|
|
337
|
return $taken->[$x][$y] = $take_modified; |
100
|
|
|
|
|
|
|
} |
101
|
|
|
|
|
|
|
|
102
|
|
|
|
|
|
|
sub random { |
103
|
6516
|
|
|
6516
|
1
|
8083
|
my ($self, $number) = @_; |
104
|
|
|
|
|
|
|
|
105
|
6516
|
|
|
|
|
23433
|
return POSIX::floor(rand($number)); |
106
|
|
|
|
|
|
|
} |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
sub splitnumber { |
109
|
119
|
|
|
119
|
1
|
140
|
my ($self, $number) = @_; |
110
|
|
|
|
|
|
|
|
111
|
119
|
|
|
|
|
301
|
my $modified = sprintf("%02d", $number); |
112
|
119
|
|
|
|
|
422
|
my ($x, $y) = $modified =~ m/^(\d{1})(\d{1})$/o; |
113
|
|
|
|
|
|
|
|
114
|
119
|
|
|
|
|
497
|
return ($x, $y, $modified); |
115
|
|
|
|
|
|
|
} |
116
|
|
|
|
|
|
|
|
117
|
|
|
|
|
|
|
1; |
118
|
|
|
|
|
|
|
|
119
|
|
|
|
|
|
|
__END__ |