… | |
… | |
280 | my ($self, $arch_name, @map_stack) = @_; |
280 | my ($self, $arch_name, @map_stack) = @_; |
281 | |
281 | |
282 | my @c = |
282 | my @c = |
283 | grep { |
283 | grep { |
284 | $_->flag (cf::FLAG_IS_CAULDRON) |
284 | $_->flag (cf::FLAG_IS_CAULDRON) |
285 | and $_->arch->name eq $arch_name |
285 | and $_->arch->archname eq $arch_name |
286 | } @map_stack; |
286 | } @map_stack; |
287 | |
287 | |
288 | $self->{cauldron} = $c[0]; |
288 | $self->{cauldron} = $c[0]; |
289 | } |
289 | } |
290 | |
290 | |
… | |
… | |
398 | |
398 | |
399 | sub value { |
399 | sub value { |
400 | my ($self, $group, $archname) = @_; |
400 | my ($self, $group, $archname) = @_; |
401 | |
401 | |
402 | my @objs = grep { |
402 | my @objs = grep { |
403 | $_->arch->name eq $archname |
403 | $_->arch->archname eq $archname |
404 | } @{$self->{ingredients}->{$group} || []}; |
404 | } @{$self->{ingredients}->{$group} || []}; |
405 | |
405 | |
406 | my $sum = 0; |
406 | my $sum = 0; |
407 | for (@objs) { |
407 | for (@objs) { |
408 | $sum += ($_->nrof || 1) * $_->value; |
408 | $sum += ($_->nrof || 1) * $_->value; |
… | |
… | |
425 | |
425 | |
426 | my @out; |
426 | my @out; |
427 | |
427 | |
428 | for (@{$ingred->{$group}}) { |
428 | for (@{$ingred->{$group}}) { |
429 | if (defined $archname) { |
429 | if (defined $archname) { |
430 | if ($_->arch->name eq $archname) { |
430 | if ($_->arch->archname eq $archname) { |
431 | Jeweler::Util::remove ($_); |
431 | Jeweler::Util::remove ($_); |
432 | } else { |
432 | } else { |
433 | push @out, $_; |
433 | push @out, $_; |
434 | } |
434 | } |
435 | } else { |
435 | } else { |
… | |
… | |
783 | $obj->{spec}{ac} = $stats->ac; |
783 | $obj->{spec}{ac} = $stats->ac; |
784 | $obj->{spec}{speed} = $stats->exp; |
784 | $obj->{spec}{speed} = $stats->exp; |
785 | $obj->{spec}{food} = $stats->food; |
785 | $obj->{spec}{food} = $stats->food; |
786 | |
786 | |
787 | $obj->{name} = $thing->name; |
787 | $obj->{name} = $thing->name; |
788 | $obj->{arch} = $thing->arch->name; |
788 | $obj->{arch} = $thing->arch->archname; |
789 | $obj->{face} = $thing->face; |
789 | $obj->{face} = $thing->face; |
790 | |
790 | |
791 | $obj->{value} = $thing->value; |
791 | $obj->{value} = $thing->value; |
792 | |
792 | |
793 | $self->{hash} = $obj |
793 | $self->{hash} = $obj |
… | |
… | |
1103 | and $check_true++; |
1103 | and $check_true++; |
1104 | } elsif ($i % 3 == 1) { |
1104 | } elsif ($i % 3 == 1) { |
1105 | $thing->title eq $match |
1105 | $thing->title eq $match |
1106 | and $check_true++; |
1106 | and $check_true++; |
1107 | } else { # $i % 3 == 2 |
1107 | } else { # $i % 3 == 2 |
1108 | $thing->arch->name eq $match |
1108 | $thing->arch->archname eq $match |
1109 | and $check_true++; |
1109 | and $check_true++; |
1110 | } |
1110 | } |
1111 | $i++; |
1111 | $i++; |
1112 | } |
1112 | } |
1113 | #d# warn "CHECK $check_true | $check_cnts | [".(join ',', @matchar).":".join (",", ($thing->name, $thing->title, $thing->arch->name))."\n"; |
1113 | #d# warn "CHECK $check_true | $check_cnts | [".(join ',', @matchar).":".join (",", ($thing->name, $thing->title, $thing->arch->archname))."\n"; |
1114 | return 1 if $check_true && $check_cnts == $check_true; |
1114 | return 1 if $check_true && $check_cnts == $check_true; |
1115 | return 0; |
1115 | return 0; |
1116 | } |
1116 | } |
1117 | |
1117 | |
1118 | sub grep_for_match { |
1118 | sub grep_for_match { |
1119 | my ($ingred, $group, @matchar) = @_; |
1119 | my ($ingred, $group, @matchar) = @_; |
1120 | |
1120 | |
1121 | for my $thing (@{$ingred->{$group} || []}) { |
1121 | for my $thing (@{$ingred->{$group} || []}) { |
1122 | #d# warn sprintf "DEB:(%s,%s,%s)<->%s\n", $thing->name, $thing->title, $thing->arch->name, "@matchar"; #d# |
1122 | #d# warn sprintf "DEB:(%s,%s,%s)<->%s\n", $thing->name, $thing->title, $thing->arch->archname, "@matchar"; #d# |
1123 | if (check_for_match ($thing, @matchar)) { |
1123 | if (check_for_match ($thing, @matchar)) { |
1124 | return $thing; |
1124 | return $thing; |
1125 | } |
1125 | } |
1126 | } |
1126 | } |
1127 | return undef; |
1127 | return undef; |