ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/Jeweler.pm
(Generate patch)

Comparing deliantra/server/ext/Jeweler.pm (file contents):
Revision 1.20 by root, Sun Sep 30 16:24:29 2007 UTC vs.
Revision 1.23 by root, Mon Dec 17 08:03:22 2007 UTC

24our $CFG; 24our $CFG;
25 25
26sub read_config { 26sub read_config {
27 my ($filename) = @_; 27 my ($filename) = @_;
28 28
29 unless (-e $filename) { 29 if (my $meta = $cf::RESOURCE{$filename}) {
30 $CFG = cf::decode_json $meta->{data};
31 } else {
30 warn "$filename doesn't exists! no config for jeweler skill loaded!\n"; 32 warn "$filename doesn't exist! no config for jeweler skill loaded!\n";
31 $CFG = {}; 33 $CFG = {};
32 return
33 } 34 }
34
35 $CFG = YAML::LoadFile $filename;
36} 35}
37 36
38sub getcfg { 37sub getcfg {
39 my ($sect, $key) = @_; 38 my ($sect, $key) = @_;
40 return $CFG->{$sect} unless defined $key; 39 return $CFG->{$sect} unless defined $key;
177 $pl->message ($r->to_string . ": " . $msg); 176 $pl->message ($r->to_string . ": " . $msg);
178 if ($pl->flag (cf::FLAG_WIZ)) { 177 if ($pl->flag (cf::FLAG_WIZ)) {
179 $r->wiz_analyze ($pl); 178 $r->wiz_analyze ($pl);
180 } 179 }
181 } 180 }
182 if ($hadunid) {
183 $pl->message ("You couldn't identify the other rings and not analyze them!"); 181 $pl->message ("You couldn't identify the other rings and not analyze them!")
184 } 182 if $hadunid;
185} 183}
186 184
187# this function converts metals/minerals into a raw ring (of adornment) 185# this function converts metals/minerals into a raw ring (of adornment)
188sub simple_converter { 186sub simple_converter {
189 my ($pl, $ingred, $chdl, $conv) = @_; 187 my ($pl, $ingred, $chdl, $conv) = @_;
203 warn "ERROR: Conversion for '$outarch' has only " . (@conv_cfg) . " arguments!"; 201 warn "ERROR: Conversion for '$outarch' has only " . (@conv_cfg) . " arguments!";
204 return; 202 return;
205 } 203 }
206 204
207 unless ($xp_gain > 0) { 205 unless ($xp_gain > 0) {
208 warn "WARNING: xp gain isn't > 0 in convesion '$outarch'\n"; 206 warn "WARNING: xp gain isn't > 0 in conversion '$outarch'\n";
209 return; 207 return;
210 } 208 }
211 209
212 unless ($outarchvalfact) { 210 unless ($outarchvalfact) {
213 warn "ERROR: source-arch-value-multiplier == 0 in conversion '$outarch'\n"; 211 warn "ERROR: source-arch-value-multiplier == 0 in conversion '$outarch'\n";
221 my $archvalsum = $ingred->value ($ingr_grp, $srcarchname); 219 my $archvalsum = $ingred->value ($ingr_grp, $srcarchname);
222 $ingred->remove ($ingr_grp, $srcarchname); 220 $ingred->remove ($ingr_grp, $srcarchname);
223 221
224 my $outarchval = cf::arch::find ($outarch)->value; 222 my $outarchval = cf::arch::find ($outarch)->value;
225 223
226 my $nrof = int ($archvalsum / (($outarchval || 1000) * $outarchvalfact)); 224 my $nrof = int $archvalsum / (($outarchval || 1000) * $outarchvalfact);
227 if ($nrof) { 225 if ($nrof) {
228 # XXX: yes, i know what i'm doing here, i don't set nrof, but it didn't work somehow (pls. chek sometimes) 226 # XXX: yes, I know what I'm doing here, I don't set nrof, but it didn't work somehow (pls. check sometimes)
229 for (1..$nrof) { 227 for (1 .. $nrof) {
230 $chdl->put (my $ob = cf::object::new $outarch); 228 $chdl->put (my $ob = cf::object::new $outarch);
231 $ob->set_animation (cf::rndm $ob->num_animations) 229 $ob->set_animation (cf::rndm $ob->num_animations)
232 if ($ob->type == cf::RING); 230 if ($ob->type == cf::RING);
233 $ob->flag (cf::FLAG_IDENTIFIED, 1); 231 $ob->flag (cf::FLAG_IDENTIFIED, 1);
234 } 232 }
235 233
236 my $xp_sum = ($xp_gain * $nrof); 234 my $xp_sum = $xp_gain * $nrof;
237 235
238 if ($xp_sum) { 236 if ($xp_sum) {
239 $pl->ob->message ("You got $xp_sum xp by making $nrof ${outarch}s"); 237 $pl->ob->message ("You got $xp_sum xp by making $nrof ${outarch}s");
240 $pl->ob->change_exp ($xp_sum, "jeweler", cf::SK_EXP_SKILL_ONLY); 238 $pl->ob->change_exp ($xp_sum, "jeweler", cf::SK_EXP_SKILL_ONLY);
241 } 239 }
477} 475}
478 476
479sub improve_ring_by_plan { 477sub improve_ring_by_plan {
480 my ($self, $plan, $ring) = @_; 478 my ($self, $plan, $ring) = @_;
481 479
482 $ring = dclone ($ring); 480 $ring = do { my $guard = Coro::Storable::guard; dclone $ring };
483 481
484 my $ingred = $self->{ingredients}; 482 my $ingred = $self->{ingredients};
485 my $impr = {}; 483 my $impr = {};
486 484
487 if ($plan =~ m/^stat_(\S+)$/) { 485 if ($plan =~ m/^stat_(\S+)$/) {
571} 569}
572 570
573sub check_costs { 571sub check_costs {
574 my ($self, $costs, $do_remove) = @_; 572 my ($self, $costs, $do_remove) = @_;
575 573
576 my $costs = dclone ($costs); 574 my $costs = do { my $guard = Coro::Storable::guard; dclone $costs };
577 575
578 for my $key (keys %$costs) { 576 for my $key (keys %$costs) {
579 my @grepar; 577 my @grepar;
580 if ($key =~ m/^(resist_|spec_|stat_)/) { # check the special items 578 if ($key =~ m/^(resist_|spec_|stat_)/) { # check the special items
581 eval { @grepar = @{Jeweler::getcfg (plans => $key) || []} }; 579 eval { @grepar = @{Jeweler::getcfg (plans => $key) || []} };

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines