Mercurial > rlmcintyre
comparison 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 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:0d795f02a8bb |
---|---|
1 package Card; | |
2 use List::Util qw(first max maxstr min minstr reduce shuffle sum); | |
3 | |
4 sub new | |
5 { | |
6 my $class = shift; | |
7 | |
8 my $hashREF = | |
9 { | |
10 _tags => {}, | |
11 _pix => "" | |
12 }; | |
13 | |
14 $objectREF = bless($hashREF, $class); | |
15 | |
16 return $objectREF; | |
17 | |
18 } | |
19 | |
20 | |
21 sub getTags | |
22 { | |
23 $bull = @_[0]->{'_tags'}; | |
24 return keys(%$bull); | |
25 }; | |
26 sub addTags | |
27 { | |
28 $object = shift; | |
29 @add = @_; | |
30 if (@add) | |
31 { | |
32 @ohYeah = ($object->getTags(),@add); | |
33 foreach(@ohYeah){$object->{_tags}{$_} = "";} | |
34 } | |
35 return $object->getTags(); | |
36 }; | |
37 | |
38 | |
39 sub hasTags | |
40 { | |
41 $card = shift; | |
42 @rest = @_; | |
43 @test = $card->getTags(); | |
44 foreach $e(@rest){if (! (first {$e eq $_} @test)){return 0;}} | |
45 return 1; | |
46 } | |
47 | |
48 | |
49 sub setPix { $_[0]->{_pix} = $_[1]; } | |
50 sub getPix {return $_[0]->{_pix} ; } | |
51 | |
52 | |
53 1; |