… | |
… | |
20 | |
20 | |
21 | =cut |
21 | =cut |
22 | |
22 | |
23 | our $CFG; |
23 | our $CFG; |
24 | |
24 | |
25 | sub read_config { |
25 | sub load_config { |
26 | my ($filename) = @_; |
26 | cf::trace "loading jeweler config from $cf::DATADIR/jeweler\n"; |
27 | |
27 | |
28 | if (my $meta = $cf::RESOURCE{$filename}) { |
28 | 0 < Coro::AIO::aio_load "$cf::DATADIR/jeweler", my $data |
|
|
29 | or die "$cf::DATADIR/jeweler: $!"; |
|
|
30 | |
29 | $CFG = cf::decode_json $meta->{data}; |
31 | $CFG = cf::decode_json $data; |
30 | } else { |
|
|
31 | warn "$filename doesn't exist! no config for jeweler skill loaded!\n"; |
|
|
32 | $CFG = {}; |
|
|
33 | } |
|
|
34 | } |
32 | } |
35 | |
33 | |
36 | sub getcfg { |
34 | sub getcfg { |
37 | my ($sect, $key) = @_; |
35 | my ($sect, $key) = @_; |
38 | return $CFG->{$sect} unless defined $key; |
36 | return $CFG->{$sect} unless defined $key; |
… | |
… | |
251 | } |
249 | } |
252 | |
250 | |
253 | |
251 | |
254 | package Jeweler::CauldronHandler; |
252 | package Jeweler::CauldronHandler; |
255 | |
253 | |
256 | use strict; |
254 | use common::sense; |
257 | |
255 | |
258 | =head2 CauldronHandler |
256 | =head2 CauldronHandler |
259 | |
257 | |
260 | The Jeweler::CauldronHandler package, that helps you with handling the |
258 | The Jeweler::CauldronHandler package, that helps you with handling the |
261 | cauldron stuff. Can also be used for other skills. |
259 | cauldron stuff. Can also be used for other skills. |
… | |
… | |
369 | =back |
367 | =back |
370 | |
368 | |
371 | =cut |
369 | =cut |
372 | |
370 | |
373 | package Jeweler::Ingredients; |
371 | package Jeweler::Ingredients; |
|
|
372 | |
|
|
373 | use common::sense; |
|
|
374 | |
374 | use Storable qw/dclone/; |
375 | use Storable qw/dclone/; |
375 | use strict; |
|
|
376 | |
376 | |
377 | =head2 Ingredients |
377 | =head2 Ingredients |
378 | |
378 | |
379 | This class handles the ingredients. |
379 | This class handles the ingredients. |
380 | |
380 | |
… | |
… | |
626 | } |
626 | } |
627 | } |
627 | } |
628 | } |
628 | } |
629 | |
629 | |
630 | package Jeweler::Object; |
630 | package Jeweler::Object; |
631 | use strict; |
631 | |
|
|
632 | use common::sense; |
632 | use POSIX; |
633 | use POSIX; |
633 | use List::Util qw/max min sum/; |
634 | use List::Util qw/max min sum/; |
634 | |
635 | |
635 | sub new { |
636 | sub new { |
636 | my ($class, %arg) = @_; |
637 | my ($class, %arg) = @_; |
… | |
… | |
1108 | $cost->{gem} += ceil $sumvalue * $stat_split->[4] / max 1, $diarch->value; |
1109 | $cost->{gem} += ceil $sumvalue * $stat_split->[4] / max 1, $diarch->value; |
1109 | } |
1110 | } |
1110 | |
1111 | |
1111 | package Jeweler::Util; |
1112 | package Jeweler::Util; |
1112 | |
1113 | |
1113 | use strict; |
1114 | use common::sense; |
1114 | |
1115 | |
1115 | =head2 Util |
1116 | =head2 Util |
1116 | |
1117 | |
1117 | Some utility functions for the Jeweler skill. |
1118 | Some utility functions for the Jeweler skill. |
1118 | |
1119 | |