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.12 by root, Sat May 3 11:14:50 2008 UTC vs.
Revision 1.13 by root, Sun Aug 31 08:54:19 2008 UTC

48 unless (keys %{$hissells || {}}) { 48 unless (keys %{$hissells || {}}) {
49 $who->reply ($npc, "I'm sorry, but you sold nothing.\n"); 49 $who->reply ($npc, "I'm sorry, but you sold nothing.\n");
50 return 0; 50 return 0;
51 } 51 }
52 52
53 $who->reply ($npc, "You sold:\n", cf::NDI_BROWN); 53 my $reply = "You sold:\n\n";
54
54 for (keys %$hissells) { 55 for (keys %$hissells) {
55 my $n = $_; 56 my $n = $_;
56 $n =~ s/\s*\(unpaid\)//g; 57 $n =~ s/\s*\(unpaid\)//g;
57 $who->reply ($npc, "$n for " . cf::cost_string_from_value ($hissells->{$_}), cf::NDI_BROWN); 58 $reply .= " B<$n> (for " . cf::cost_string_from_value ($hissells->{$_}) . ")\n";
58 } 59 }
60
61 $who->reply ($npc, $reply);
59 62
60 0 63 0
61}; 64};
62 65
63cf::register_script_function "reseller::pay_player" => sub { 66cf::register_script_function "reseller::pay_player" => sub {
73 76
74 my $sum = 0; 77 my $sum = 0;
75 $sum += $_ for values %$hissells; 78 $sum += $_ for values %$hissells;
76 79
77 $who->pay_player ($sum); 80 $who->pay_player ($sum);
78 $who->reply ($npc, "Here are the " . cf::cost_string_from_value ($sum) . " for your sales"); 81 $who->reply ($npc, "Here are the " . cf::cost_string_from_value ($sum) . " for your sales.");
79 82
80 audit_log ($who, 'collects', "$sum silver"); 83 audit_log ($who, 'collects', "$sum silver");
81 84
82 $sells->{$who->name} = {}; 85 $sells->{$who->name} = {};
83 86
188 191
189 if ($name =~ m/\S/) { 192 if ($name =~ m/\S/) {
190 unless ($name =~ m/\d+\s*\S+/) { 193 unless ($name =~ m/\d+\s*\S+/) {
191 give_back_with_message ($who, $what, 194 give_back_with_message ($who, $what,
192 "The shopkeeper says: Sorry, I don't recognize '$name' as currency. " 195 "The shopkeeper says: Sorry, I don't recognize '$name' as currency. "
193 . "Please name your item like '17 platinum' or '10 gold 8 silver'"); 196 . "Please name your item like '17 platinum' or '10 gold 8 silver.'");
194 return cf::override; 197 return cf::override;
195 } 198 }
196 199
197 while ($name =~ s/^\s*(\d+)\s*(\S+)//) { 200 while ($name =~ s/^\s*(\d+)\s*(\S+)//) {
198 my ($v, $c) = ($1, $2); 201 my ($v, $c) = ($1, $2);
211 # reseller shop as dumpyard: 214 # reseller shop as dumpyard:
212 # $value = $what->query_cost ($who, cf::F_SELL | cf::F_SHOP) / ($what->nrof || 1); 215 # $value = $what->query_cost ($who, cf::F_SELL | cf::F_SHOP) / ($what->nrof || 1);
213 give_back_with_message ($who, $what, 216 give_back_with_message ($who, $what,
214 "Sorry, you can't just sell stuff without assigning a price to it! " 217 "Sorry, you can't just sell stuff without assigning a price to it! "
215 . "Please name your item like '17 platinum' or '10 gold 8 silver' " 218 . "Please name your item like '17 platinum' or '10 gold 8 silver' "
216 . "and drop it again. (To rename the item use the 'rename' " 219 . "and drop it again. (To rename the item use the B<rename> "
217 . "context menu item in the inventory)." 220 . "entry in the inventory item popup menu)."
218 ); 221 );
219 return cf::override; 222 return cf::override;
220 } 223 }
221 224
222 if ($value < 0) { 225 if ($value < 0) {
223 give_back_with_message ($who, $what, 226 give_back_with_message ($who, $what,
224 "The shopkeeper says: You can't sell something for a negative value: $value"); 227 "The shopkeeper says: You can't sell something for a negative value: $value.");
225 return cf::override; 228 return cf::override;
226 } 229 }
227 230
228 my $fee = $value / 100; # 1% selling fee 231 my $fee = $value / 100; # 1% selling fee
229 232
230 unless ($who->pay_amount ($fee)) { 233 unless ($who->pay_amount ($fee)) {
231 give_back_with_message ($who, $what, 234 give_back_with_message ($who, $what,
232 "The shopkeeper says: You need " . cf::cost_string_from_value ($fee) 235 "The shopkeeper says: You need " . cf::cost_string_from_value ($fee)
233 . " to pay the 1% fee for this item"); 236 . " to pay the 1% fee for this item.");
234 return cf::override; 237 return cf::override;
235 } else { 238 } else {
236 $who->message ( 239 $who->message (
237 "The shopkeeper says: Ok, got the fee of " . cf::cost_string_from_value ($fee) 240 "The shopkeeper says: Ok, got the fee of " . cf::cost_string_from_value ($fee)
238 . " for the item", 241 . " for the item.",
239 cf::NDI_BROWN 242 cf::NDI_BROWN
240 ); 243 );
241 } 244 }
242 245
243 $what->value ($value); 246 $what->value ($value);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines