… | |
… | |
170 | next; |
170 | next; |
171 | } |
171 | } |
172 | $found = 1; |
172 | $found = 1; |
173 | my $r = Jeweler::Object->new (object => $_); |
173 | my $r = Jeweler::Object->new (object => $_); |
174 | my $msg = $r->analyze ($sk, $pl, $input_level); |
174 | my $msg = $r->analyze ($sk, $pl, $input_level); |
175 | $pl->message ($r->to_string . ": " . $msg); |
175 | $pl->message ("There is a '" . $r->to_string . "' in the workbench. Your analysis: " . $msg); |
176 | if ($pl->flag (cf::FLAG_WIZ)) { |
176 | if ($pl->flag (cf::FLAG_WIZ)) { |
177 | $r->wiz_analyze ($pl); |
177 | $r->wiz_analyze ($pl); |
178 | } |
178 | } |
179 | } |
179 | } |
180 | $pl->message ("You couldn't identify the other rings and not analyze them!") |
180 | $pl->message ("You couldn't identify the other rings and not analyze them!") |
… | |
… | |
230 | if ($nrof) { |
230 | if ($nrof) { |
231 | # XXX: yes, I know what I'm doing here, I don't set nrof, but it didn't work somehow (pls. check sometimes) |
231 | # XXX: yes, I know what I'm doing here, I don't set nrof, but it didn't work somehow (pls. check sometimes) |
232 | $ingred->remove ($ingr_grp, $srcarchname); |
232 | $ingred->remove ($ingr_grp, $srcarchname); |
233 | for (1 .. $nrof) { |
233 | for (1 .. $nrof) { |
234 | $chdl->put (my $ob = cf::object::new $outarch); |
234 | $chdl->put (my $ob = cf::object::new $outarch); |
235 | $ob->set_animation (cf::rndm $ob->num_animations) |
235 | $ob->set_anim_frame (cf::rndm $ob->anim_frames) |
236 | if ($ob->type == cf::RING); |
236 | if ($ob->type == cf::RING); |
237 | $ob->flag (cf::FLAG_IDENTIFIED, 1); |
237 | $ob->flag (cf::FLAG_IDENTIFIED, 1); |
238 | } |
238 | } |
239 | |
239 | |
240 | my $xp_sum = $xp_gain * $nrof; |
240 | my $xp_sum = $xp_gain * $nrof; |
… | |
… | |
591 | } |
591 | } |
592 | |
592 | |
593 | if ($do_remove) { |
593 | if ($do_remove) { |
594 | my $rem = $costs->{$key}; |
594 | my $rem = $costs->{$key}; |
595 | $self->do_grep (sub { |
595 | $self->do_grep (sub { |
|
|
596 | if ($rem) { |
596 | if ($rem) { $rem = Jeweler::Util::remove ($_[0], $rem); } |
597 | $rem = Jeweler::Util::remove ($_[0], $rem); |
|
|
598 | } |
597 | 1 |
599 | 1 |
598 | }, @grepar); |
600 | }, @grepar); |
599 | if ($rem > 0) { |
601 | if ($rem > 0) { |
600 | warn "JEWELER BUG: removed ingredients ($key) $rem > 0 after removing!"; |
602 | warn "JEWELER BUG: removed ingredients ($key) $rem > 0 after removing!"; |
601 | } |
603 | } |
… | |
… | |
652 | return 1 if $self->{hash}->{resist}->{$resnum}; |
654 | return 1 if $self->{hash}->{resist}->{$resnum}; |
653 | } |
655 | } |
654 | return undef; |
656 | return undef; |
655 | } |
657 | } |
656 | |
658 | |
|
|
659 | sub lvl2exp { |
|
|
660 | my $lvl = shift; |
|
|
661 | (cf::level_to_min_exp ($lvl) - cf::level_to_min_exp ($lvl - 1)) |
|
|
662 | / (20 + max ($lvl - 1, 0)) # 20 + level times making such a ring |
|
|
663 | # should get you to the rings level at least. |
|
|
664 | } |
|
|
665 | |
657 | sub projected_exp { |
666 | sub projected_exp { |
658 | my ($self, $input_level) = @_; |
667 | my ($self, $input_level) = @_; |
659 | |
668 | |
660 | my $lvl = max ($self->power_to_level, 1); |
669 | my $lvl = max ($self->power_to_level, 1); |
661 | my $exp = |
670 | my $exp = lvl2exp ($lvl); |
662 | (cf::level_to_min_exp ($lvl) - cf::level_to_min_exp ($lvl - 1)) |
|
|
663 | / (10 + max ($lvl - 1, 0)); # 10 + level times making such a ring |
|
|
664 | # should get you to the rings level at least. |
|
|
665 | |
671 | |
666 | if (defined $input_level) { |
672 | if (defined $input_level) { # in case we merge rings: |
667 | my $subexp = |
673 | my $subexp = lvl2exp ($input_level); |
668 | (cf::level_to_min_exp ($input_level) |
|
|
669 | - cf::level_to_min_exp ($input_level - 1)) |
|
|
670 | / (10 + max ($input_level - 1, 0)); # see above for comment |
|
|
671 | |
|
|
672 | $exp -= $subexp; |
674 | $exp -= $subexp; |
673 | $exp = max ($exp, 0); |
675 | $exp = max ($exp, 0); |
674 | |
676 | |
675 | } else { |
677 | } else { |
676 | # the experience bonus here is to make level 1 rings give you at least |
678 | # the experience bonus here is to make level 1 rings give you at least |
… | |
… | |
856 | sub to_object { |
858 | sub to_object { |
857 | my ($self) = @_; |
859 | my ($self) = @_; |
858 | |
860 | |
859 | my $obj = cf::object::new $self->{hash}->{arch}; |
861 | my $obj = cf::object::new $self->{hash}->{arch}; |
860 | |
862 | |
861 | $obj->item_power (floor ($self->power_to_level / 3)); # there have to be strings attached! |
863 | $obj->item_power (floor ($self->power_to_level / 5)); # there have to be strings attached! |
862 | |
864 | |
863 | $obj->face ($self->{hash}{face}); |
865 | $obj->face ($self->{hash}{face}); |
864 | |
866 | |
865 | my $stats = $obj->stats; |
867 | my $stats = $obj->stats; |
866 | |
868 | |
… | |
… | |
1126 | |
1128 | |
1127 | =cut |
1129 | =cut |
1128 | |
1130 | |
1129 | sub remove { |
1131 | sub remove { |
1130 | my ($obj, $nrof) = @_; |
1132 | my ($obj, $nrof) = @_; |
1131 | |
1133 | |
1132 | my $c = $obj->nrof || 1; |
1134 | my $c = $obj->number_of; |
1133 | my $r = $c > $nrof ? 0 : $nrof - $c; |
1135 | my $r = $c > $nrof ? 0 : $nrof - $c; |
1134 | $obj->decrease (defined ($nrof) ? $nrof : ($obj->nrof || 1)); |
1136 | $obj->decrease (defined ($nrof) ? $nrof : ($obj->nrof || 1)); |
1135 | |
1137 | |
1136 | $r |
1138 | $r |
1137 | } |
1139 | } |