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.16 by elmex, Thu Aug 20 18:27:21 2009 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 = "T<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
153; 156;
154 157
155sub give_back { 158sub give_back {
156 my ($who, $what) = @_; 159 my ($who, $what) = @_;
157 $who->insert ($what); 160 $who->insert ($what);
158 $who->esrv_send_item ($what);
159} 161}
160 162
161sub give_back_with_message { 163sub give_back_with_message {
162 my ($who, $what, $msg) = @_; 164 my ($who, $what, $msg) = @_;
163 $who->message ($msg, cf::NDI_BROWN); 165 $who->message ($msg, cf::NDI_BROWN);
188 190
189 if ($name =~ m/\S/) { 191 if ($name =~ m/\S/) {
190 unless ($name =~ m/\d+\s*\S+/) { 192 unless ($name =~ m/\d+\s*\S+/) {
191 give_back_with_message ($who, $what, 193 give_back_with_message ($who, $what,
192 "The shopkeeper says: Sorry, I don't recognize '$name' as currency. " 194 "The shopkeeper says: Sorry, I don't recognize '$name' as currency. "
193 . "Please name your item like '17 platinum' or '10 gold 8 silver'"); 195 . "Please name your item like '17 platinum' or '10 gold 8 silver.'");
194 return cf::override; 196 return cf::override;
195 } 197 }
196 198
197 while ($name =~ s/^\s*(\d+)\s*(\S+)//) { 199 while ($name =~ s/^\s*(\d+)\s*(\S+)//) {
198 my ($v, $c) = ($1, $2); 200 my ($v, $c) = ($1, $2);
211 # reseller shop as dumpyard: 213 # reseller shop as dumpyard:
212 # $value = $what->query_cost ($who, cf::F_SELL | cf::F_SHOP) / ($what->nrof || 1); 214 # $value = $what->query_cost ($who, cf::F_SELL | cf::F_SHOP) / ($what->nrof || 1);
213 give_back_with_message ($who, $what, 215 give_back_with_message ($who, $what,
214 "Sorry, you can't just sell stuff without assigning a price to it! " 216 "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' " 217 . "Please name your item like '17 platinum' or '10 gold 8 silver' "
216 . "and drop it again. (To rename the item use the 'rename' " 218 . "and drop it again. (To rename the item use the B<rename> "
217 . "context menu item in the inventory)." 219 . "entry in the inventory item popup menu)."
218 ); 220 );
219 return cf::override; 221 return cf::override;
220 } 222 }
221 223
224 if ($value > 100 ** 4) { # also for overflow prevention
225 give_back_with_message ($who, $what,
226 "The shopkeeper says: You can't sell something for such a high "
227 . "value. Please keep it below 100 royalty.");
228 return cf::override;
229 }
230
222 if ($value < 0) { 231 if ($value < 0) {
223 give_back_with_message ($who, $what, 232 give_back_with_message ($who, $what,
224 "The shopkeeper says: You can't sell something for a negative value: $value"); 233 "The shopkeeper says: You can't sell something for a negative value: $value.");
225 return cf::override; 234 return cf::override;
226 } 235 }
227 236
228 my $fee = $value / 100; # 1% selling fee 237 my $fee = $value / 100; # 1% selling fee
229 238
230 unless ($who->pay_amount ($fee)) { 239 unless ($who->pay_amount ($fee)) {
231 give_back_with_message ($who, $what, 240 give_back_with_message ($who, $what,
232 "The shopkeeper says: You need " . cf::cost_string_from_value ($fee) 241 "The shopkeeper says: You need " . cf::cost_string_from_value ($fee)
233 . " to pay the 1% fee for this item"); 242 . " to pay the 1% fee for this item.");
234 return cf::override; 243 return cf::override;
235 } else { 244 } else {
236 $who->message ( 245 $who->message (
237 "The shopkeeper says: Ok, got the fee of " . cf::cost_string_from_value ($fee) 246 "The shopkeeper says: Ok, got the fee of " . cf::cost_string_from_value ($fee)
238 . " for the item", 247 . " for the item.",
239 cf::NDI_BROWN 248 cf::NDI_BROWN
240 ); 249 );
241 } 250 }
242 251
243 $what->value ($value); 252 $what->value ($value);

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines