… | |
… | |
81 | $ring->negate; |
81 | $ring->negate; |
82 | } |
82 | } |
83 | $chdl->put ($ring->to_object); |
83 | $chdl->put ($ring->to_object); |
84 | } |
84 | } |
85 | |
85 | |
86 | cf::attach_to_type cf::SKILL, cf::SK_JEWELER, |
86 | cf::object->attach ( |
|
|
87 | type => cf::SKILL, |
|
|
88 | subtype => cf::SK_JEWELER, |
87 | on_use_skill => sub { |
89 | on_use_skill => sub { |
88 | my ($sk, $ob, $part, $dir, $msg) = @_; |
90 | my ($sk, $ob, $part, $dir, $msg) = @_; |
89 | my $pl = $ob; |
91 | my $pl = $ob; |
90 | |
92 | |
91 | my $skobj = $sk; |
93 | my $skobj = $sk; |
92 | |
94 | |
93 | my $chdl = new Jeweler::CauldronHandler; |
95 | my $chdl = new Jeweler::CauldronHandler; |
94 | |
96 | |
95 | my $rv = 1; |
97 | my $rv = 1; |
96 | eval { |
98 | eval { |
97 | Jeweler::read_config ($ENV{CROSSFIRE_LIBDIR} . '/jeweler.yaml'); |
|
|
98 | $DEBUG = 1; |
99 | $DEBUG = 1; |
99 | |
100 | |
100 | my $player = $ob->contr; |
101 | my $player = $ob->contr; |
101 | |
102 | |
102 | unless ($chdl->find_cauldron ('jeweler_bench', $ob->map->at ($ob->x, $ob->y))) { |
103 | unless ($chdl->find_cauldron ('jeweler_bench', $ob->map->at ($ob->x, $ob->y))) { |
… | |
… | |
151 | my $c2 = $iring->calc_costs; |
152 | my $c2 = $iring->calc_costs; |
152 | |
153 | |
153 | my %keys; |
154 | my %keys; |
154 | my %cdiff; |
155 | my %cdiff; |
155 | for (keys %$c1, keys %$c2) { $keys{$_} = 1 } |
156 | for (keys %$c1, keys %$c2) { $keys{$_} = 1 } |
156 | for (keys %keys) { $cdiff{$_} = $c2->{$_} - $c1->{$_} } |
157 | for (keys %keys) { $cdiff{$_} = $c2->{$_} - $c1->{$_}; warn "$_: $c2->{$_} | $c1->{$_}\n"; } |
157 | |
158 | |
158 | unless (grep { $_ > 0 } values %cdiff) { |
159 | unless ($iring->is_better_than ($ringo)) { |
159 | $pl->message ("This plan doesn't improve anything, you find yourself puzzled about what you missed..."); |
160 | $pl->message ("This plan doesn't improve anything, you find yourself puzzled about what you missed..."); |
160 | return; |
161 | return; |
161 | } |
162 | } |
162 | |
163 | |
163 | my $remcosts = $ingred->check_costs (\%cdiff); |
164 | my $remcosts = $ingred->check_costs (\%cdiff); |
… | |
… | |
184 | } |
185 | } |
185 | } |
186 | } |
186 | }; |
187 | }; |
187 | $@ and warn "ERROR: $@\n"; |
188 | $@ and warn "ERROR: $@\n"; |
188 | } |
189 | } |
189 | ; |
190 | ); |
190 | |
191 | |
|
|
192 | Jeweler::read_config (cf::datadir . '/jeweler.yaml'); |