diff Card.pm @ 0:477258d09353 boosterpack

[svn r1] initial import
author robert
date Sun, 30 Aug 2009 02:19:26 -0400
parents
children 8c6d2ce90677
line wrap: on
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/Card.pm	Sun Aug 30 02:19:26 2009 -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