line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Set; |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
our $VERSION = '0.014'; |
4
|
|
|
|
|
|
|
our $AUTHORITY = 'cpan:TOBYINK'; |
5
|
|
|
|
|
|
|
|
6
|
4
|
|
|
4
|
|
577
|
use Acme::Mitey::Cards::Mite qw( -all ); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
30
|
|
7
|
4
|
|
|
4
|
|
555
|
use Acme::Mitey::Cards::Types qw( :types ); |
|
4
|
|
|
|
|
9
|
|
|
4
|
|
|
|
|
1312
|
|
8
|
|
|
|
|
|
|
|
9
|
4
|
|
|
4
|
|
25
|
use List::Util (); |
|
4
|
|
|
|
|
8
|
|
|
4
|
|
|
|
|
1117
|
|
10
|
|
|
|
|
|
|
|
11
|
|
|
|
|
|
|
has cards => ( |
12
|
|
|
|
|
|
|
is => lazy, |
13
|
|
|
|
|
|
|
isa => CardArray, |
14
|
|
|
|
|
|
|
); |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
sub _build_cards { |
17
|
2
|
|
|
2
|
|
3
|
my $self = shift; |
18
|
|
|
|
|
|
|
|
19
|
2
|
|
|
|
|
4
|
return []; |
20
|
|
|
|
|
|
|
} |
21
|
|
|
|
|
|
|
|
22
|
|
|
|
|
|
|
signature_for to_string => ( |
23
|
|
|
|
|
|
|
pos => [], |
24
|
|
|
|
|
|
|
); |
25
|
|
|
|
|
|
|
|
26
|
|
|
|
|
|
|
sub to_string { |
27
|
|
|
|
|
|
|
my $self = shift; |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
return join " ", map $_->to_string, @{ $self->cards }; |
30
|
|
|
|
|
|
|
} |
31
|
|
|
|
|
|
|
|
32
|
|
|
|
|
|
|
signature_for count => ( |
33
|
|
|
|
|
|
|
pos => [], |
34
|
|
|
|
|
|
|
); |
35
|
|
|
|
|
|
|
|
36
|
|
|
|
|
|
|
sub count { |
37
|
|
|
|
|
|
|
my $self = shift; |
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
scalar @{ $self->cards }; |
40
|
|
|
|
|
|
|
} |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
signature_for take => ( |
43
|
|
|
|
|
|
|
pos => [ Int ], |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
sub take { |
47
|
|
|
|
|
|
|
my ( $self, $n ) = @_; |
48
|
|
|
|
|
|
|
|
49
|
|
|
|
|
|
|
croak "Not enough cards: wanted %d but only have %d", $n, $self->count |
50
|
|
|
|
|
|
|
if $n > $self->count; |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
my @taken = splice( @{ $self->cards }, 0, $n ); |
53
|
|
|
|
|
|
|
return __PACKAGE__->new( cards => \@taken ); |
54
|
|
|
|
|
|
|
} |
55
|
|
|
|
|
|
|
|
56
|
|
|
|
|
|
|
sub shuffle { |
57
|
1
|
|
|
1
|
0
|
3
|
my $self = shift; |
58
|
|
|
|
|
|
|
|
59
|
1
|
|
|
|
|
1
|
@{ $self->cards } = List::Util::shuffle( @{ $self->cards } ); |
|
1
|
|
|
|
|
6
|
|
|
1
|
|
|
|
|
3
|
|
60
|
|
|
|
|
|
|
|
61
|
1
|
|
|
|
|
2
|
return $self; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
1; |