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.4 by elmex, Wed Jan 31 14:11:02 2007 UTC vs.
Revision 1.7 by elmex, Fri Feb 2 12:05:28 2007 UTC

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;
622 my $self = bless { }, $class; 626 my $self = bless { }, $class;
623 627
624 $self->ring_or_ammy_to_hash ($arg{object}); 628 $self->ring_or_ammy_to_hash ($arg{object});
625 629
626 $self; 630 $self;
631}
632
633sub has_resist {
634 my ($self, $resistnam, $resistval) = @_;
635 my $resnum = $REV_RESMAP{uc $resistnam};
636 if (defined ($resistval)) {
637 return 1 if $self->{hash}->{resist}->{$resnum} == $resistval;
638 } else {
639 return 1 if $self->{hash}->{resist}->{$resnum};
640 }
641 return undef;
627} 642}
628 643
629sub analyze { 644sub analyze {
630 my ($self, $sk, $pl) = @_; 645 my ($self, $sk, $pl) = @_;
631 646
645sub wiz_analyze { 660sub wiz_analyze {
646 my ($self, $pl) = @_; 661 my ($self, $pl) = @_;
647 my $costs = $self->calc_costs; 662 my $costs = $self->calc_costs;
648 my $desc = ""; 663 my $desc = "";
649 my $lvl = $self->power_to_level (\$desc); 664 my $lvl = $self->power_to_level (\$desc);
665 my $emarch = cf::arch::find 'emerald';
666 my $saarch = cf::arch::find 'sapphire';
667 my $pearch = cf::arch::find 'pearl';
668 my $ruarch = cf::arch::find 'ruby';
669 my $diarch = cf::arch::find 'gem';
670 my $scosts = $emarch->clone->value * $costs->{emerald}
671 + $saarch->clone->value * $costs->{sapphire}
672 + $pearch->clone->value * $costs->{pearl}
673 + $ruarch->clone->value * $costs->{ruby}
674 + $diarch->clone->value * $costs->{gem};
675
650 $pl->message ("costs: " . join (', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs)); 676 $pl->message ("costs: " . (join (', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs)) . " (".($scosts / 5000)." royalties)");
651 $pl->message ("level: " . $desc); 677 $pl->message ("level: " . $desc);
652} 678}
653 679
654 680
655sub get_chance_perc { 681sub get_chance_perc {
751sub to_object { 777sub to_object {
752 my ($self) = @_; 778 my ($self) = @_;
753 779
754 my $obj = cf::object::new $self->{hash}->{arch}; 780 my $obj = cf::object::new $self->{hash}->{arch};
755 781
782 $obj->item_power ($self->power_to_level); # there have to be strings attached!
783
756 $obj->face ($self->{hash}{face}); 784 $obj->face ($self->{hash}{face});
757 785
758 my $stats = $obj->stats; 786 my $stats = $obj->stats;
759 787
760 $stats->hp ($self->{hash}{spec}{regen}); 788 $stats->hp ($self->{hash}{spec}{regen});

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines