annotate BoosterPack/.svn/text-base/Card.pm.svn-base @ 0:0d795f02a8bb tip

initial committ. what was I thinking?
author Robert McIntyre <rlm@mit.edu>
date Mon, 27 Sep 2010 16:57:26 -0400
parents
children
rev   line source
rlm@0 1 package Card;
rlm@0 2 use List::Util qw(first max maxstr min minstr reduce shuffle sum);
rlm@0 3
rlm@0 4 sub new
rlm@0 5 {
rlm@0 6 my $class = shift;
rlm@0 7
rlm@0 8 my $hashREF =
rlm@0 9 {
rlm@0 10 _tags => {},
rlm@0 11 _pix => ""
rlm@0 12 };
rlm@0 13
rlm@0 14 $objectREF = bless($hashREF, $class);
rlm@0 15
rlm@0 16 return $objectREF;
rlm@0 17
rlm@0 18 }
rlm@0 19
rlm@0 20
rlm@0 21 sub getTags
rlm@0 22 {
rlm@0 23 $bull = @_[0]->{'_tags'};
rlm@0 24 return keys(%$bull);
rlm@0 25 };
rlm@0 26 sub addTags
rlm@0 27 {
rlm@0 28 $object = shift;
rlm@0 29 @add = @_;
rlm@0 30 if (@add)
rlm@0 31 {
rlm@0 32 @ohYeah = ($object->getTags(),@add);
rlm@0 33 foreach(@ohYeah){$object->{_tags}{$_} = "";}
rlm@0 34 }
rlm@0 35 return $object->getTags();
rlm@0 36 };
rlm@0 37
rlm@0 38
rlm@0 39 sub hasTags
rlm@0 40 {
rlm@0 41 $card = shift;
rlm@0 42 @rest = @_;
rlm@0 43 @test = $card->getTags();
rlm@0 44 foreach $e(@rest){if (! (first {$e eq $_} @test)){return 0;}}
rlm@0 45 return 1;
rlm@0 46 }
rlm@0 47
rlm@0 48
rlm@0 49 sub setPix { $_[0]->{_pix} = $_[1]; }
rlm@0 50 sub getPix {return $_[0]->{_pix} ; }
rlm@0 51
rlm@0 52
rlm@0 53 1;