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.21 by root, Fri Oct 12 19:13:26 2007 UTC vs.
Revision 1.26 by elmex, Sun Jul 13 20:15:51 2008 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;
165 164
166sub analyze { 165sub analyze {
167 my ($sk, $chdl, $pl, $input_level) = @_; 166 my ($sk, $chdl, $pl, $input_level) = @_;
168 167
169 my $hadunid = 0; 168 my $hadunid = 0;
169 my $found = 0;
170 for ($chdl->grep_by_type (cf::RING, cf::AMULET)) { 170 for ($chdl->grep_by_type (cf::RING, cf::AMULET)) {
171 if (!$_->flag (cf::FLAG_IDENTIFIED) && $_->need_identify) { 171 if (!$_->flag (cf::FLAG_IDENTIFIED) && $_->need_identify) {
172 $hadunid = 1; 172 $hadunid = 1;
173 next; 173 next;
174 } 174 }
175 $found = 1;
175 my $r = Jeweler::Object->new (object => $_); 176 my $r = Jeweler::Object->new (object => $_);
176 my $msg = $r->analyze ($sk, $pl, $input_level); 177 my $msg = $r->analyze ($sk, $pl, $input_level);
177 $pl->message ($r->to_string . ": " . $msg); 178 $pl->message ($r->to_string . ": " . $msg);
178 if ($pl->flag (cf::FLAG_WIZ)) { 179 if ($pl->flag (cf::FLAG_WIZ)) {
179 $r->wiz_analyze ($pl); 180 $r->wiz_analyze ($pl);
180 } 181 }
181 } 182 }
182 if ($hadunid) {
183 $pl->message ("You couldn't identify the other rings and not analyze them!"); 183 $pl->message ("You couldn't identify the other rings and not analyze them!")
184 } 184 if $hadunid;
185 $pl->message ("You couldn't find anything in the bench to analyse!")
186 unless $found;
185} 187}
186 188
187# this function converts metals/minerals into a raw ring (of adornment) 189# this function converts metals/minerals into a raw ring (of adornment)
188sub simple_converter { 190sub simple_converter {
189 my ($pl, $ingred, $chdl, $conv) = @_; 191 my ($pl, $ingred, $chdl, $conv) = @_;
203 warn "ERROR: Conversion for '$outarch' has only " . (@conv_cfg) . " arguments!"; 205 warn "ERROR: Conversion for '$outarch' has only " . (@conv_cfg) . " arguments!";
204 return; 206 return;
205 } 207 }
206 208
207 unless ($xp_gain > 0) { 209 unless ($xp_gain > 0) {
208 warn "WARNING: xp gain isn't > 0 in convesion '$outarch'\n"; 210 warn "WARNING: xp gain isn't > 0 in conversion '$outarch'\n";
209 return; 211 return;
210 } 212 }
211 213
212 unless ($outarchvalfact) { 214 unless ($outarchvalfact) {
213 warn "ERROR: source-arch-value-multiplier == 0 in conversion '$outarch'\n"; 215 warn "ERROR: source-arch-value-multiplier == 0 in conversion '$outarch'\n";
221 my $archvalsum = $ingred->value ($ingr_grp, $srcarchname); 223 my $archvalsum = $ingred->value ($ingr_grp, $srcarchname);
222 $ingred->remove ($ingr_grp, $srcarchname); 224 $ingred->remove ($ingr_grp, $srcarchname);
223 225
224 my $outarchval = cf::arch::find ($outarch)->value; 226 my $outarchval = cf::arch::find ($outarch)->value;
225 227
226 my $nrof = int ($archvalsum / (($outarchval || 1000) * $outarchvalfact)); 228 my $nrof = int $archvalsum / (($outarchval || 1000) * $outarchvalfact);
227 if ($nrof) { 229 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) 230 # 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) { 231 for (1 .. $nrof) {
230 $chdl->put (my $ob = cf::object::new $outarch); 232 $chdl->put (my $ob = cf::object::new $outarch);
231 $ob->set_animation (cf::rndm $ob->num_animations) 233 $ob->set_animation (cf::rndm $ob->num_animations)
232 if ($ob->type == cf::RING); 234 if ($ob->type == cf::RING);
233 $ob->flag (cf::FLAG_IDENTIFIED, 1); 235 $ob->flag (cf::FLAG_IDENTIFIED, 1);
234 } 236 }
235 237
236 my $xp_sum = ($xp_gain * $nrof); 238 my $xp_sum = $xp_gain * $nrof;
237 239
238 if ($xp_sum) { 240 if ($xp_sum) {
239 $pl->ob->message ("You got $xp_sum xp by making $nrof ${outarch}s"); 241 $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); 242 $pl->ob->change_exp ($xp_sum, "jeweler", cf::SK_EXP_SKILL_ONLY);
241 } 243 }
661 $exp -= $subexp; 663 $exp -= $subexp;
662 $exp = max ($exp, 0); 664 $exp = max ($exp, 0);
663 665
664 } else { 666 } else {
665 # the experience bonus here is to make level 1 rings give you at least 667 # the experience bonus here is to make level 1 rings give you at least
666 # 100 exp points when making them. This also makes leveling in the 668 # 200 exp points when making them. This also makes leveling in the
667 # first few levels a bit easier. (probably until around level 5-6). 669 # first few levels a bit easier. (probably until around level 5-6).
668 my $expbonus = cf::level_to_min_exp (2) / 10; 670 my $expbonus = cf::level_to_min_exp (2) / 5;
669 # this bonus should also only be given for _new_ rings and not for merged 671 # this bonus should also only be given for _new_ rings and not for merged
670 # ones - to prevent infinite exp making. 672 # ones - to prevent infinite exp making.
671 $exp += $expbonus; 673 $exp += $expbonus;
672 } 674 }
673 675
717 if (defined $costs) { 719 if (defined $costs) {
718 my $desc = ""; 720 my $desc = "";
719 my $lvl = $self->power_to_level (\$desc); 721 my $lvl = $self->power_to_level (\$desc);
720 my $scosts = $self->calc_value_from_cost ($costs); 722 my $scosts = $self->calc_value_from_cost ($costs);
721 723
722 $pl->message ("costs: " . (join (', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs)) . " (".($scosts / 5000)." royalties)"); 724 $pl->message ("costs: "
725 . (join ', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs)
726 . " ("
727 . ($scosts / "platinacoin"->cf::arch::find->value)
728 . " platinum)");
723 $pl->message ("level: " . $desc); 729 $pl->message ("level: $desc");
724 } else { 730 } else {
725 $pl->message ("level: impossible to make, due to impossible resistancy configuration"); 731 $pl->message ("level: impossible to make, due to impossible resistancy configuration");
726 } 732 }
727} 733}
728 734

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines