Mercurial > rlmcintyre
diff 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 |
line wrap: on
line diff
1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/BoosterPack/.svn/text-base/Card.pm.svn-base Mon Sep 27 16:57:26 2010 -0400 1.3 @@ -0,0 +1,53 @@ 1.4 +package Card; 1.5 +use List::Util qw(first max maxstr min minstr reduce shuffle sum); 1.6 + 1.7 +sub new 1.8 +{ 1.9 + my $class = shift; 1.10 + 1.11 + my $hashREF = 1.12 + { 1.13 + _tags => {}, 1.14 + _pix => "" 1.15 + }; 1.16 + 1.17 + $objectREF = bless($hashREF, $class); 1.18 + 1.19 + return $objectREF; 1.20 + 1.21 +} 1.22 + 1.23 + 1.24 +sub getTags 1.25 +{ 1.26 + $bull = @_[0]->{'_tags'}; 1.27 + return keys(%$bull); 1.28 +}; 1.29 +sub addTags 1.30 +{ 1.31 + $object = shift; 1.32 + @add = @_; 1.33 + if (@add) 1.34 + { 1.35 + @ohYeah = ($object->getTags(),@add); 1.36 + foreach(@ohYeah){$object->{_tags}{$_} = "";} 1.37 + } 1.38 + return $object->getTags(); 1.39 +}; 1.40 + 1.41 + 1.42 +sub hasTags 1.43 +{ 1.44 + $card = shift; 1.45 + @rest = @_; 1.46 + @test = $card->getTags(); 1.47 + foreach $e(@rest){if (! (first {$e eq $_} @test)){return 0;}} 1.48 + return 1; 1.49 +} 1.50 + 1.51 + 1.52 +sub setPix { $_[0]->{_pix} = $_[1]; } 1.53 +sub getPix {return $_[0]->{_pix} ; } 1.54 + 1.55 + 1.56 +1; 1.57 \ No newline at end of file