… | |
… | |
163 | } |
163 | } |
164 | } else { |
164 | } else { |
165 | $value = $what->query_cost ($who, cf::F_SELL | cf::F_SHOP) / ($what->nrof || 1); |
165 | $value = $what->query_cost ($who, cf::F_SELL | cf::F_SHOP) / ($what->nrof || 1); |
166 | } |
166 | } |
167 | |
167 | |
|
|
168 | if ($value < 0) { |
|
|
169 | $what->insert_ob_in_ob ($who); |
|
|
170 | $who->message ("The shopkeeper says: You can't sell something for a negative value: $value", cf::NDI_BROWN); |
|
|
171 | return 1; |
|
|
172 | } |
|
|
173 | |
168 | my $fee = $value / 100; # 1% selling fee |
174 | my $fee = $value / 100; # 1% selling fee |
169 | |
175 | |
170 | unless ($who->pay_amount ($fee)) { |
176 | unless ($who->pay_amount ($fee)) { |
171 | $who->message ( |
177 | $who->message ( |
172 | "The shopkeeper says: You need " . cf::cost_string_from_value ($fee) . " to pay the 1% fee for this item", |
178 | "The shopkeeper says: You need " . cf::cost_string_from_value ($fee) . " to pay the 1% fee for this item", |
… | |
… | |
205 | |
211 | |
206 | $what->set_ob_key_value (ext_reseller_seller => $who->name); |
212 | $what->set_ob_key_value (ext_reseller_seller => $who->name); |
207 | $what->set_ob_key_value (ext_reseller_orig_value => $orig_value); |
213 | $what->set_ob_key_value (ext_reseller_orig_value => $orig_value); |
208 | # warn "SET SELLER ON " . $what->name . " + " . $what->{seller}->[0] . "\n"; |
214 | # warn "SET SELLER ON " . $what->name . " + " . $what->{seller}->[0] . "\n"; |
209 | $what->set_custom_name ( |
215 | $what->set_custom_name ( |
210 | $what->name . " (property of " . $who->name . ")" |
216 | $what->name . " (by " . $who->name . ")" |
211 | ); |
217 | ); |
212 | $what->set_flag (cf::FLAG_UNPAID, 1); |
218 | $what->set_flag (cf::FLAG_UNPAID, 1); |
213 | $what->insert_ob_in_map_at ($who->map, $who, cf::INS_BELOW_ORIGINATOR, $who->x, $who->y); |
219 | $what->insert_ob_in_map_at ($who->map, $who, cf::INS_BELOW_ORIGINATOR, $who->x, $who->y); |
214 | 1; |
220 | 1; |
215 | } |
221 | } |