… | |
… | |
24 | our $CFG; |
24 | our $CFG; |
25 | |
25 | |
26 | sub read_config { |
26 | sub read_config { |
27 | my ($filename) = @_; |
27 | my ($filename) = @_; |
28 | |
28 | |
29 | unless (-e $filename) { |
29 | if (my $meta = $cf::RESOURCE{$filename}) { |
|
|
30 | $CFG = cf::decode_json $meta->{data}; |
|
|
31 | } else { |
30 | warn "$filename doesn't exists! no config for jeweler skill loaded!\n"; |
32 | warn "$filename doesn't exist! no config for jeweler skill loaded!\n"; |
31 | $CFG = {}; |
33 | $CFG = {}; |
32 | return |
|
|
33 | } |
34 | } |
34 | |
|
|
35 | $CFG = YAML::LoadFile $filename; |
|
|
36 | } |
35 | } |
37 | |
36 | |
38 | sub getcfg { |
37 | sub getcfg { |
39 | my ($sect, $key) = @_; |
38 | my ($sect, $key) = @_; |
40 | return $CFG->{$sect} unless defined $key; |
39 | return $CFG->{$sect} unless defined $key; |
… | |
… | |
165 | |
164 | |
166 | sub analyze { |
165 | sub analyze { |
167 | my ($sk, $chdl, $pl, $input_level) = @_; |
166 | my ($sk, $chdl, $pl, $input_level) = @_; |
168 | |
167 | |
169 | my $hadunid = 0; |
168 | my $hadunid = 0; |
|
|
169 | my $found = 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 | $found = 1; |
175 | my $r = Jeweler::Object->new (object => $_); |
176 | my $r = Jeweler::Object->new (object => $_); |
176 | my $msg = $r->analyze ($sk, $pl, $input_level); |
177 | my $msg = $r->analyze ($sk, $pl, $input_level); |
177 | $pl->message ($r->to_string . ": " . $msg); |
178 | $pl->message ($r->to_string . ": " . $msg); |
178 | if ($pl->flag (cf::FLAG_WIZ)) { |
179 | if ($pl->flag (cf::FLAG_WIZ)) { |
179 | $r->wiz_analyze ($pl); |
180 | $r->wiz_analyze ($pl); |
180 | } |
181 | } |
181 | } |
182 | } |
182 | $pl->message ("You couldn't identify the other rings and not analyze them!") |
183 | $pl->message ("You couldn't identify the other rings and not analyze them!") |
183 | if $hadunid; |
184 | if $hadunid; |
|
|
185 | $pl->message ("You couldn't find anything in the bench to analyse!") |
|
|
186 | unless $found; |
184 | } |
187 | } |
185 | |
188 | |
186 | # this function converts metals/minerals into a raw ring (of adornment) |
189 | # this function converts metals/minerals into a raw ring (of adornment) |
187 | sub simple_converter { |
190 | sub simple_converter { |
188 | my ($pl, $ingred, $chdl, $conv) = @_; |
191 | my ($pl, $ingred, $chdl, $conv) = @_; |
… | |
… | |
716 | if (defined $costs) { |
719 | if (defined $costs) { |
717 | my $desc = ""; |
720 | my $desc = ""; |
718 | my $lvl = $self->power_to_level (\$desc); |
721 | my $lvl = $self->power_to_level (\$desc); |
719 | my $scosts = $self->calc_value_from_cost ($costs); |
722 | my $scosts = $self->calc_value_from_cost ($costs); |
720 | |
723 | |
721 | $pl->message ("costs: " . (join (', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs)) . " (".($scosts / 5000)." royalties)"); |
724 | $pl->message ("costs: " |
|
|
725 | . (join ', ', map { "$_: " . sprintf "%.2f", $costs->{$_} } keys %$costs) |
|
|
726 | . " (" |
|
|
727 | . ($scosts / "royalty"->cf::arch::find->value) |
|
|
728 | . " royalties)"); |
722 | $pl->message ("level: " . $desc); |
729 | $pl->message ("level: $desc"); |
723 | } else { |
730 | } else { |
724 | $pl->message ("level: impossible to make, due to impossible resistancy configuration"); |
731 | $pl->message ("level: impossible to make, due to impossible resistancy configuration"); |
725 | } |
732 | } |
726 | } |
733 | } |
727 | |
734 | |