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