… | |
… | |
226 | my $nrof = int ($archvalsum / (($outarchval || 1000) * $outarchvalfact)); |
226 | my $nrof = int ($archvalsum / (($outarchval || 1000) * $outarchvalfact)); |
227 | if ($nrof) { |
227 | 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) |
228 | # XXX: yes, i know what i'm doing here, i don't set nrof, but it didn't work somehow (pls. chek sometimes) |
229 | for (1..$nrof) { |
229 | for (1..$nrof) { |
230 | $chdl->put (my $ob = cf::object::new $outarch); |
230 | $chdl->put (my $ob = cf::object::new $outarch); |
231 | $ob->set_animation (cf::rndm $ob->num_animations); |
231 | $ob->set_animation (cf::rndm $ob->num_animations) |
|
|
232 | if ($ob->type == cf::RING); |
232 | $ob->flag (cf::FLAG_IDENTIFIED, 1); |
233 | $ob->flag (cf::FLAG_IDENTIFIED, 1); |
233 | } |
234 | } |
234 | |
235 | |
235 | my $xp_sum = ($xp_gain * $nrof); |
236 | my $xp_sum = ($xp_gain * $nrof); |
236 | |
237 | |
… | |
… | |
328 | cf::POTION => 'potions', |
329 | cf::POTION => 'potions', |
329 | cf::SCROLL => 'scrolls', |
330 | cf::SCROLL => 'scrolls', |
330 | ); |
331 | ); |
331 | |
332 | |
332 | for ($self->{cauldron}->inv) { |
333 | for ($self->{cauldron}->inv) { |
|
|
334 | if (!$_->flag (cf::FLAG_IDENTIFIED) && $_->need_identify) { |
|
|
335 | die "unidentified"; |
|
|
336 | } elsif ($_->flag (cf::FLAG_CURSED) || $_->flag (cf::FLAG_DAMNED)) { |
|
|
337 | die "cursed"; |
|
|
338 | } |
333 | |
339 | |
334 | if (my $k = $type_to_key{$_->type}) { |
340 | if (my $k = $type_to_key{$_->type}) { |
335 | push @{$ingreds->{$k}}, $_; |
341 | push @{$ingreds->{$k}}, $_; |
336 | } else { |
342 | } else { |
337 | push @{$ingreds->{other}}, $_; |
343 | push @{$ingreds->{other}}, $_; |
… | |
… | |
585 | } |
591 | } |
586 | } else { |
592 | } else { |
587 | my $nr; |
593 | my $nr; |
588 | $self->do_grep (sub { $nr += ($_[0]->nrof || 1); 0 }, @grepar); |
594 | $self->do_grep (sub { $nr += ($_[0]->nrof || 1); 0 }, @grepar); |
589 | $costs->{$key} -= $nr; |
595 | $costs->{$key} -= $nr; |
590 | warn "CHECKCOST $key <-> $nr -> $costs->{$key}\n"; |
|
|
591 | } |
596 | } |
592 | |
597 | |
593 | } |
598 | } |
594 | |
599 | |
595 | return $costs; |
600 | return $costs; |
… | |
… | |
622 | my $self = bless { }, $class; |
627 | my $self = bless { }, $class; |
623 | |
628 | |
624 | $self->ring_or_ammy_to_hash ($arg{object}); |
629 | $self->ring_or_ammy_to_hash ($arg{object}); |
625 | |
630 | |
626 | $self; |
631 | $self; |
|
|
632 | } |
|
|
633 | |
|
|
634 | sub has_resist { |
|
|
635 | my ($self, $resistnam, $resistval) = @_; |
|
|
636 | my $resnum = $REV_RESMAP{uc $resistnam}; |
|
|
637 | if (defined ($resistval)) { |
|
|
638 | return 1 if $self->{hash}->{resist}->{$resnum} == $resistval; |
|
|
639 | } else { |
|
|
640 | return 1 if $self->{hash}->{resist}->{$resnum}; |
|
|
641 | } |
|
|
642 | return undef; |
627 | } |
643 | } |
628 | |
644 | |
629 | sub analyze { |
645 | sub analyze { |
630 | my ($self, $sk, $pl) = @_; |
646 | my ($self, $sk, $pl) = @_; |
631 | |
647 | |
… | |
… | |
645 | sub wiz_analyze { |
661 | sub wiz_analyze { |
646 | my ($self, $pl) = @_; |
662 | my ($self, $pl) = @_; |
647 | my $costs = $self->calc_costs; |
663 | my $costs = $self->calc_costs; |
648 | my $desc = ""; |
664 | my $desc = ""; |
649 | my $lvl = $self->power_to_level (\$desc); |
665 | my $lvl = $self->power_to_level (\$desc); |
|
|
666 | my $emarch = cf::arch::find 'emerald'; |
|
|
667 | my $saarch = cf::arch::find 'sapphire'; |
|
|
668 | my $pearch = cf::arch::find 'pearl'; |
|
|
669 | my $ruarch = cf::arch::find 'ruby'; |
|
|
670 | my $diarch = cf::arch::find 'gem'; |
|
|
671 | my $scosts = $emarch->clone->value * $costs->{emerald} |
|
|
672 | + $saarch->clone->value * $costs->{sapphire} |
|
|
673 | + $pearch->clone->value * $costs->{pearl} |
|
|
674 | + $ruarch->clone->value * $costs->{ruby} |
|
|
675 | + $diarch->clone->value * $costs->{gem}; |
|
|
676 | |
650 | $pl->message ("costs: " . join (', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs)); |
677 | $pl->message ("costs: " . (join (', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs)) . " (".($scosts / 5000)." royalties)"); |
651 | $pl->message ("level: " . $desc); |
678 | $pl->message ("level: " . $desc); |
652 | } |
679 | } |
653 | |
680 | |
654 | |
681 | |
655 | sub get_chance_perc { |
682 | sub get_chance_perc { |
… | |
… | |
751 | sub to_object { |
778 | sub to_object { |
752 | my ($self) = @_; |
779 | my ($self) = @_; |
753 | |
780 | |
754 | my $obj = cf::object::new $self->{hash}->{arch}; |
781 | my $obj = cf::object::new $self->{hash}->{arch}; |
755 | |
782 | |
|
|
783 | $obj->item_power ($self->power_to_level); # there have to be strings attached! |
|
|
784 | |
756 | $obj->face ($self->{hash}{face}); |
785 | $obj->face ($self->{hash}{face}); |
757 | |
786 | |
758 | my $stats = $obj->stats; |
787 | my $stats = $obj->stats; |
759 | |
788 | |
760 | $stats->hp ($self->{hash}{spec}{regen}); |
789 | $stats->hp ($self->{hash}{spec}{regen}); |