… | |
… | |
328 | cf::POTION => 'potions', |
328 | cf::POTION => 'potions', |
329 | cf::SCROLL => 'scrolls', |
329 | cf::SCROLL => 'scrolls', |
330 | ); |
330 | ); |
331 | |
331 | |
332 | for ($self->{cauldron}->inv) { |
332 | for ($self->{cauldron}->inv) { |
|
|
333 | if (!$_->flag (cf::FLAG_IDENTIFIED) && $_->need_identify) { |
|
|
334 | die "unidentified"; |
|
|
335 | } elsif ($_->flag (cf::FLAG_CURSED) || $_->flag (cf::FLAG_DAMNED)) { |
|
|
336 | die "cursed"; |
|
|
337 | } |
333 | |
338 | |
334 | if (my $k = $type_to_key{$_->type}) { |
339 | if (my $k = $type_to_key{$_->type}) { |
335 | push @{$ingreds->{$k}}, $_; |
340 | push @{$ingreds->{$k}}, $_; |
336 | } else { |
341 | } else { |
337 | push @{$ingreds->{other}}, $_; |
342 | push @{$ingreds->{other}}, $_; |
… | |
… | |
585 | } |
590 | } |
586 | } else { |
591 | } else { |
587 | my $nr; |
592 | my $nr; |
588 | $self->do_grep (sub { $nr += ($_[0]->nrof || 1); 0 }, @grepar); |
593 | $self->do_grep (sub { $nr += ($_[0]->nrof || 1); 0 }, @grepar); |
589 | $costs->{$key} -= $nr; |
594 | $costs->{$key} -= $nr; |
590 | warn "CHECKCOST $key <-> $nr -> $costs->{$key}\n"; |
|
|
591 | } |
595 | } |
592 | |
596 | |
593 | } |
597 | } |
594 | |
598 | |
595 | return $costs; |
599 | return $costs; |
… | |
… | |
645 | sub wiz_analyze { |
649 | sub wiz_analyze { |
646 | my ($self, $pl) = @_; |
650 | my ($self, $pl) = @_; |
647 | my $costs = $self->calc_costs; |
651 | my $costs = $self->calc_costs; |
648 | my $desc = ""; |
652 | my $desc = ""; |
649 | my $lvl = $self->power_to_level (\$desc); |
653 | my $lvl = $self->power_to_level (\$desc); |
|
|
654 | my $emarch = cf::arch::find 'emerald'; |
|
|
655 | my $saarch = cf::arch::find 'sapphire'; |
|
|
656 | my $pearch = cf::arch::find 'pearl'; |
|
|
657 | my $ruarch = cf::arch::find 'ruby'; |
|
|
658 | my $diarch = cf::arch::find 'gem'; |
|
|
659 | my $scosts = $emarch->clone->value * $costs->{emerald} |
|
|
660 | + $saarch->clone->value * $costs->{sapphire} |
|
|
661 | + $pearch->clone->value * $costs->{pearl} |
|
|
662 | + $ruarch->clone->value * $costs->{ruby} |
|
|
663 | + $diarch->clone->value * $costs->{gem}; |
|
|
664 | |
650 | $pl->message ("costs: " . join (', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs)); |
665 | $pl->message ("costs: " . (join (', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs)) . " (".($scosts / 5000)." royalties)"); |
651 | $pl->message ("level: " . $desc); |
666 | $pl->message ("level: " . $desc); |
652 | } |
667 | } |
653 | |
668 | |
654 | |
669 | |
655 | sub get_chance_perc { |
670 | sub get_chance_perc { |
… | |
… | |
751 | sub to_object { |
766 | sub to_object { |
752 | my ($self) = @_; |
767 | my ($self) = @_; |
753 | |
768 | |
754 | my $obj = cf::object::new $self->{hash}->{arch}; |
769 | my $obj = cf::object::new $self->{hash}->{arch}; |
755 | |
770 | |
|
|
771 | $obj->item_power ($self->power_to_level); # there have to be strings attached! |
|
|
772 | |
756 | $obj->face ($self->{hash}{face}); |
773 | $obj->face ($self->{hash}{face}); |
757 | |
774 | |
758 | my $stats = $obj->stats; |
775 | my $stats = $obj->stats; |
759 | |
776 | |
760 | $stats->hp ($self->{hash}{spec}{regen}); |
777 | $stats->hp ($self->{hash}{spec}{regen}); |