|
@@ -154,9 +154,12 @@ def gift(json_request):
|
|
|
|
|
|
if model.user_available_ownable(sender_id, ownable_id) == 0:
|
|
|
return BadRequest('You do not own any of these.')
|
|
|
- if not model.user_has_at_least_available(amount, sender_id, ownable_id):
|
|
|
-
|
|
|
- amount = model.user_available_ownable(sender_id, ownable_id)
|
|
|
+
|
|
|
+ wealth = model.user_wealth(user_id=sender_id)
|
|
|
+ if wealth < amount:
|
|
|
+ raise PreconditionFailed(f'Your current wealth, computed from your owned equities minus debt, is {wealth}.\n'
|
|
|
+ f'To protect you from giving away more than you can afford, you not gift any amounts larger than this to other players.'
|
|
|
+ f'You can still try to emulate gifting by selling something at a low price and buying it back afterwards at a higher price.')
|
|
|
|
|
|
recipient_id = model.get_user_id_by_name(json_request['username'])
|
|
|
|