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