… | |
… | |
9 | |
9 | |
10 | sub rec_inv_by_slaying { |
10 | sub rec_inv_by_slaying { |
11 | my ($ob, $slaying, $cb) = @_; |
11 | my ($ob, $slaying, $cb) = @_; |
12 | $cb->($ob) if $ob->slaying eq $slaying; |
12 | $cb->($ob) if $ob->slaying eq $slaying; |
13 | for my $iob ($ob->inv) { rec_inv_by_slaying ($iob, $slaying, $cb) } |
13 | for my $iob ($ob->inv) { rec_inv_by_slaying ($iob, $slaying, $cb) } |
|
|
14 | } |
|
|
15 | |
|
|
16 | =item count_linked ($map, $connected) |
|
|
17 | |
|
|
18 | Counts the number of objects with the connected value C<$connected> on |
|
|
19 | the map C<$map>. |
|
|
20 | |
|
|
21 | =cut |
|
|
22 | |
|
|
23 | sub count_linked { |
|
|
24 | my ($map, $connected) = @_; |
|
|
25 | my (@a) = $map->find_link ($connected); |
|
|
26 | scalar @a |
14 | } |
27 | } |
15 | |
28 | |
16 | =item object attachment: 'check_inventory_on_apply' |
29 | =item object attachment: 'check_inventory_on_apply' |
17 | |
30 | |
18 | This attachment checks on apply whether the applyer |
31 | This attachment checks on apply whether the applyer |
… | |
… | |
59 | rec_inv_by_slaying ($pl, $cfg->{key_string}, sub { |
72 | rec_inv_by_slaying ($pl, $cfg->{key_string}, sub { |
60 | my ($ob) = @_; |
73 | my ($ob) = @_; |
61 | $match = $ob; |
74 | $match = $ob; |
62 | }); |
75 | }); |
63 | if ($match) { |
76 | if ($match) { |
64 | $match->decrease_ob_nr ($cfg->{decrease_by_cnt}) if $cfg->{decrease_by_cnt}; |
77 | $match->decrease ($cfg->{decrease_by_cnt}) if $cfg->{decrease_by_cnt}; |
65 | $pl->message ($cfg->{message_on_match}, cf::NDI_UNIQUE) if defined $cfg->{message_on_match}; |
78 | $pl->message ($cfg->{message_on_match}, cf::NDI_UNIQUE) if defined $cfg->{message_on_match}; |
66 | } else { |
79 | } else { |
67 | $pl->message ($cfg->{message_on_nomatch}, cf::NDI_RED | cf::NDI_UNIQUE) if defined $cfg->{message_on_nomatch}; |
80 | $pl->message ($cfg->{message_on_nomatch}, cf::NDI_RED | cf::NDI_UNIQUE) if defined $cfg->{message_on_nomatch}; |
68 | cf::override; |
81 | cf::override; |
69 | } |
82 | } |