1 | #! perl |
1 | #! perl |
2 | |
2 | |
3 | use Data::Dumper; |
3 | use strict; |
|
|
4 | |
4 | use Jeweler; |
5 | use Jeweler; |
5 | use List::Util qw/max min sum/; |
6 | use List::Util qw/max min sum/; |
6 | use strict; |
|
|
7 | |
7 | |
8 | sub ingred_alias { |
8 | sub ingred_alias { |
9 | my ($ing) = @_; |
9 | my ($ing) = @_; |
10 | |
10 | |
11 | my %aliases = ( |
11 | my %aliases = ( |
… | |
… | |
209 | my $plan = $ingred->get_plan; |
209 | my $plan = $ingred->get_plan; |
210 | |
210 | |
211 | if ($plan) { |
211 | if ($plan) { |
212 | my @ring = $ingred->get_ring; |
212 | my @ring = $ingred->get_ring; |
213 | |
213 | |
|
|
214 | if (!@ring) { |
|
|
215 | # actually the algorithm cant |
|
|
216 | $pl->message ("You slap yourself, you forgot the jewelery!"); |
|
|
217 | return; |
|
|
218 | |
214 | if ((@ring > 1) || ($ring[0]->nrof > 1)) { |
219 | } elsif ((@ring > 1) || (grep { $_->nrof > 1 } @ring)) { |
215 | # actually the algorithm cant handle more than one improvement at a time |
220 | # actually the algorithm cant handle more than one improvement at a time |
216 | $pl->message ("You can't manage to improve more than one thing at a time!"); |
221 | $pl->message ("You can't manage to improve more than one thing at a time!"); |
217 | return; |
222 | return; |
218 | |
|
|
219 | } elsif (@ring < 1) { |
|
|
220 | # actually the algorithm cant |
|
|
221 | $pl->message ("You slap yourself, you forgot the jewelery!"); |
|
|
222 | return; |
|
|
223 | |
|
|
224 | } else { |
223 | } else { |
225 | my $ringo = Jeweler::Object->new (object => $ring[0]); |
224 | my $ringo = Jeweler::Object->new (object => $ring[0]); |
226 | my $iring = $ingred->improve_ring_by_plan ($plan, $ringo); |
225 | my $iring = $ingred->improve_ring_by_plan ($plan, $ringo); |
227 | my $c1 = $ringo->calc_costs; |
226 | my $c1 = $ringo->calc_costs; |
228 | my $c2 = $iring->calc_costs; |
227 | my $c2 = $iring->calc_costs; |
… | |
… | |
270 | }; |
269 | }; |
271 | $@ and warn "ERROR: $@\n"; |
270 | $@ and warn "ERROR: $@\n"; |
272 | } |
271 | } |
273 | ); |
272 | ); |
274 | |
273 | |
275 | Jeweler::read_config "$DATADIR/jeweler.yaml"; |
274 | Jeweler::read_config "res/jeweler.yaml"; |
276 | |
275 | |