ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/deliantra/server/ext/jeweler.ext
(Generate patch)

Comparing deliantra/server/ext/jeweler.ext (file contents):
Revision 1.12 by elmex, Tue Jul 31 09:40:15 2007 UTC vs.
Revision 1.15 by root, Mon Dec 17 08:03:22 2007 UTC

1#! perl 1#! perl
2 2
3use Data::Dumper; 3use strict;
4
4use Jeweler; 5use Jeweler;
5use List::Util qw/max min sum/; 6use List::Util qw/max min sum/;
6use strict;
7 7
8sub ingred_alias { 8sub ingred_alias {
9 my ($ing) = @_; 9 my ($ing) = @_;
10 10
11 my %aliases = ( 11 my %aliases = (
112 "JEWELER AUDIT: '%s' made '%s' (%s) (sk lvl %d, ring lvl %d, got %d exp): %s", 112 "JEWELER AUDIT: '%s' made '%s' (%s) (sk lvl %d, ring lvl %d, got %d exp): %s",
113 $pl->name, $ring->to_string, $ring_ob->uuid, $sklvl, 113 $pl->name, $ring->to_string, $ring_ob->uuid, $sklvl,
114 $ring->power_to_level, $exp, $make_status; 114 $ring->power_to_level, $exp, $make_status;
115 115
116 warn "$make_info\n" if $make_status eq 'succeeded'; 116 warn "$make_info\n" if $make_status eq 'succeeded';
117
118 $ring_ob->set_ob_key_value (ext_jeweler_made_by => $pl->name);
119 $ring_ob->set_ob_key_value (ext_jeweler_make_info => $make_info);
120 } 117 }
121 118
122 $chdl->put ($ring_ob); 119 $chdl->put ($ring_ob);
123} 120}
124 121
212 my $plan = $ingred->get_plan; 209 my $plan = $ingred->get_plan;
213 210
214 if ($plan) { 211 if ($plan) {
215 my @ring = $ingred->get_ring; 212 my @ring = $ingred->get_ring;
216 213
214 if (!@ring) {
215 # actually the algorithm cant
216 $pl->message ("You slap yourself, you forgot the jewelery!");
217 return;
218
217 if ((@ring > 1) || ($ring[0]->nrof > 1)) { 219 } elsif ((@ring > 1) || (grep { $_->nrof > 1 } @ring)) {
218 # 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
219 $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!");
220 return; 222 return;
221
222 } elsif (@ring < 1) {
223 # actually the algorithm cant
224 $pl->message ("You slap yourself, you forgot the jewelery!");
225 return;
226
227 } else { 223 } else {
228 my $ringo = Jeweler::Object->new (object => $ring[0]); 224 my $ringo = Jeweler::Object->new (object => $ring[0]);
229 my $iring = $ingred->improve_ring_by_plan ($plan, $ringo); 225 my $iring = $ingred->improve_ring_by_plan ($plan, $ringo);
230 my $c1 = $ringo->calc_costs; 226 my $c1 = $ringo->calc_costs;
231 my $c2 = $iring->calc_costs; 227 my $c2 = $iring->calc_costs;
273 }; 269 };
274 $@ and warn "ERROR: $@\n"; 270 $@ and warn "ERROR: $@\n";
275 } 271 }
276); 272);
277 273
278Jeweler::read_config "$DATADIR/jeweler.yaml"; 274Jeweler::read_config "res/jeweler.yaml";
279 275

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines