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.2 by root, Thu Dec 21 22:41:34 2006 UTC vs.
Revision 1.4 by elmex, Wed Jan 31 15:53:17 2007 UTC

38my $DEBUG = 1; 38my $DEBUG = 1;
39 39
40sub merge { 40sub merge {
41 my ($chdl, $sk, $pl, $do_analyze) = @_; 41 my ($chdl, $sk, $pl, $do_analyze) = @_;
42 42
43 my $ingred = $chdl->extract_jeweler_ingredients; 43 my $ingred = eval { $chdl->extract_jeweler_ingredients };
44 if ($@ =~ /cursed/) {
45 $pl->reply ("There are cursed items in the workbench, take them out before you do anything.").
46 return
47 } elsif ($@) {
48 warn "error in jeweler ingredient extraction: $@";
49 return;
50 }
51
44 my @ring = $ingred->get_ring; 52 my @ring = $ingred->get_ring;
45 my @rings = map { Jeweler::Object->new (object => $_) } @ring; 53 my @rings = map { Jeweler::Object->new (object => $_) } @ring;
46 54
47 @rings >= 2 55 @rings >= 2
48 or return $pl->reply (undef, "You slap yourself, you forgot to put at least 2 jewels in!"); 56 or return $pl->reply (undef, "You slap yourself, you forgot to put at least 2 jewels in!");
111 119
112 } elsif ($msg =~ m/^\s*make\s*$/i) { 120 } elsif ($msg =~ m/^\s*make\s*$/i) {
113 $pl->message ("You can make: " . (join ', ', keys %{Jeweler::getcfg ('conversions') || {}})); 121 $pl->message ("You can make: " . (join ', ', keys %{Jeweler::getcfg ('conversions') || {}}));
114 122
115 } elsif ($msg =~ m/^\s*make\s+(\S+)\s*$/i) { 123 } elsif ($msg =~ m/^\s*make\s+(\S+)\s*$/i) {
116 my $ingred = $chdl->extract_jeweler_ingredients; 124 my $ingred = eval { $chdl->extract_jeweler_ingredients };
125 if ($@ =~ /cursed/) {
126 $pl->message ("There are cursed items in the workbench, take them out before you do anything.").
127 return
128 } elsif ($@) {
129 warn "error in jeweler ingredient extraction: $@";
130 return;
131 }
117 132
118 unless ($Jeweler::CFG->{conversions}->{lc $1}) { 133 unless ($Jeweler::CFG->{conversions}->{lc $1}) {
119 $pl->message ("You don't know how to make '$1', is does such a thing even exist?"); 134 $pl->message ("You don't know how to make '$1', is does such a thing even exist?");
120 return 135 return
121 } 136 }
127 142
128 } elsif ($msg =~ m/^\s*merge\s*$/i) { 143 } elsif ($msg =~ m/^\s*merge\s*$/i) {
129 merge ($chdl, $sk, $pl, 0); 144 merge ($chdl, $sk, $pl, 0);
130 145
131 } else { 146 } else {
132 my $ingred = $chdl->extract_jeweler_ingredients; 147 my $ingred = eval { $chdl->extract_jeweler_ingredients };
148 if ($@ =~ /cursed/) {
149 $pl->message ("There are cursed items in the workbench, take them out before you do anything.").
150 return
151 } elsif ($@) {
152 warn "error in jeweler ingredient extraction: $@";
153 return;
154 }
155
133 my $plan = $ingred->get_plan; 156 my $plan = $ingred->get_plan;
134 157
135 if ($plan) { 158 if ($plan) {
136 my @ring = $ingred->get_ring; 159 my @ring = $ingred->get_ring;
137 160
152 my $c2 = $iring->calc_costs; 175 my $c2 = $iring->calc_costs;
153 176
154 my %keys; 177 my %keys;
155 my %cdiff; 178 my %cdiff;
156 for (keys %$c1, keys %$c2) { $keys{$_} = 1 } 179 for (keys %$c1, keys %$c2) { $keys{$_} = 1 }
157 for (keys %keys) { $cdiff{$_} = $c2->{$_} - $c1->{$_} } 180 for (keys %keys) { $cdiff{$_} = $c2->{$_} - $c1->{$_}; warn "$_: $c2->{$_} | $c1->{$_}\n"; }
158 181
159 unless (grep { $_ > 0 } values %cdiff) { 182 unless ($iring->is_better_than ($ringo)) {
160 $pl->message ("This plan doesn't improve anything, you find yourself puzzled about what you missed..."); 183 $pl->message ("This plan doesn't improve anything, you find yourself puzzled about what you missed...");
161 return; 184 return;
162 } 185 }
163 186
164 my $remcosts = $ingred->check_costs (\%cdiff); 187 my $remcosts = $ingred->check_costs (\%cdiff);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines