annotate Card.pm @ 8:8c6d2ce90677 boosterpack

[svn r11] saving for transference to cd
author rlm
date Fri, 19 Mar 2010 07:28:10 -0400
parents 477258d09353
children
rev   line source
rlm@8 1 #!/usr/bin/perl
rlm@8 2
rlm@8 3 package Card;
rlm@8 4 use List::Util qw(first max maxstr min minstr reduce shuffle sum);
rlm@8 5
rlm@8 6 sub new
rlm@8 7 {
rlm@8 8 my $class = shift;
rlm@8 9
rlm@8 10 my $hashREF =
rlm@8 11 {
rlm@8 12 _tags => {},
rlm@8 13 _pix => ""
rlm@8 14 };
rlm@8 15
rlm@8 16 $objectREF = bless($hashREF, $class);
rlm@8 17
rlm@8 18 return $objectREF;
rlm@8 19
rlm@8 20 }
rlm@8 21
rlm@8 22
rlm@8 23 sub getTags
rlm@8 24 {
rlm@8 25 $bull = @_[0]->{'_tags'};
rlm@8 26 return keys(%$bull);
rlm@8 27 };
rlm@8 28 sub addTags
rlm@8 29 {
rlm@8 30 $object = shift;
rlm@8 31 @add = @_;
rlm@8 32 if (@add)
rlm@8 33 {
rlm@8 34 @ohYeah = ($object->getTags(),@add);
rlm@8 35 foreach(@ohYeah){$object->{_tags}{$_} = "";}
rlm@8 36 }
rlm@8 37 return $object->getTags();
rlm@8 38 };
rlm@8 39
rlm@8 40
rlm@8 41 sub hasTags
rlm@8 42 {
rlm@8 43 $card = shift;
rlm@8 44 @rest = @_;
rlm@8 45 @test = $card->getTags();
rlm@8 46 foreach $e(@rest){if (! (first {$e eq $_} @test)){return 0;}}
rlm@8 47 return 1;
rlm@8 48 }
rlm@8 49
rlm@8 50
rlm@8 51 sub setPix { $_[0]->{_pix} = $_[1]; }
rlm@8 52 sub getPix {return $_[0]->{_pix} ; }
rlm@8 53
rlm@8 54
rlm@8 55 1;