… | |
… | |
162 | $delta = 5 if $delta > 5; |
162 | $delta = 5 if $delta > 5; |
163 | return $LVL_DIFF_CHANCES{$delta} |
163 | return $LVL_DIFF_CHANCES{$delta} |
164 | } |
164 | } |
165 | |
165 | |
166 | sub analyze { |
166 | sub analyze { |
167 | my ($sk, $chdl, $pl) = @_; |
167 | my ($sk, $chdl, $pl, $input_level) = @_; |
168 | |
168 | |
169 | my $hadunid = 0; |
169 | my $hadunid = 0; |
170 | for ($chdl->grep_by_type (cf::RING, cf::AMULET)) { |
170 | for ($chdl->grep_by_type (cf::RING, cf::AMULET)) { |
171 | if (!$_->flag (cf::FLAG_IDENTIFIED) && $_->need_identify) { |
171 | if (!$_->flag (cf::FLAG_IDENTIFIED) && $_->need_identify) { |
172 | $hadunid = 1; |
172 | $hadunid = 1; |
173 | next; |
173 | next; |
174 | } |
174 | } |
175 | my $r = Jeweler::Object->new (object => $_); |
175 | my $r = Jeweler::Object->new (object => $_); |
176 | my $msg = $r->analyze ($sk, $pl); |
176 | my $msg = $r->analyze ($sk, $pl, $input_level); |
177 | $pl->message ($r->to_string . ": " . $msg); |
177 | $pl->message ($r->to_string . ": " . $msg); |
178 | if ($pl->flag (cf::FLAG_WIZ)) { |
178 | if ($pl->flag (cf::FLAG_WIZ)) { |
179 | $r->wiz_analyze ($pl); |
179 | $r->wiz_analyze ($pl); |
180 | } |
180 | } |
181 | } |
181 | } |
182 | if ($hadunid) { |
|
|
183 | $pl->message ("You couldn't identify the other rings and not analyze them!"); |
182 | $pl->message ("You couldn't identify the other rings and not analyze them!") |
184 | } |
183 | if $hadunid; |
185 | } |
184 | } |
186 | |
185 | |
187 | # this function converts metals/minerals into a raw ring (of adornment) |
186 | # this function converts metals/minerals into a raw ring (of adornment) |
188 | sub simple_converter { |
187 | sub simple_converter { |
189 | my ($pl, $ingred, $chdl, $conv) = @_; |
188 | my ($pl, $ingred, $chdl, $conv) = @_; |
… | |
… | |
203 | warn "ERROR: Conversion for '$outarch' has only " . (@conv_cfg) . " arguments!"; |
202 | warn "ERROR: Conversion for '$outarch' has only " . (@conv_cfg) . " arguments!"; |
204 | return; |
203 | return; |
205 | } |
204 | } |
206 | |
205 | |
207 | unless ($xp_gain > 0) { |
206 | unless ($xp_gain > 0) { |
208 | warn "WARNING: xp gain isn't > 0 in convesion '$outarch'\n"; |
207 | warn "WARNING: xp gain isn't > 0 in conversion '$outarch'\n"; |
209 | return; |
208 | return; |
210 | } |
209 | } |
211 | |
210 | |
212 | unless ($outarchvalfact) { |
211 | unless ($outarchvalfact) { |
213 | warn "ERROR: source-arch-value-multiplier == 0 in conversion '$outarch'\n"; |
212 | warn "ERROR: source-arch-value-multiplier == 0 in conversion '$outarch'\n"; |
… | |
… | |
219 | } |
218 | } |
220 | |
219 | |
221 | my $archvalsum = $ingred->value ($ingr_grp, $srcarchname); |
220 | my $archvalsum = $ingred->value ($ingr_grp, $srcarchname); |
222 | $ingred->remove ($ingr_grp, $srcarchname); |
221 | $ingred->remove ($ingr_grp, $srcarchname); |
223 | |
222 | |
224 | my $outarchval = cf::arch::find ($outarch)->clone->value; |
223 | my $outarchval = cf::arch::find ($outarch)->value; |
225 | |
224 | |
226 | my $nrof = int ($archvalsum / (($outarchval || 1000) * $outarchvalfact)); |
225 | my $nrof = int $archvalsum / (($outarchval || 1000) * $outarchvalfact); |
227 | if ($nrof) { |
226 | 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) |
227 | # XXX: yes, I know what I'm doing here, I don't set nrof, but it didn't work somehow (pls. check sometimes) |
229 | for (1..$nrof) { |
228 | for (1 .. $nrof) { |
230 | $chdl->put (my $ob = cf::object::new $outarch); |
229 | $chdl->put (my $ob = cf::object::new $outarch); |
231 | $ob->set_animation (cf::rndm $ob->num_animations) |
230 | $ob->set_animation (cf::rndm $ob->num_animations) |
232 | if ($ob->type == cf::RING); |
231 | if ($ob->type == cf::RING); |
233 | $ob->flag (cf::FLAG_IDENTIFIED, 1); |
232 | $ob->flag (cf::FLAG_IDENTIFIED, 1); |
234 | } |
233 | } |
235 | |
234 | |
236 | my $xp_sum = ($xp_gain * $nrof); |
235 | my $xp_sum = $xp_gain * $nrof; |
237 | |
236 | |
238 | if ($xp_sum) { |
237 | if ($xp_sum) { |
239 | $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"); |
240 | $pl->ob->change_exp ($xp_sum, "jeweler", cf::SK_EXP_SKILL_ONLY); |
239 | $pl->ob->change_exp ($xp_sum, "jeweler", cf::SK_EXP_SKILL_ONLY); |
241 | } |
240 | } |
242 | } else { |
241 | } else { |
243 | $pl->ob->message ("You fail to make something, propably you used not enough source material?"); |
242 | $pl->ob->message ("You fail to make something, probably you used not enough source material?"); |
244 | } |
243 | } |
245 | } |
244 | } |
246 | |
245 | |
247 | |
246 | |
248 | package Jeweler::CauldronHandler; |
247 | package Jeweler::CauldronHandler; |
… | |
… | |
280 | my ($self, $arch_name, @map_stack) = @_; |
279 | my ($self, $arch_name, @map_stack) = @_; |
281 | |
280 | |
282 | my @c = |
281 | my @c = |
283 | grep { |
282 | grep { |
284 | $_->flag (cf::FLAG_IS_CAULDRON) |
283 | $_->flag (cf::FLAG_IS_CAULDRON) |
285 | and $_->arch->name eq $arch_name |
284 | and $_->arch->archname eq $arch_name |
286 | } @map_stack; |
285 | } @map_stack; |
287 | |
286 | |
288 | $self->{cauldron} = $c[0]; |
287 | $self->{cauldron} = $c[0]; |
289 | } |
288 | } |
290 | |
289 | |
… | |
… | |
355 | |
354 | |
356 | sub put { |
355 | sub put { |
357 | my ($self, $obj) = @_; |
356 | my ($self, $obj) = @_; |
358 | |
357 | |
359 | return undef unless $self->{cauldron}; |
358 | return undef unless $self->{cauldron}; |
360 | $obj->insert_ob_in_ob ($self->{cauldron}); |
359 | $self->{cauldron}->insert ($obj); |
361 | } |
360 | } |
362 | |
361 | |
363 | =back |
362 | =back |
364 | |
363 | |
365 | =cut |
364 | =cut |
… | |
… | |
398 | |
397 | |
399 | sub value { |
398 | sub value { |
400 | my ($self, $group, $archname) = @_; |
399 | my ($self, $group, $archname) = @_; |
401 | |
400 | |
402 | my @objs = grep { |
401 | my @objs = grep { |
403 | $_->arch->name eq $archname |
402 | $_->arch->archname eq $archname |
404 | } @{$self->{ingredients}->{$group} || []}; |
403 | } @{$self->{ingredients}->{$group} || []}; |
405 | |
404 | |
406 | my $sum = 0; |
405 | my $sum = 0; |
407 | for (@objs) { |
406 | for (@objs) { |
408 | $sum += ($_->nrof || 1) * $_->value; |
407 | $sum += ($_->nrof || 1) * $_->value; |
… | |
… | |
425 | |
424 | |
426 | my @out; |
425 | my @out; |
427 | |
426 | |
428 | for (@{$ingred->{$group}}) { |
427 | for (@{$ingred->{$group}}) { |
429 | if (defined $archname) { |
428 | if (defined $archname) { |
430 | if ($_->arch->name eq $archname) { |
429 | if ($_->arch->archname eq $archname) { |
431 | Jeweler::Util::remove ($_); |
430 | Jeweler::Util::remove ($_); |
432 | } else { |
431 | } else { |
433 | push @out, $_; |
432 | push @out, $_; |
434 | } |
433 | } |
435 | } else { |
434 | } else { |
… | |
… | |
477 | } |
476 | } |
478 | |
477 | |
479 | sub improve_ring_by_plan { |
478 | sub improve_ring_by_plan { |
480 | my ($self, $plan, $ring) = @_; |
479 | my ($self, $plan, $ring) = @_; |
481 | |
480 | |
482 | $ring = dclone ($ring); |
481 | $ring = do { my $guard = Coro::Storable::guard; dclone $ring }; |
483 | |
482 | |
484 | my $ingred = $self->{ingredients}; |
483 | my $ingred = $self->{ingredients}; |
485 | my $impr = {}; |
484 | my $impr = {}; |
486 | |
485 | |
487 | if ($plan =~ m/^stat_(\S+)$/) { |
486 | if ($plan =~ m/^stat_(\S+)$/) { |
… | |
… | |
571 | } |
570 | } |
572 | |
571 | |
573 | sub check_costs { |
572 | sub check_costs { |
574 | my ($self, $costs, $do_remove) = @_; |
573 | my ($self, $costs, $do_remove) = @_; |
575 | |
574 | |
576 | my $costs = dclone ($costs); |
575 | my $costs = do { my $guard = Coro::Storable::guard; dclone $costs }; |
577 | |
576 | |
578 | for my $key (keys %$costs) { |
577 | for my $key (keys %$costs) { |
579 | my @grepar; |
578 | my @grepar; |
580 | if ($key =~ m/^(resist_|spec_|stat_)/) { # check the special items |
579 | if ($key =~ m/^(resist_|spec_|stat_)/) { # check the special items |
581 | eval { @grepar = @{Jeweler::getcfg (plans => $key) || []} }; |
580 | eval { @grepar = @{Jeweler::getcfg (plans => $key) || []} }; |
… | |
… | |
641 | return 1 if $self->{hash}->{resist}->{$resnum}; |
640 | return 1 if $self->{hash}->{resist}->{$resnum}; |
642 | } |
641 | } |
643 | return undef; |
642 | return undef; |
644 | } |
643 | } |
645 | |
644 | |
|
|
645 | sub projected_exp { |
|
|
646 | my ($self, $input_level) = @_; |
|
|
647 | |
|
|
648 | my $lvl = max ($self->power_to_level, 1); |
|
|
649 | my $exp = |
|
|
650 | (cf::level_to_min_exp ($lvl) - cf::level_to_min_exp ($lvl - 1)) |
|
|
651 | / (10 + max ($lvl - 1, 0)); # 10 + level times making such a ring |
|
|
652 | # should get you to the rings level at least. |
|
|
653 | |
|
|
654 | if (defined $input_level) { |
|
|
655 | my $subexp = |
|
|
656 | (cf::level_to_min_exp ($input_level) |
|
|
657 | - cf::level_to_min_exp ($input_level - 1)) |
|
|
658 | / (10 + max ($input_level - 1, 0)); # see above for comment |
|
|
659 | |
|
|
660 | $exp -= $subexp; |
|
|
661 | $exp = max ($exp, 0); |
|
|
662 | |
|
|
663 | } else { |
|
|
664 | # the experience bonus here is to make level 1 rings give you at least |
|
|
665 | # 100 exp points when making them. This also makes leveling in the |
|
|
666 | # first few levels a bit easier. (probably until around level 5-6). |
|
|
667 | my $expbonus = cf::level_to_min_exp (2) / 10; |
|
|
668 | # this bonus should also only be given for _new_ rings and not for merged |
|
|
669 | # ones - to prevent infinite exp making. |
|
|
670 | $exp += $expbonus; |
|
|
671 | } |
|
|
672 | |
|
|
673 | $exp |
|
|
674 | } |
|
|
675 | |
646 | sub analyze { |
676 | sub analyze { |
647 | my ($self, $sk, $pl) = @_; |
677 | my ($self, $sk, $pl, $input_level) = @_; |
|
|
678 | my $costs = $self->calc_costs; |
|
|
679 | |
|
|
680 | unless (defined $costs) { |
|
|
681 | return "This ring has a resistancy above 99%, you can't make that."; |
|
|
682 | } |
648 | |
683 | |
649 | my $sklvl = cf::exp_to_level ($sk->stats->exp); |
684 | my $sklvl = cf::exp_to_level ($sk->stats->exp); |
650 | my $ringlvl = $self->power_to_level; |
685 | my $ringlvl = $self->power_to_level; |
651 | |
686 | |
652 | my $tmpl; |
687 | my $tmpl; |
653 | if ($pl->flag (cf::FLAG_WIZ)) { |
688 | if ($pl->flag (cf::FLAG_WIZ)) { |
654 | $tmpl = Jeweler::level_diff_to_chance_perc ($sklvl - $ringlvl); |
689 | $tmpl = Jeweler::level_diff_to_chance_perc ($sklvl - $ringlvl); |
655 | } else { |
690 | } else { |
656 | $tmpl = Jeweler::level_diff_to_str ($sklvl - $ringlvl); |
691 | $tmpl = Jeweler::level_diff_to_str ($sklvl - $ringlvl); |
657 | } |
692 | } |
658 | my $msg = sprintf "Projected success rate: %s", $tmpl; |
693 | my $msg = sprintf "Projected success rate: %s, you would get %d exp for this.", $tmpl, $self->projected_exp ($input_level); |
659 | return $msg; |
694 | return $msg; |
660 | } |
695 | } |
661 | |
696 | |
662 | sub calc_value_from_cost { |
697 | sub calc_value_from_cost { |
663 | my ($self, $costs) = @_; |
698 | my ($self, $costs) = @_; |
664 | my $emarch = cf::arch::find 'emerald'; |
699 | my $emarch = cf::arch::find 'emerald'; |
665 | my $saarch = cf::arch::find 'sapphire'; |
700 | my $saarch = cf::arch::find 'sapphire'; |
666 | my $pearch = cf::arch::find 'pearl'; |
701 | my $pearch = cf::arch::find 'pearl'; |
667 | my $ruarch = cf::arch::find 'ruby'; |
702 | my $ruarch = cf::arch::find 'ruby'; |
668 | my $diarch = cf::arch::find 'gem'; |
703 | my $diarch = cf::arch::find 'gem'; |
669 | my $value = $emarch->clone->value * $costs->{emerald} |
704 | my $value = $emarch->value * $costs->{emerald} |
670 | + $saarch->clone->value * $costs->{sapphire} |
705 | + $saarch->value * $costs->{sapphire} |
671 | + $pearch->clone->value * $costs->{pearl} |
706 | + $pearch->value * $costs->{pearl} |
672 | + $ruarch->clone->value * $costs->{ruby} |
707 | + $ruarch->value * $costs->{ruby} |
673 | + $diarch->clone->value * $costs->{gem}; |
708 | + $diarch->value * $costs->{gem}; |
674 | |
709 | |
675 | $value |
710 | $value |
676 | } |
711 | } |
677 | |
712 | |
678 | sub wiz_analyze { |
713 | sub wiz_analyze { |
679 | my ($self, $pl) = @_; |
714 | my ($self, $pl) = @_; |
680 | my $costs = $self->calc_costs; |
715 | my $costs = $self->calc_costs; |
|
|
716 | if (defined $costs) { |
681 | my $desc = ""; |
717 | my $desc = ""; |
682 | my $lvl = $self->power_to_level (\$desc); |
718 | my $lvl = $self->power_to_level (\$desc); |
683 | my $scosts = $self->calc_value_from_cost ($costs); |
719 | my $scosts = $self->calc_value_from_cost ($costs); |
684 | |
720 | |
685 | $pl->message ("costs: " . (join (', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs)) . " (".($scosts / 5000)." royalties)"); |
721 | $pl->message ("costs: " . (join (', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs)) . " (".($scosts / 5000)." royalties)"); |
686 | $pl->message ("level: " . $desc); |
722 | $pl->message ("level: " . $desc); |
|
|
723 | } else { |
|
|
724 | $pl->message ("level: impossible to make, due to impossible resistancy configuration"); |
|
|
725 | } |
687 | } |
726 | } |
688 | |
727 | |
689 | sub get_chance_perc { |
728 | sub get_chance_perc { |
690 | my ($self, $sk) = @_; |
729 | my ($self, $sk) = @_; |
691 | my $sklvl = cf::exp_to_level ($sk->stats->exp); |
730 | my $sklvl = cf::exp_to_level ($sk->stats->exp); |
… | |
… | |
696 | sub fx { |
735 | sub fx { |
697 | my ($res, $cfg) = @_; |
736 | my ($res, $cfg) = @_; |
698 | my $or = $res; |
737 | my $or = $res; |
699 | my $ar = $Jeweler::CFG->{functions}->{$cfg}; |
738 | my $ar = $Jeweler::CFG->{functions}->{$cfg}; |
700 | |
739 | |
701 | if (ref $ar->[0] eq 'ARRAY') { |
740 | if (ref $ar && ref $ar->[0] eq 'ARRAY') { |
702 | $res = $res - 1; |
741 | $res = $res - 1; |
703 | return $ar->[max (min ($res, @$ar - 1), 0)]; |
742 | return $ar->[max (min ($res, @$ar - 1), 0)]; |
704 | |
743 | |
705 | } else { |
744 | } else { |
706 | # +0.1 is for a jump to the next index when $res / 5 is exactly 1, 2, 3... |
745 | # +0.1 is for a jump to the next index when $res / 5 is exactly 1, 2, 3... |
|
|
746 | # old code: |
707 | my $idx = ceil (($res / 5) + 0.1) - 1; |
747 | #my $idx = ceil (($res / 5) + 0.1) - 1; |
708 | my $a = $ar->[max (min ($idx, @$ar - 1), 0)]; |
748 | #my $a = $ar->[max (min ($idx, @$ar - 1), 0)]; |
709 | my $b = $ar->[max (min ($idx + 1, @$ar - 1), 0)]; |
749 | #my $b = $ar->[max (min ($idx + 1, @$ar - 1), 0)]; |
710 | my $diff = $b - $a; # use the difference of the cost to the next cost |
750 | #my $diff = $b - $a; # use the difference of the cost to the next cost |
711 | my $o_cost = $a + ($diff / 5) * ($res % 5); # and do some linear interpolation |
751 | #my $o_cost = $a + ($diff / 5) * ($res % 5); # and do some linear interpolation |
712 | return $o_cost; |
752 | #return $o_cost; |
|
|
753 | return 0 if $res <= 0; |
|
|
754 | return ($ar / (1 - ($res * 0.01)) - $ar) |
713 | } |
755 | } |
714 | } |
756 | } |
715 | |
757 | |
716 | sub improve_by_ring { |
758 | sub improve_by_ring { |
717 | my ($self, @rings) = @_; |
759 | my ($self, @rings) = @_; |
… | |
… | |
783 | $obj->{spec}{ac} = $stats->ac; |
825 | $obj->{spec}{ac} = $stats->ac; |
784 | $obj->{spec}{speed} = $stats->exp; |
826 | $obj->{spec}{speed} = $stats->exp; |
785 | $obj->{spec}{food} = $stats->food; |
827 | $obj->{spec}{food} = $stats->food; |
786 | |
828 | |
787 | $obj->{name} = $thing->name; |
829 | $obj->{name} = $thing->name; |
788 | $obj->{arch} = $thing->arch->name; |
830 | $obj->{arch} = $thing->arch->archname; |
789 | $obj->{face} = $thing->face; |
831 | $obj->{face} = $thing->face; |
790 | |
832 | |
791 | $obj->{value} = $thing->value; |
833 | $obj->{value} = $thing->value; |
792 | |
834 | |
793 | $self->{hash} = $obj |
835 | $self->{hash} = $obj |
… | |
… | |
796 | sub to_object { |
838 | sub to_object { |
797 | my ($self) = @_; |
839 | my ($self) = @_; |
798 | |
840 | |
799 | my $obj = cf::object::new $self->{hash}->{arch}; |
841 | my $obj = cf::object::new $self->{hash}->{arch}; |
800 | |
842 | |
801 | $obj->item_power ($self->power_to_level); # there have to be strings attached! |
843 | $obj->item_power (floor ($self->power_to_level / 3)); # there have to be strings attached! |
802 | |
844 | |
803 | $obj->face ($self->{hash}{face}); |
845 | $obj->face ($self->{hash}{face}); |
804 | |
846 | |
805 | my $stats = $obj->stats; |
847 | my $stats = $obj->stats; |
806 | |
848 | |
… | |
… | |
996 | |
1038 | |
997 | my $res = $ring->{resist}->{$resnum}; |
1039 | my $res = $ring->{resist}->{$resnum}; |
998 | |
1040 | |
999 | next unless $res > 0; |
1041 | next unless $res > 0; |
1000 | |
1042 | |
|
|
1043 | return undef if $res == 100; |
|
|
1044 | |
1001 | $costs->{"resist_" . $Jeweler::RESMAP{$resnum}} += $res; |
1045 | $costs->{"resist_" . $Jeweler::RESMAP{$resnum}} += $res; |
1002 | |
1046 | |
1003 | my $diamonds; |
1047 | my $diamonds; |
1004 | if (grep { $resnum eq $_ } @Jeweler::EFFECT_RESISTS) { |
1048 | if (grep { $resnum eq $_ } @Jeweler::EFFECT_RESISTS) { |
1005 | $diamonds += fx ($res, 'effect_resist_diamonds'); |
1049 | $diamonds += fx ($res, 'effect_resist_diamonds_x'); |
1006 | } else { |
1050 | } else { |
1007 | $diamonds += fx ($res, 'attack_resist_diamonds'); |
1051 | $diamonds += fx ($res, 'attack_resist_diamonds_x'); |
1008 | } |
1052 | } |
1009 | |
1053 | |
1010 | split_diamonds ($costs, $diamonds, 'resist_' . $Jeweler::RESMAP{$resnum}); |
1054 | split_diamonds ($costs, $diamonds, 'resist_' . $Jeweler::RESMAP{$resnum}); |
1011 | } |
1055 | } |
1012 | |
1056 | |
… | |
… | |
1020 | my ($cost, $diamonds, $category) = @_; |
1064 | my ($cost, $diamonds, $category) = @_; |
1021 | |
1065 | |
1022 | my $stat_split = Jeweler::getcfg (diamond_split => $category); |
1066 | my $stat_split = Jeweler::getcfg (diamond_split => $category); |
1023 | |
1067 | |
1024 | my $sum = sum (@$stat_split); |
1068 | my $sum = sum (@$stat_split); |
1025 | if ($sum < (1 - 0.0001)) { |
|
|
1026 | warn "JEWELER BUG: sum (@$stat_split) = $sum < 1 for $category!"; |
|
|
1027 | } |
|
|
1028 | |
1069 | |
1029 | my $emarch = cf::arch::find 'emerald'; |
1070 | my $emarch = cf::arch::find 'emerald'; |
1030 | my $saarch = cf::arch::find 'sapphire'; |
1071 | my $saarch = cf::arch::find 'sapphire'; |
1031 | my $pearch = cf::arch::find 'pearl'; |
1072 | my $pearch = cf::arch::find 'pearl'; |
1032 | my $ruarch = cf::arch::find 'ruby'; |
1073 | my $ruarch = cf::arch::find 'ruby'; |
1033 | my $diarch = cf::arch::find 'gem'; |
1074 | my $diarch = cf::arch::find 'gem'; |
1034 | |
1075 | |
1035 | my $sumvalue = $diarch->clone->value * $diamonds; |
1076 | my $sumvalue = $diarch->value * $diamonds; |
1036 | |
1077 | |
1037 | $cost->{emerald} += ceil $sumvalue * $stat_split->[0] / max 1, $emarch->clone->value; |
1078 | $cost->{emerald} += ceil $sumvalue * $stat_split->[0] / max 1, $emarch->value; |
1038 | $cost->{sapphire} += ceil $sumvalue * $stat_split->[1] / max 1, $saarch->clone->value; |
1079 | $cost->{sapphire} += ceil $sumvalue * $stat_split->[1] / max 1, $saarch->value; |
1039 | $cost->{pearl} += ceil $sumvalue * $stat_split->[2] / max 1, $pearch->clone->value; |
1080 | $cost->{pearl} += ceil $sumvalue * $stat_split->[2] / max 1, $pearch->value; |
1040 | $cost->{ruby} += ceil $sumvalue * $stat_split->[3] / max 1, $ruarch->clone->value; |
1081 | $cost->{ruby} += ceil $sumvalue * $stat_split->[3] / max 1, $ruarch->value; |
1041 | $cost->{gem} += ceil $sumvalue * $stat_split->[4] / max 1, $diarch->clone->value; |
1082 | $cost->{gem} += ceil $sumvalue * $stat_split->[4] / max 1, $diarch->value; |
1042 | } |
1083 | } |
1043 | |
1084 | |
1044 | package Jeweler::Util; |
1085 | package Jeweler::Util; |
1045 | |
1086 | |
1046 | use strict; |
1087 | use strict; |
… | |
… | |
1085 | my $i = 0; |
1126 | my $i = 0; |
1086 | my $check_cnts = 0; |
1127 | my $check_cnts = 0; |
1087 | my $check_true = 0; |
1128 | my $check_true = 0; |
1088 | for my $match (@matchar) { |
1129 | for my $match (@matchar) { |
1089 | if ($i % 3 == 0) { |
1130 | if ($i % 3 == 0) { |
|
|
1131 | return 1 if $check_true && $check_cnts == $check_true; |
1090 | $check_cnts = 0; |
1132 | $check_cnts = 0; |
1091 | $check_true = 0; |
1133 | $check_true = 0; |
1092 | } |
1134 | } |
1093 | |
1135 | |
1094 | if ($match =~ m/^\s*$/) { |
1136 | if ($match =~ m/^\s*$/) { |
… | |
… | |
1102 | and $check_true++; |
1144 | and $check_true++; |
1103 | } elsif ($i % 3 == 1) { |
1145 | } elsif ($i % 3 == 1) { |
1104 | $thing->title eq $match |
1146 | $thing->title eq $match |
1105 | and $check_true++; |
1147 | and $check_true++; |
1106 | } else { # $i % 3 == 2 |
1148 | } else { # $i % 3 == 2 |
1107 | $thing->arch->name eq $match |
1149 | $thing->arch->archname eq $match |
1108 | and $check_true++; |
1150 | and $check_true++; |
1109 | } |
1151 | } |
1110 | $i++; |
1152 | $i++; |
1111 | } |
1153 | } |
1112 | #d# warn "CHECK $check_true | $check_cnts | [".(join ',', @matchar).":".join (",", ($thing->name, $thing->title, $thing->arch->name))."\n"; |
1154 | #d# warn "CHECK $check_true | $check_cnts | [".(join ',', @matchar).":".join (",", ($thing->name, $thing->title, $thing->arch->archname))."\n"; |
1113 | if ($check_true && $check_cnts == $check_true) { |
1155 | return 1 if $check_true && $check_cnts == $check_true; |
1114 | return 1; |
|
|
1115 | } |
|
|
1116 | return 0; |
1156 | return 0; |
1117 | } |
1157 | } |
1118 | |
1158 | |
1119 | sub grep_for_match { |
1159 | sub grep_for_match { |
1120 | my ($ingred, $group, @matchar) = @_; |
1160 | my ($ingred, $group, @matchar) = @_; |
1121 | |
1161 | |
1122 | for my $thing (@{$ingred->{$group} || []}) { |
1162 | for my $thing (@{$ingred->{$group} || []}) { |
1123 | #d# warn sprintf "DEB:(%s,%s,%s)<->%s\n", $thing->name, $thing->title, $thing->arch->name, "@matchar"; #d# |
1163 | #d# warn sprintf "DEB:(%s,%s,%s)<->%s\n", $thing->name, $thing->title, $thing->arch->archname, "@matchar"; #d# |
1124 | if (check_for_match ($thing, @matchar)) { |
1164 | if (check_for_match ($thing, @matchar)) { |
1125 | return $thing; |
1165 | return $thing; |
1126 | } |
1166 | } |
1127 | } |
1167 | } |
1128 | return undef; |
1168 | return undef; |