… | |
… | |
117 | cf::ATNR_LIFE_STEALING => "LIFE_STEALING", |
117 | cf::ATNR_LIFE_STEALING => "LIFE_STEALING", |
118 | cf::ATNR_BLIND => "BLIND", |
118 | cf::ATNR_BLIND => "BLIND", |
119 | cf::ATNR_DISEASE => "DISEASE", |
119 | cf::ATNR_DISEASE => "DISEASE", |
120 | ); |
120 | ); |
121 | |
121 | |
|
|
122 | our %REV_RESMAP = map { $RESMAP{$_} => $_ } keys %RESMAP; |
|
|
123 | |
122 | our %LVL_DIFF_CHANCES = ( |
124 | our %LVL_DIFF_CHANCES = ( |
123 | +5 => 100, |
125 | +5 => 100, |
124 | +4 => 95, |
126 | +4 => 95, |
125 | +3 => 85, |
127 | +3 => 85, |
126 | +2 => 75, |
128 | +2 => 75, |
… | |
… | |
222 | my $outarchval = cf::arch::find ($outarch)->clone->value; |
224 | my $outarchval = cf::arch::find ($outarch)->clone->value; |
223 | |
225 | |
224 | my $nrof = int ($archvalsum / (($outarchval || 1000) * $outarchvalfact)); |
226 | my $nrof = int ($archvalsum / (($outarchval || 1000) * $outarchvalfact)); |
225 | if ($nrof) { |
227 | if ($nrof) { |
226 | # 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) { |
227 | $chdl->put (cf::object::new $outarch) for 1..$nrof; |
230 | $chdl->put (my $ob = cf::object::new $outarch); |
|
|
231 | $ob->set_animation (cf::rndm $ob->num_animations); |
|
|
232 | $ob->flag (cf::FLAG_IDENTIFIED, 1); |
|
|
233 | } |
228 | |
234 | |
229 | my $xp_sum = ($xp_gain * $nrof); |
235 | my $xp_sum = ($xp_gain * $nrof); |
230 | |
236 | |
231 | if ($xp_sum) { |
237 | if ($xp_sum) { |
232 | $pl->ob->message ("You got $xp_sum xp by making $nrof ${outarch}s"); |
238 | $pl->ob->message ("You got $xp_sum xp by making $nrof ${outarch}s"); |
233 | $pl->ob->change_exp ($xp_sum, "jeweler", cf::SK_EXP_ADD_SKILL); |
239 | $pl->ob->change_exp ($xp_sum, "jeweler", cf::SK_EXP_SKILL_ONLY); |
234 | } |
240 | } |
|
|
241 | } else { |
|
|
242 | $pl->ob->message ("You fail to make something, propably you used not enough source material?"); |
235 | } |
243 | } |
236 | } |
244 | } |
237 | |
245 | |
238 | |
246 | |
239 | package Jeweler::CauldronHandler; |
247 | package Jeweler::CauldronHandler; |
… | |
… | |
320 | cf::POTION => 'potions', |
328 | cf::POTION => 'potions', |
321 | cf::SCROLL => 'scrolls', |
329 | cf::SCROLL => 'scrolls', |
322 | ); |
330 | ); |
323 | |
331 | |
324 | 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 | } |
325 | |
338 | |
326 | if (my $k = $type_to_key{$_->type}) { |
339 | if (my $k = $type_to_key{$_->type}) { |
327 | push @{$ingreds->{$k}}, $_; |
340 | push @{$ingreds->{$k}}, $_; |
|
|
341 | } else { |
|
|
342 | push @{$ingreds->{other}}, $_; |
328 | } |
343 | } |
329 | } |
344 | } |
330 | |
345 | |
331 | return Jeweler::Ingredients->new (ingredients => $ingreds, cauldron_helper => $self) |
346 | return Jeweler::Ingredients->new (ingredients => $ingreds, cauldron_helper => $self) |
332 | } |
347 | } |
… | |
… | |
427 | sub get_plan { |
442 | sub get_plan { |
428 | my ($self) = @_; |
443 | my ($self) = @_; |
429 | |
444 | |
430 | my $ingred = $self->{ingredients}; |
445 | my $ingred = $self->{ingredients}; |
431 | |
446 | |
432 | for my $grp (keys %$ingred) { |
|
|
433 | for my $pot (@{$ingred->{$grp}}) { |
|
|
434 | for my $plan (keys %{$Jeweler::CFG->{plans}}) { |
447 | for my $plan (keys %{$Jeweler::CFG->{plans}}) { |
435 | my $plg = $Jeweler::CFG->{plans}->{$plan}; |
448 | my $plg = $Jeweler::CFG->{plans}->{$plan}; |
436 | my @plga = (); |
449 | my @plga = (); |
437 | unless (ref $plg eq 'ARRAY') { |
450 | unless (ref $plg eq 'ARRAY') { |
438 | push @plga, $plg; |
451 | push @plga, $plg; |
439 | } else { |
452 | } else { |
440 | @plga = @$plg; |
453 | @plga = @$plg; |
441 | } |
454 | } |
442 | next unless @plga > 0; |
455 | next unless @plga > 0; |
443 | if (Jeweler::Util::grep_for_match ($pot, @plga)) { |
456 | if (Jeweler::Util::grep_for_match ($ingred, @plga)) { |
444 | return $plan; |
457 | return $plan; |
445 | } |
|
|
446 | } |
|
|
447 | } |
458 | } |
448 | } |
459 | } |
449 | } |
460 | } |
450 | |
461 | |
451 | sub get_ring { |
462 | sub get_ring { |
… | |
… | |
454 | @{$self->{ingredients}->{ammys} || []}, |
465 | @{$self->{ingredients}->{ammys} || []}, |
455 | @{$self->{ingredients}->{rings} || []} |
466 | @{$self->{ingredients}->{rings} || []} |
456 | ); |
467 | ); |
457 | } |
468 | } |
458 | |
469 | |
|
|
470 | sub improve_max { |
|
|
471 | my ($stat, $impro) = @_; |
|
|
472 | if ($stat >= 0) { |
|
|
473 | $stat = $impro > $stat ? $impro : $stat; |
|
|
474 | } |
|
|
475 | $stat |
|
|
476 | } |
|
|
477 | |
459 | sub improve_ring_by_plan { |
478 | sub improve_ring_by_plan { |
460 | my ($self, $plan, $ring) = @_; |
479 | my ($self, $plan, $ring) = @_; |
461 | |
480 | |
462 | $ring = dclone ($ring); |
481 | $ring = dclone ($ring); |
463 | |
482 | |
… | |
… | |
468 | my $statname = $1; |
487 | my $statname = $1; |
469 | my $plingred = Jeweler::getcfg (plans => $plan) |
488 | my $plingred = Jeweler::getcfg (plans => $plan) |
470 | or die "ingredients for plan '$plan' not defined!"; |
489 | or die "ingredients for plan '$plan' not defined!"; |
471 | |
490 | |
472 | my $cnt = 0; |
491 | my $cnt = 0; |
473 | for my $pot (@{$ingred->{potions}}) { |
|
|
474 | if (Jeweler::Util::grep_for_match ($pot, @$plingred)) { |
492 | if (my $pot = Jeweler::Util::grep_for_match ($ingred, @$plingred)) { |
475 | $cnt += $pot->nrof; |
493 | $cnt += $pot->nrof; |
476 | } |
|
|
477 | } |
494 | } |
478 | |
495 | |
479 | my $maxstat = Jeweler::getcfg (maximprovements => 'stats'); |
496 | my $maxstat = Jeweler::getcfg (maximprovements => 'stats'); |
480 | my $did_impr = 0; |
|
|
481 | for my $x (1..$maxstat) { |
497 | for my $x (1..$maxstat) { |
482 | my $y = Jeweler::Object::fx ($x, 'stat_potions'); |
498 | my $y = Jeweler::Object::fx ($x, 'stat_items'); |
483 | |
499 | |
484 | if ($cnt <= $y->[0]) { |
500 | if ($cnt <= $y->[0]) { |
485 | $ring->{hash}->{stat}->{$statname} += $x; |
501 | $ring->{hash}->{stat}->{$statname} = |
486 | $did_impr = 1; |
502 | improve_max $ring->{hash}->{stat}->{$statname}, $x; |
487 | last; |
503 | last; |
488 | } |
504 | } |
489 | } |
505 | } |
490 | |
506 | |
491 | # we want at least this improvement if we have a plan... |
|
|
492 | $ring->{hash}->{stat}->{$statname} += 1 unless $did_impr; |
|
|
493 | |
|
|
494 | } elsif ($plan =~ m/^spec_(\S+)$/) { |
507 | } elsif ($plan =~ m/^spec_(\S+)$/) { |
|
|
508 | my $specname = $1; |
|
|
509 | my $plingred = Jeweler::getcfg (plans => $plan) |
|
|
510 | or die "ingredients for plan '$plan' not defined!"; |
|
|
511 | |
|
|
512 | my $cnt = 0; |
|
|
513 | if (my $pot = Jeweler::Util::grep_for_match ($ingred, @$plingred)) { |
|
|
514 | $cnt += $pot->nrof; |
|
|
515 | } |
|
|
516 | |
|
|
517 | my $maxspec = Jeweler::getcfg (maximprovements => 'specials'); |
|
|
518 | for my $x (1..$maxspec) { |
|
|
519 | my $y = Jeweler::Object::fx ($x, 'spec_items'); |
|
|
520 | |
|
|
521 | if ($cnt <= $y->[0]) { |
|
|
522 | $ring->{hash}->{spec}->{$specname} = |
|
|
523 | improve_max $ring->{hash}->{spec}->{$specname}, $x; |
|
|
524 | last; |
|
|
525 | } |
|
|
526 | } |
|
|
527 | |
495 | } elsif ($plan =~ m/^resist_(\S+)$/) { |
528 | } elsif ($plan =~ m/^resist_(\S+)$/) { |
|
|
529 | my $resname = $1; |
|
|
530 | my $resnum = $REV_RESMAP{$resname}; |
|
|
531 | my $plingred = Jeweler::getcfg (plans => $plan) |
|
|
532 | or die "ingredients for plan '$plan' not defined!"; |
|
|
533 | |
|
|
534 | my $cnt = 0; |
|
|
535 | if (my $it = Jeweler::Util::grep_for_match ($ingred, @$plingred)) { |
|
|
536 | $cnt += $it->nrof; |
|
|
537 | } |
|
|
538 | my $resist_item_nr = 0; |
|
|
539 | $self->do_grep (sub { $resist_item_nr += ($_[0]->nrof || 1); 0 }, @$plingred); |
|
|
540 | |
|
|
541 | my $maximprovname = (grep { $resnum eq $_ } @Jeweler::EFFECT_RESISTS) |
|
|
542 | ? 'effect_resistances' |
|
|
543 | : 'attack_resistances'; |
|
|
544 | |
|
|
545 | my $maxres = Jeweler::getcfg (maximprovements => $maximprovname); |
|
|
546 | $resist_item_nr = $maxres if ($resist_item_nr > $maxres); |
|
|
547 | $ring->{hash}->{resist}->{$resnum} = |
|
|
548 | improve_max $ring->{hash}->{resist}->{$resnum}, $resist_item_nr; |
496 | } |
549 | } |
497 | |
550 | |
498 | return $ring; |
551 | return $ring; |
499 | } |
552 | } |
500 | |
553 | |
501 | sub do_grep { |
554 | sub do_grep { |
502 | my ($self, $cb, @grepar) = @_; |
555 | my ($self, $cb, $cat, @grepar) = @_; |
503 | |
556 | |
504 | my $ingred = $self->{ingredients}; |
557 | my $ingred = $self->{ingredients}; |
505 | |
558 | |
506 | |
|
|
507 | for my $cat (keys %$ingred) { |
|
|
508 | my @rem; |
559 | my @rem; |
509 | for my $ing (@{$ingred->{$cat}}) { |
560 | for my $ing (@{$ingred->{$cat}}) { |
510 | if (Jeweler::Util::grep_for_match ($ing, @grepar)) { |
561 | if (Jeweler::Util::check_for_match ($ing, @grepar)) { |
511 | unless ($cb->($ing)) { |
562 | unless ($cb->($ing)) { |
512 | push @rem, $ing; |
|
|
513 | } |
|
|
514 | } else { |
|
|
515 | push @rem, $ing; |
563 | push @rem, $ing; |
516 | } |
564 | } |
|
|
565 | } else { |
|
|
566 | push @rem, $ing; |
517 | } |
567 | } |
|
|
568 | } |
518 | @{$ingred->{$cat}} = @rem; |
569 | @{$ingred->{$cat}} = @rem; |
519 | } |
|
|
520 | } |
570 | } |
521 | |
571 | |
522 | sub check_costs { |
572 | sub check_costs { |
523 | my ($self, $costs, $do_remove) = @_; |
573 | my ($self, $costs, $do_remove) = @_; |
524 | |
574 | |
525 | my $costs = dclone ($costs); |
575 | my $costs = dclone ($costs); |
526 | |
576 | |
527 | for my $key (keys %$costs) { |
577 | for my $key (keys %$costs) { |
528 | my @grepar; |
578 | my @grepar; |
529 | if ($key =~ m/^stat_(\S+)$/) { |
579 | if ($key =~ m/^(resist_|spec_|stat_)/) { # check the special items |
530 | @grepar = @{Jeweler::getcfg (plans => $key) || []}; |
580 | @grepar = @{Jeweler::getcfg (plans => $key) || []}; |
531 | } else { |
581 | } else { # check the gems |
532 | @grepar = (undef, undef, $key); |
582 | @grepar = ('gems', undef, undef, $key); |
533 | } |
583 | } |
534 | |
584 | |
535 | if ($do_remove) { |
585 | if ($do_remove) { |
536 | my $rem = $costs->{$key}; |
586 | my $rem = $costs->{$key}; |
537 | $self->do_grep (sub { if ($rem) { $rem = Jeweler::Util::remove ($_[0], $rem); } 1 }, @grepar); |
587 | $self->do_grep (sub { if ($rem) { $rem = Jeweler::Util::remove ($_[0], $rem); } 1 }, @grepar); |
538 | if ($rem > 0) { |
588 | if ($rem > 0) { |
539 | warn "JEWELER BUG: removed ingredients $rem > 0 after removing!"; |
589 | warn "JEWELER BUG: removed ingredients $rem > 0 after removing!"; |
540 | } |
590 | } |
541 | } else { |
591 | } else { |
542 | my $nr; |
592 | my $nr; |
543 | $self->do_grep (sub { $nr += $_[0]->nrof; 0 }, @grepar); |
593 | $self->do_grep (sub { $nr += ($_[0]->nrof || 1); 0 }, @grepar); |
544 | $costs->{$key} -= $nr; |
594 | $costs->{$key} -= $nr; |
545 | } |
595 | } |
|
|
596 | |
546 | } |
597 | } |
547 | |
598 | |
548 | return $costs; |
599 | return $costs; |
549 | } |
600 | } |
550 | |
601 | |
… | |
… | |
575 | my $self = bless { }, $class; |
626 | my $self = bless { }, $class; |
576 | |
627 | |
577 | $self->ring_or_ammy_to_hash ($arg{object}); |
628 | $self->ring_or_ammy_to_hash ($arg{object}); |
578 | |
629 | |
579 | $self; |
630 | $self; |
|
|
631 | } |
|
|
632 | |
|
|
633 | sub 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; |
580 | } |
642 | } |
581 | |
643 | |
582 | sub analyze { |
644 | sub analyze { |
583 | my ($self, $sk, $pl) = @_; |
645 | my ($self, $sk, $pl) = @_; |
584 | |
646 | |
… | |
… | |
598 | sub wiz_analyze { |
660 | sub wiz_analyze { |
599 | my ($self, $pl) = @_; |
661 | my ($self, $pl) = @_; |
600 | my $costs = $self->calc_costs; |
662 | my $costs = $self->calc_costs; |
601 | my $desc = ""; |
663 | my $desc = ""; |
602 | 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 | |
603 | $pl->message ("costs: " . join (', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs)); |
676 | $pl->message ("costs: " . (join (', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs)) . " (".($scosts / 5000)." royalties)"); |
604 | $pl->message ("level: " . $desc); |
677 | $pl->message ("level: " . $desc); |
605 | } |
678 | } |
606 | |
679 | |
607 | |
680 | |
608 | sub get_chance_perc { |
681 | sub get_chance_perc { |
… | |
… | |
675 | my ($self, $thing) = @_; |
748 | my ($self, $thing) = @_; |
676 | |
749 | |
677 | my $obj = {}; |
750 | my $obj = {}; |
678 | |
751 | |
679 | for (@Jeweler::RESISTS) { |
752 | for (@Jeweler::RESISTS) { |
680 | $obj->{resist}->{$_} = $thing->resistance ($_); |
753 | $obj->{resist}->{$_} = $thing->resist ($_); |
681 | } |
754 | } |
682 | |
755 | |
683 | my $stats = $thing->stats; |
756 | my $stats = $thing->stats; |
684 | |
757 | |
685 | for (qw/Str Dex Con Wis Cha Int Pow/) { |
758 | for (qw/Str Dex Con Wis Cha Int Pow/) { |
… | |
… | |
704 | sub to_object { |
777 | sub to_object { |
705 | my ($self) = @_; |
778 | my ($self) = @_; |
706 | |
779 | |
707 | my $obj = cf::object::new $self->{hash}->{arch}; |
780 | my $obj = cf::object::new $self->{hash}->{arch}; |
708 | |
781 | |
|
|
782 | $obj->item_power ($self->power_to_level); # there have to be strings attached! |
|
|
783 | |
709 | $obj->face ($self->{hash}{face}); |
784 | $obj->face ($self->{hash}{face}); |
710 | |
785 | |
711 | my $stats = $obj->stats; |
786 | my $stats = $obj->stats; |
712 | |
787 | |
713 | $stats->hp ($self->{hash}{spec}{regen}); |
788 | $stats->hp ($self->{hash}{spec}{regen}); |
… | |
… | |
720 | |
795 | |
721 | $stats->$_ ($self->{hash}{stat}{lc $_}) |
796 | $stats->$_ ($self->{hash}{stat}{lc $_}) |
722 | for qw/Str Dex Con Wis Cha Int Pow/; |
797 | for qw/Str Dex Con Wis Cha Int Pow/; |
723 | |
798 | |
724 | for (@Jeweler::RESISTS) { |
799 | for (@Jeweler::RESISTS) { |
725 | $obj->resistance ($_, $self->{hash}->{resist}->{$_}); |
800 | $obj->resist ($_, $self->{hash}->{resist}->{$_}); |
726 | } |
801 | } |
727 | |
802 | |
728 | $obj->flag (cf::FLAG_IDENTIFIED, 1); |
803 | $obj->flag (cf::FLAG_IDENTIFIED, 1); |
729 | |
804 | |
730 | return $obj; |
805 | return $obj; |
|
|
806 | } |
|
|
807 | |
|
|
808 | sub is_better_than { |
|
|
809 | my ($self, $other) = @_; |
|
|
810 | |
|
|
811 | for my $type (qw/spec stat resist/) { |
|
|
812 | for my $stat (keys %{$self->{hash}->{$type}}) { |
|
|
813 | if ($self->{hash}->{$type}->{$stat} > $other->{hash}->{$type}->{$stat}) { |
|
|
814 | return 1; |
|
|
815 | } |
|
|
816 | } |
|
|
817 | } |
|
|
818 | |
|
|
819 | return 0; |
731 | } |
820 | } |
732 | |
821 | |
733 | sub stat_level { |
822 | sub stat_level { |
734 | my ($self) = @_; |
823 | my ($self) = @_; |
735 | my $stats = $self->{hash}->{stat} || {}; |
824 | my $stats = $self->{hash}->{stat} || {}; |
… | |
… | |
849 | for my $stat (keys %$stats) { |
938 | for my $stat (keys %$stats) { |
850 | my $sum = $stats->{$stat}; |
939 | my $sum = $stats->{$stat}; |
851 | |
940 | |
852 | next unless $sum > 0; |
941 | next unless $sum > 0; |
853 | |
942 | |
854 | my $statfx = fx ($sum, 'stat_potions'); |
943 | my $statfx = fx ($sum, 'stat_items'); |
855 | $cost->{"stat_$stat"} += $statfx->[0]; |
944 | $cost->{"stat_$stat"} += $statfx->[0]; |
856 | split_diamonds ($cost, $statfx->[1], 'stat_' . $stat); |
945 | split_diamonds ($cost, $statfx->[1], 'stat_' . $stat); |
857 | } |
946 | } |
858 | } |
947 | } |
859 | |
948 | |
… | |
… | |
865 | for my $spec (keys %$specials) { |
954 | for my $spec (keys %$specials) { |
866 | my $sum = $specials->{$spec}; |
955 | my $sum = $specials->{$spec}; |
867 | |
956 | |
868 | next unless $sum > 0; |
957 | next unless $sum > 0; |
869 | |
958 | |
870 | my $specfx = fx ($sum, 'spec_potions'); |
959 | my $specfx = fx ($sum, 'spec_items'); |
871 | $cost->{"spec_$spec"} += $specfx->[0]; |
960 | $cost->{"spec_$spec"} += $specfx->[0]; |
872 | split_diamonds ($cost, $specfx->[1], 'spec_' . $spec); |
961 | split_diamonds ($cost, $specfx->[1], 'spec_' . $spec); |
873 | } |
962 | } |
874 | } |
963 | } |
875 | |
964 | |
… | |
… | |
878 | |
967 | |
879 | my $costs = {}; |
968 | my $costs = {}; |
880 | |
969 | |
881 | my $ring = $self->{hash}; |
970 | my $ring = $self->{hash}; |
882 | |
971 | |
883 | for my $resnam (keys %{$ring->{resist} || {}}) { |
972 | for my $resnum (keys %{$ring->{resist} || {}}) { |
884 | |
973 | |
885 | my $res = $ring->{resist}->{$resnam}; |
974 | my $res = $ring->{resist}->{$resnum}; |
886 | |
975 | |
887 | next unless $res > 0; |
976 | next unless $res > 0; |
888 | |
977 | |
889 | $costs->{"resist_" . $Jeweler::RESMAP{$resnam} . "_item"} += $res; |
978 | $costs->{"resist_" . $Jeweler::RESMAP{$resnum}} += $res; |
890 | |
979 | |
891 | my $diamonds; |
980 | my $diamonds; |
892 | if (grep { $resnam eq $_ } @Jeweler::EFFECT_RESISTS) { |
981 | if (grep { $resnum eq $_ } @Jeweler::EFFECT_RESISTS) { |
893 | $diamonds += fx ($res, 'effect_resist_diamonds'); |
982 | $diamonds += fx ($res, 'effect_resist_diamonds'); |
894 | } else { |
983 | } else { |
895 | $diamonds += fx ($res, 'attack_resist_diamonds'); |
984 | $diamonds += fx ($res, 'attack_resist_diamonds'); |
896 | } |
985 | } |
897 | |
986 | |
898 | split_diamonds ($costs, $diamonds, 'resist_' . $Jeweler::RESMAP{$resnam}); |
987 | split_diamonds ($costs, $diamonds, 'resist_' . $Jeweler::RESMAP{$resnum}); |
899 | } |
988 | } |
900 | |
989 | |
901 | $self->add_stat_costs ($costs); |
990 | $self->add_stat_costs ($costs); |
902 | $self->add_special_costs ($costs); |
991 | $self->add_special_costs ($costs); |
903 | |
992 | |
… | |
… | |
950 | my ($obj, $nrof) = @_; |
1039 | my ($obj, $nrof) = @_; |
951 | |
1040 | |
952 | my $cnt; |
1041 | my $cnt; |
953 | |
1042 | |
954 | if (defined $nrof) { |
1043 | if (defined $nrof) { |
|
|
1044 | # TODO: Check tihis line: |
955 | return 0 if ($nrof * 1) == 0; |
1045 | return 0 if ($nrof * 1) == 0; #XXX: ??? |
956 | $cnt = int (($obj->nrof || 1) - (1 * $nrof)); |
1046 | $cnt = int (($obj->nrof || 1) - (1 * $nrof)); |
957 | |
1047 | |
958 | if ($cnt > 0) { |
1048 | if ($cnt > 0) { |
959 | $obj->nrof ($cnt); |
1049 | $obj->nrof ($cnt); |
960 | return 0; |
1050 | return 0; |
… | |
… | |
964 | remove ($_) for $obj->inv; |
1054 | remove ($_) for $obj->inv; |
965 | $obj->destroy; |
1055 | $obj->destroy; |
966 | return $cnt; |
1056 | return $cnt; |
967 | } |
1057 | } |
968 | |
1058 | |
969 | sub grep_for_match { |
1059 | sub check_for_match { |
970 | my ($thing, @matchar) = @_; |
1060 | my ($thing, @matchar) = @_; |
971 | |
1061 | |
972 | my $i = 0; |
1062 | my $i = 0; |
973 | for my $match (@matchar) { |
1063 | for my $match (@matchar) { |
974 | if ($match =~ m/^\s*$/) { |
1064 | if ($match =~ m/^\s*$/) { |
… | |
… | |
989 | $i++; |
1079 | $i++; |
990 | } |
1080 | } |
991 | return 0; |
1081 | return 0; |
992 | } |
1082 | } |
993 | |
1083 | |
|
|
1084 | sub grep_for_match { |
|
|
1085 | my ($ingred, $group, @matchar) = @_; |
|
|
1086 | |
|
|
1087 | for my $thing (@{$ingred->{$group} || []}) { |
|
|
1088 | warn sprintf "DEB:(%s,%s,%s)<->%s\n", $thing->name, $thing->title, $thing->arch->name, "@matchar"; #d# |
|
|
1089 | if (check_for_match ($thing, @matchar)) { |
|
|
1090 | return $thing; |
|
|
1091 | } |
|
|
1092 | } |
|
|
1093 | return undef; |
|
|
1094 | } |
|
|
1095 | |
994 | =back |
1096 | =back |
995 | |
1097 | |
996 | =back |
|
|
997 | |
|
|
998 | 1 |
1098 | 1 |