line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
package Acme::Mitey::Cards::Types::Source; |
2
|
|
|
|
|
|
|
|
3
|
1
|
|
|
1
|
|
8
|
use strict; |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
42
|
|
4
|
1
|
|
|
1
|
|
8
|
use warnings; |
|
1
|
|
|
|
|
2
|
|
|
1
|
|
|
|
|
72
|
|
5
|
|
|
|
|
|
|
|
6
|
|
|
|
|
|
|
use Type::Library 1.014 |
7
|
1
|
|
|
|
|
11
|
-extends => [ |
8
|
|
|
|
|
|
|
'Types::Standard', |
9
|
|
|
|
|
|
|
'Types::Common::String', |
10
|
|
|
|
|
|
|
'Types::Common::Numeric', |
11
|
|
|
|
|
|
|
], |
12
|
|
|
|
|
|
|
-declare => qw( |
13
|
|
|
|
|
|
|
Card FaceCard JokerCard NumericCard Deck Hand Set Suit |
14
|
|
|
|
|
|
|
CardArray CardNumber Character |
15
|
1
|
|
|
1
|
|
546
|
); |
|
1
|
|
|
|
|
11019
|
|
16
|
|
|
|
|
|
|
|
17
|
1
|
|
|
1
|
|
194821
|
use Type::Tiny::Class; |
|
1
|
|
|
|
|
3565
|
|
|
1
|
|
|
|
|
13
|
|
18
|
1
|
|
|
1
|
|
149
|
use Type::Utils (); |
|
1
|
|
|
|
|
3
|
|
|
1
|
|
|
|
|
309
|
|
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
__PACKAGE__->add_type( |
21
|
|
|
|
|
|
|
name => CardNumber, |
22
|
|
|
|
|
|
|
parent => IntRange[ 1, 10 ], |
23
|
|
|
|
|
|
|
); |
24
|
|
|
|
|
|
|
|
25
|
|
|
|
|
|
|
CardNumber->coercion->add_type_coercions( |
26
|
|
|
|
|
|
|
Enum['A', 'a'], q{1}, |
27
|
|
|
|
|
|
|
); |
28
|
|
|
|
|
|
|
|
29
|
|
|
|
|
|
|
__PACKAGE__->add_type( |
30
|
|
|
|
|
|
|
name => Character, |
31
|
|
|
|
|
|
|
parent => Enum[ 'Jack', 'Queen', 'King' ], |
32
|
|
|
|
|
|
|
); |
33
|
|
|
|
|
|
|
|
34
|
|
|
|
|
|
|
__PACKAGE__->add_type( |
35
|
|
|
|
|
|
|
'Type::Tiny::Class'->new( |
36
|
|
|
|
|
|
|
name => Card, |
37
|
|
|
|
|
|
|
class => 'Acme::Mitey::Cards::Card', |
38
|
|
|
|
|
|
|
library => __PACKAGE__, |
39
|
|
|
|
|
|
|
) |
40
|
|
|
|
|
|
|
); |
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
Card->coercion->add_type_coercions( |
43
|
|
|
|
|
|
|
Str, q{'Acme::Mitey::Cards::Card'->from_string($_)}, |
44
|
|
|
|
|
|
|
); |
45
|
|
|
|
|
|
|
|
46
|
|
|
|
|
|
|
__PACKAGE__->add_type( |
47
|
|
|
|
|
|
|
name => CardArray, |
48
|
|
|
|
|
|
|
parent => ArrayRef[Card], |
49
|
|
|
|
|
|
|
coercion => 1, |
50
|
|
|
|
|
|
|
); |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
__PACKAGE__->add_type( |
53
|
|
|
|
|
|
|
'Type::Tiny::Class'->new( |
54
|
|
|
|
|
|
|
name => FaceCard, |
55
|
|
|
|
|
|
|
class => 'Acme::Mitey::Cards::Card::Face', |
56
|
|
|
|
|
|
|
library => __PACKAGE__, |
57
|
|
|
|
|
|
|
) |
58
|
|
|
|
|
|
|
); |
59
|
|
|
|
|
|
|
|
60
|
|
|
|
|
|
|
__PACKAGE__->add_type( |
61
|
|
|
|
|
|
|
'Type::Tiny::Class'->new( |
62
|
|
|
|
|
|
|
name => JokerCard, |
63
|
|
|
|
|
|
|
class => 'Acme::Mitey::Cards::Card::Joker', |
64
|
|
|
|
|
|
|
library => __PACKAGE__, |
65
|
|
|
|
|
|
|
) |
66
|
|
|
|
|
|
|
); |
67
|
|
|
|
|
|
|
|
68
|
|
|
|
|
|
|
__PACKAGE__->add_type( |
69
|
|
|
|
|
|
|
'Type::Tiny::Class'->new( |
70
|
|
|
|
|
|
|
name => NumericCard, |
71
|
|
|
|
|
|
|
class => 'Acme::Mitey::Cards::Card::Numeric', |
72
|
|
|
|
|
|
|
library => __PACKAGE__, |
73
|
|
|
|
|
|
|
) |
74
|
|
|
|
|
|
|
); |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
__PACKAGE__->add_type( |
77
|
|
|
|
|
|
|
'Type::Tiny::Class'->new( |
78
|
|
|
|
|
|
|
name => Deck, |
79
|
|
|
|
|
|
|
class => 'Acme::Mitey::Cards::Deck', |
80
|
|
|
|
|
|
|
library => __PACKAGE__, |
81
|
|
|
|
|
|
|
) |
82
|
|
|
|
|
|
|
); |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
__PACKAGE__->add_type( |
85
|
|
|
|
|
|
|
'Type::Tiny::Class'->new( |
86
|
|
|
|
|
|
|
name => Hand, |
87
|
|
|
|
|
|
|
class => 'Acme::Mitey::Cards::Hand', |
88
|
|
|
|
|
|
|
library => __PACKAGE__, |
89
|
|
|
|
|
|
|
) |
90
|
|
|
|
|
|
|
); |
91
|
|
|
|
|
|
|
|
92
|
|
|
|
|
|
|
Hand->coercion->add_type_coercions( |
93
|
|
|
|
|
|
|
CardArray, q{'Acme::Mitey::Cards::Hand'->new( set => $_ )}, |
94
|
|
|
|
|
|
|
); |
95
|
|
|
|
|
|
|
|
96
|
|
|
|
|
|
|
__PACKAGE__->add_type( |
97
|
|
|
|
|
|
|
'Type::Tiny::Class'->new( |
98
|
|
|
|
|
|
|
name => Set, |
99
|
|
|
|
|
|
|
class => 'Acme::Mitey::Cards::Set', |
100
|
|
|
|
|
|
|
library => __PACKAGE__, |
101
|
|
|
|
|
|
|
) |
102
|
|
|
|
|
|
|
); |
103
|
|
|
|
|
|
|
|
104
|
|
|
|
|
|
|
Set->coercion->add_type_coercions( |
105
|
|
|
|
|
|
|
CardArray, q{'Acme::Mitey::Cards::Set'->new( set => $_ )}, |
106
|
|
|
|
|
|
|
); |
107
|
|
|
|
|
|
|
|
108
|
|
|
|
|
|
|
__PACKAGE__->add_type( |
109
|
|
|
|
|
|
|
'Type::Tiny::Class'->new( |
110
|
|
|
|
|
|
|
name => Suit, |
111
|
|
|
|
|
|
|
class => 'Acme::Mitey::Cards::Suit', |
112
|
|
|
|
|
|
|
library => __PACKAGE__, |
113
|
|
|
|
|
|
|
) |
114
|
|
|
|
|
|
|
); |
115
|
|
|
|
|
|
|
|
116
|
|
|
|
|
|
|
Suit->coercion->add_type_coercions( |
117
|
|
|
|
|
|
|
Str, q{do { my $method = lc($_); 'Acme::Mitey::Cards::Suit'->$method }}, |
118
|
|
|
|
|
|
|
); |
119
|
|
|
|
|
|
|
|
120
|
|
|
|
|
|
|
__PACKAGE__->make_immutable; |
121
|
|
|
|
|
|
|
|
122
|
|
|
|
|
|
|
1; |