line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
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
|
|
|
1
|
|
5
|
use strict; |
|
1
|
|
|
|
|
1
|
|
|
1
|
|
|
|
|
410
|
|
7
|
|
|
|
|
|
|
|
8
|
|
|
|
|
|
|
|
9
|
|
|
|
|
|
|
sub new { |
10
|
33
|
|
|
33
|
0
|
44
|
my $class = shift(); |
11
|
33
|
|
|
|
|
56
|
my($name, $desc, $num, $where) = @_; |
12
|
|
|
|
|
|
|
|
13
|
33
|
|
|
|
|
263
|
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
|
25
|
|
|
25
|
0
|
26
|
my $this = shift(); |
25
|
25
|
|
|
|
|
81
|
return $this->{name}; |
26
|
|
|
|
|
|
|
} |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
sub desc { |
29
|
33
|
|
|
33
|
0
|
41
|
my $this = shift(); |
30
|
33
|
|
|
|
|
93
|
return $this->{desc}; |
31
|
|
|
|
|
|
|
} |
32
|
|
|
|
|
|
|
|
33
|
|
|
|
|
|
|
sub num { |
34
|
67
|
|
|
67
|
0
|
81
|
my $this = shift(); |
35
|
67
|
|
|
|
|
195
|
return $this->{num}; |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
|
39
|
|
|
|
|
|
|
sub where { |
40
|
55
|
|
|
55
|
0
|
64
|
my $this = shift(); |
41
|
55
|
|
|
|
|
65
|
my($where) = @_; |
42
|
|
|
|
|
|
|
|
43
|
55
|
|
|
|
|
87
|
my $old = $this->{where}; |
44
|
55
|
100
|
|
|
|
109
|
if (defined $where) { |
45
|
11
|
50
|
|
|
|
27
|
undef $where if $where eq ''; |
46
|
11
|
|
|
|
|
16
|
$this->{where} = $where; |
47
|
|
|
|
|
|
|
} |
48
|
55
|
|
|
|
|
156
|
return $old; |
49
|
|
|
|
|
|
|
} |
50
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
# Allow special argument of empty string meaning nowhere |
53
|
|
|
|
|
|
|
sub getdrop { |
54
|
61
|
|
|
61
|
0
|
68
|
my $this = shift(); |
55
|
61
|
|
|
|
|
71
|
my($name) = @_; |
56
|
|
|
|
|
|
|
|
57
|
61
|
|
|
|
|
85
|
my $old = $this->{getdrop}; |
58
|
61
|
100
|
|
|
|
160
|
if (defined $name) { |
59
|
14
|
|
|
|
|
25
|
$this->{getdrop} = $name; |
60
|
|
|
|
|
|
|
} |
61
|
61
|
|
|
|
|
144
|
return $old; |
62
|
|
|
|
|
|
|
} |
63
|
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
1; |