ScottAdams/Item.pm

filter: Statementstmt 15.3% 4 / 26 Branchbran 0.0% 0 / 6 Conditioncond n/a MC/DCmcdc n/a Subroutinesub 14.2% 1 / 7 Podpod 0.0% 0 / 6 totaltotal 11.1% 5 / 45 CC 4 SCAR 17.4
CC
4
Cov
12%
where
12.0
getdrop
6.0
new
2.0
CRAP 5.7
« ScottAdams/File.pm ↑ Summary ScottAdams/Room.pm »
1 # $Id: Item.pm,v 1.1 2006/10/31 20:31:21 mike Exp $
2  
3 # Item.pm - an item in a Scott Adams game.
4  
5 package Games::ScottAdams::Item;
6 1 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8  
9 sub new {
10 0 ▶ my $class = shift();
Subroutine new: not called CC=1 SCAR=6.9
Pod undocumented
11 0 my($name, $desc, $num, $where) = @_;
12  
13 0 return bless {
14 name => $name,
15 desc => $desc,
16 num => $num, # 0-based index into Game's list of rooms
17 where => $where, # name of containing room (undef=nowhere)
18 getdrop => undef, # name for automatic get/drop (if provided)
19 }, $class;
20 }
21  
22  
23 sub name {
24 0 ▶ my $this = shift();
Subroutine name: not called CC=1 SCAR=6.9
Pod undocumented
25 0 return $this->{name};
26 }
27  
28 sub desc {
29 0 ▶ my $this = shift();
Subroutine desc: not called CC=1 SCAR=6.9
Pod undocumented
30 0 return $this->{desc};
31 }
32  
33 sub num {
34 0 ▶ my $this = shift();
Subroutine num: not called CC=1 SCAR=6.9
Pod undocumented
35 0 return $this->{num};
36 }
37  
38  
39 sub where {
40 0 ▶ my $this = shift();
Subroutine where: not called CC=3 SCAR=24.8
Pod undocumented
41 0 my($where) = @_;
42  
43 0 my $old = $this->{where};
44 0 ▶ if (defined $where) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $where) 0 0 0
45 0 ▶ undef $where if $where eq '';
Branch: 1 branch
BranchTrueFalseTotal
if $where eq "" 0 0 0
46 0 $this->{where} = $where;
47 }
48 0 return $old;
49 }
50  
51  
52 # Allow special argument of empty string meaning nowhere
53 sub getdrop {
54 0 ▶ my $this = shift();
Subroutine getdrop: not called CC=2 SCAR=17.9
Pod undocumented
55 0 my($name) = @_;
56  
57 0 my $old = $this->{getdrop};
58 0 ▶ if (defined $name) {
Branch: 1 branch
BranchTrueFalseTotal
if (defined $name) 0 0 0
59 0 $this->{getdrop} = $name;
60 }
61 0 return $old;
62 }
63  
64  
65 1 1;
« ScottAdams/File.pm ↑ Summary ScottAdams/Room.pm »