Mercurial > boosterpack
comparison Card.pm @ 0:477258d09353 boosterpack
[svn r1] initial import
author | robert |
---|---|
date | Sun, 30 Aug 2009 02:19:26 -0400 |
parents | |
children | 8c6d2ce90677 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:477258d09353 |
---|---|
1 package Card; | |
2 use List::Util qw(first max maxstr min minstr reduce shuffle sum); | |
3 | |
4 sub new | |
5 { | |
6 my $class = shift; | |
7 | |
8 my $hashREF = | |
9 { | |
10 _tags => {}, | |
11 _pix => "" | |
12 }; | |
13 | |
14 $objectREF = bless($hashREF, $class); | |
15 | |
16 return $objectREF; | |
17 | |
18 } | |
19 | |
20 | |
21 sub getTags | |
22 { | |
23 $bull = @_[0]->{'_tags'}; | |
24 return keys(%$bull); | |
25 }; | |
26 sub addTags | |
27 { | |
28 $object = shift; | |
29 @add = @_; | |
30 if (@add) | |
31 { | |
32 @ohYeah = ($object->getTags(),@add); | |
33 foreach(@ohYeah){$object->{_tags}{$_} = "";} | |
34 } | |
35 return $object->getTags(); | |
36 }; | |
37 | |
38 | |
39 sub hasTags | |
40 { | |
41 $card = shift; | |
42 @rest = @_; | |
43 @test = $card->getTags(); | |
44 foreach $e(@rest){if (! (first {$e eq $_} @test)){return 0;}} | |
45 return 1; | |
46 } | |
47 | |
48 | |
49 sub setPix { $_[0]->{_pix} = $_[1]; } | |
50 sub getPix {return $_[0]->{_pix} ; } | |
51 | |
52 | |
53 1; |