--- deliantra/server/ext/reseller.ext 2007/12/24 16:41:55 1.10 +++ deliantra/server/ext/reseller.ext 2008/04/10 15:35:16 1.11 @@ -1,17 +1,5 @@ #!perl # mandatory -my %unit = ( - silver => 1, - gold => 10, - platina => 50, - royalty => 5000, -); - -my %aliases = ( - platinum => 'platina', - royalties => 'royalty', -); - sub ob2info { my ($item, $rval) = @_; sprintf "[%s from %s (%d:%d%s) nrof: %d uuid: %s]", @@ -202,16 +190,19 @@ unless ($name =~ m/\d+\s*\S+/) { give_back_with_message ($who, $what, "The shopkeeper says: Sorry, I don't recognize '$name' as currency. " - ."Please name your item like '10 royalty' or '10 platinum 2 silver'"); + . "Please name your item like '17 platinum' or '10 gold 8 silver'"); return cf::override; } while ($name =~ s/^\s*(\d+)\s*(\S+)//) { - if ($aliases{lc $2} or $unit{lc $2}) { - $value += $1 * ($unit{lc $2} ? $unit{lc $2} : $unit{$aliases{lc $2}}); + my ($v, $c) = ($1, $2); + if (my $coin = cf::coin_from_name $c) { + $value += $v * $coin->value; } else { give_back_with_message ($who, $what, - "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)); + "The shopkeeper says: I don't know the currency '$c', you can use one of these currencies: " + . (join ", ", cf::coin_names) + ); return cf::override; } } @@ -221,9 +212,10 @@ # $value = $what->query_cost ($who, cf::F_SELL | cf::F_SHOP) / ($what->nrof || 1); give_back_with_message ($who, $what, "Sorry, you can't just sell stuff without assigning a price to it! " - ."Please name your item like '10 royalty' or '10 platinum 2 silver' " - ."and drop it again. (To rename the item use the 'rename' " - ."context menu item in the inventory)."); + . "Please name your item like '17 platinum' or '10 gold 8 silver' " + . "and drop it again. (To rename the item use the 'rename' " + . "context menu item in the inventory)." + ); return cf::override; }