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

Comparing deliantra/server/ext/reseller.ext (file contents):
Revision 1.10 by elmex, Mon Dec 24 16:41:55 2007 UTC vs.
Revision 1.11 by root, Thu Apr 10 15:35:16 2008 UTC

1#!perl # mandatory 1#!perl # mandatory
2
3my %unit = (
4 silver => 1,
5 gold => 10,
6 platina => 50,
7 royalty => 5000,
8);
9
10my %aliases = (
11 platinum => 'platina',
12 royalties => 'royalty',
13);
14 2
15sub ob2info { 3sub ob2info {
16 my ($item, $rval) = @_; 4 my ($item, $rval) = @_;
17 sprintf "[%s from %s (%d:%d%s) nrof: %d uuid: %s]", 5 sprintf "[%s from %s (%d:%d%s) nrof: %d uuid: %s]",
18 $item->name, $item->get_ob_key_value ('ext_reseller_seller'), 6 $item->name, $item->get_ob_key_value ('ext_reseller_seller'),
200 188
201 if ($name =~ m/\S/) { 189 if ($name =~ m/\S/) {
202 unless ($name =~ m/\d+\s*\S+/) { 190 unless ($name =~ m/\d+\s*\S+/) {
203 give_back_with_message ($who, $what, 191 give_back_with_message ($who, $what,
204 "The shopkeeper says: Sorry, I don't recognize '$name' as currency. " 192 "The shopkeeper says: Sorry, I don't recognize '$name' as currency. "
205 ."Please name your item like '10 royalty' or '10 platinum 2 silver'"); 193 . "Please name your item like '17 platinum' or '10 gold 8 silver'");
206 return cf::override; 194 return cf::override;
207 } 195 }
208 196
209 while ($name =~ s/^\s*(\d+)\s*(\S+)//) { 197 while ($name =~ s/^\s*(\d+)\s*(\S+)//) {
210 if ($aliases{lc $2} or $unit{lc $2}) { 198 my ($v, $c) = ($1, $2);
211 $value += $1 * ($unit{lc $2} ? $unit{lc $2} : $unit{$aliases{lc $2}}); 199 if (my $coin = cf::coin_from_name $c) {
200 $value += $v * $coin->value;
212 } else { 201 } else {
213 give_back_with_message ($who, $what, 202 give_back_with_message ($who, $what,
214 "The shopkeeper says: I don't know the currency '$2', you can use one of these currencies: ".join (", ", keys %unit)." or also: ".join (", ", keys %aliases)); 203 "The shopkeeper says: I don't know the currency '$c', you can use one of these currencies: "
204 . (join ", ", cf::coin_names)
205 );
215 return cf::override; 206 return cf::override;
216 } 207 }
217 } 208 }
218 } else { 209 } else {
219 # commented out the following line because too many just use the 210 # commented out the following line because too many just use the
220 # reseller shop as dumpyard: 211 # reseller shop as dumpyard:
221 # $value = $what->query_cost ($who, cf::F_SELL | cf::F_SHOP) / ($what->nrof || 1); 212 # $value = $what->query_cost ($who, cf::F_SELL | cf::F_SHOP) / ($what->nrof || 1);
222 give_back_with_message ($who, $what, 213 give_back_with_message ($who, $what,
223 "Sorry, you can't just sell stuff without assigning a price to it! " 214 "Sorry, you can't just sell stuff without assigning a price to it! "
224 ."Please name your item like '10 royalty' or '10 platinum 2 silver' " 215 . "Please name your item like '17 platinum' or '10 gold 8 silver' "
225 ."and drop it again. (To rename the item use the 'rename' " 216 . "and drop it again. (To rename the item use the 'rename' "
226 ."context menu item in the inventory)."); 217 . "context menu item in the inventory)."
218 );
227 return cf::override; 219 return cf::override;
228 } 220 }
229 221
230 if ($value < 0) { 222 if ($value < 0) {
231 give_back_with_message ($who, $what, 223 give_back_with_message ($who, $what,

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines