line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# vi:filetype=perl: |
2
|
|
|
|
|
|
|
|
3
|
|
|
|
|
|
|
package Games::RolePlay::MapGen::MapQueue::Object; |
4
|
|
|
|
|
|
|
|
5
|
1
|
|
|
1
|
|
7413
|
use common::sense; |
|
1
|
|
|
|
|
10
|
|
|
1
|
|
|
|
|
7
|
|
6
|
1
|
|
|
1
|
|
2018
|
use overload fallback => 1, bool => sub{1}, '0+' => \&n, '""' => \&q, "-=" => \&me, "+=" => \&pe; |
|
1
|
|
|
0
|
|
1223
|
|
|
1
|
|
|
|
|
12
|
|
|
0
|
|
|
|
|
0
|
|
7
|
|
|
|
|
|
|
|
8
|
5
|
|
|
5
|
0
|
348
|
sub new { my $class = shift; my $val = shift; bless {q=>1, u=>1, v=>$val}, $class } |
|
5
|
|
|
|
|
9
|
|
|
5
|
|
|
|
|
35
|
|
9
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
sub desc { |
11
|
4
|
|
|
4
|
0
|
8
|
my $this = shift; |
12
|
|
|
|
|
|
|
|
13
|
4
|
|
|
|
|
7
|
my $r = $this->{v}; |
14
|
4
|
100
|
|
|
|
19
|
$r .= " ($this->{q})" if $this->{q} != 1; |
15
|
4
|
100
|
|
|
|
14
|
$r .= " #$this->{c}" unless $this->{u}; |
16
|
|
|
|
|
|
|
|
17
|
4
|
|
|
|
|
15
|
return $r; |
18
|
|
|
|
|
|
|
} |
19
|
|
|
|
|
|
|
|
20
|
|
|
|
|
|
|
sub attr { |
21
|
4
|
|
|
4
|
0
|
1786
|
my $this = shift; |
22
|
4
|
|
|
|
|
8
|
my $name = shift; |
23
|
4
|
|
|
|
|
5
|
my $that = shift; |
24
|
|
|
|
|
|
|
|
25
|
4
|
50
|
|
|
|
11
|
return undef unless $name; |
26
|
|
|
|
|
|
|
|
27
|
4
|
100
|
|
|
|
55
|
$this->{a}{$name} = $that if defined $that; |
28
|
4
|
|
|
|
|
18
|
$this->{a}{$name}; |
29
|
|
|
|
|
|
|
} |
30
|
|
|
|
|
|
|
|
31
|
|
|
|
|
|
|
sub q { |
32
|
8
|
|
|
8
|
0
|
235
|
my $this = shift; |
33
|
|
|
|
|
|
|
|
34
|
8
|
100
|
|
|
|
43
|
return lc("$this->{v} #$this->{c}") unless $this->{u}; |
35
|
3
|
|
|
|
|
12
|
return lc($this->{v}); |
36
|
|
|
|
|
|
|
} |
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
sub n { |
39
|
6
|
|
|
6
|
0
|
20
|
my $this = shift; |
40
|
|
|
|
|
|
|
|
41
|
6
|
|
|
|
|
33
|
return $this->{q}; |
42
|
|
|
|
|
|
|
} |
43
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
sub pe { |
45
|
1
|
|
|
1
|
0
|
3
|
my $this = shift; |
46
|
1
|
|
|
|
|
2
|
my $that = shift; |
47
|
|
|
|
|
|
|
|
48
|
1
|
|
|
|
|
2
|
$this->{q} += $that; |
49
|
1
|
|
|
|
|
3
|
$this; |
50
|
|
|
|
|
|
|
} |
51
|
|
|
|
|
|
|
|
52
|
|
|
|
|
|
|
sub me { |
53
|
1
|
|
|
1
|
0
|
3
|
my $this = shift; |
54
|
1
|
|
|
|
|
31
|
my $that = shift; |
55
|
1
|
|
|
|
|
3
|
my $ordr = shift; |
56
|
|
|
|
|
|
|
|
57
|
1
|
50
|
|
|
|
3
|
return ($this->{q} = ($that - $this->{q})) if $ordr; |
58
|
1
|
|
|
|
|
3
|
$this->{q} -= $that; |
59
|
1
|
|
|
|
|
3
|
$this; |
60
|
|
|
|
|
|
|
} |
61
|
|
|
|
|
|
|
|
62
|
|
|
|
|
|
|
my %item_counts; |
63
|
2
|
100
|
|
2
|
0
|
5
|
sub quantity { my $this = shift; my $q = shift; $this->{q}=$q if defined $q; $this->{q} } |
|
2
|
|
|
|
|
3
|
|
|
2
|
|
|
|
|
7
|
|
|
2
|
|
|
|
|
7
|
|
64
|
1
|
|
|
1
|
0
|
2
|
sub unique { my $this = shift; $this->{u}=1; } |
|
1
|
|
|
|
|
3
|
|
65
|
5
|
|
|
5
|
0
|
17
|
sub nonunique { my $this = shift; $this->{u}=0; my $num = shift; |
|
5
|
|
|
|
|
8
|
|
|
5
|
|
|
|
|
7
|
|
66
|
5
|
100
|
|
|
|
13
|
if( defined $num ) { |
67
|
1
|
|
|
|
|
5
|
$this->set_item_number($num); |
68
|
|
|
|
|
|
|
|
69
|
|
|
|
|
|
|
} else { |
70
|
4
|
100
|
|
|
|
14
|
unless( exists $this->{c} ) { |
71
|
3
|
|
|
|
|
12
|
$this->{c} = ++ $item_counts{$this->{v}}; |
72
|
|
|
|
|
|
|
} |
73
|
|
|
|
|
|
|
} |
74
|
|
|
|
|
|
|
} |
75
|
|
|
|
|
|
|
sub set_item_number { |
76
|
2
|
|
|
2
|
0
|
4
|
my $this = shift; |
77
|
2
|
|
|
|
|
4
|
my $num = 0+shift; |
78
|
|
|
|
|
|
|
|
79
|
2
|
50
|
33
|
|
|
19
|
$item_counts{$this->{v}} = $num if not exists $item_counts{$this->{v}} or $num > $item_counts{$this->{v}}; |
80
|
2
|
|
|
|
|
6
|
$this->{c} = $num; |
81
|
|
|
|
|
|
|
} |
82
|
|
|
|
|
|
|
|
83
|
|
|
|
|
|
|
"I like GD::Graph."; |
84
|
|
|
|
|
|
|
|
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
__END__ |