… | |
… | |
666 | unpaid_price += query_cost (item, pl, F_BUY | F_SHOP); |
666 | unpaid_price += query_cost (item, pl, F_BUY | F_SHOP); |
667 | } |
667 | } |
668 | |
668 | |
669 | if (unpaid_price > player_wealth) |
669 | if (unpaid_price > player_wealth) |
670 | { |
670 | { |
671 | char buf[MAX_BUF]; |
671 | dynbuf_text buf; |
672 | char cost[MAX_BUF]; |
|
|
673 | char missing[MAX_BUF]; |
|
|
674 | |
672 | |
675 | snprintf (cost, MAX_BUF, "%s", cost_string_from_value (unpaid_price, 0)); |
673 | buf << "You have " << unpaid_count |
676 | snprintf (missing, MAX_BUF, "%s", cost_string_from_value (unpaid_price - player_wealth, 0)); |
674 | << " unpaid item(s) that would cost you " << cost_string_from_value (unpaid_price, 0) |
|
|
675 | << ". You need another " << cost_string_from_value (unpaid_price - player_wealth, 0) |
|
|
676 | << " to be able to afford that."; |
677 | |
677 | |
678 | snprintf (buf, MAX_BUF, "You have %d unpaid items that would cost you %s. You need another %s to be able to afford that.", |
678 | pl->failmsg (buf); |
679 | unpaid_count, cost, missing); |
|
|
680 | new_draw_info (NDI_UNIQUE, 0, pl, buf); |
|
|
681 | |
679 | |
682 | return 0; |
680 | return 0; |
683 | } |
681 | } |
684 | else |
682 | else |
685 | return 1; |
683 | return 1; |
… | |
… | |
797 | |
795 | |
798 | /* elmex: this is for the bank plugin :( */ |
796 | /* elmex: this is for the bank plugin :( */ |
799 | sint64 |
797 | sint64 |
800 | pay_player_arch (object *pl, const char *arch, sint64 amount) |
798 | pay_player_arch (object *pl, const char *arch, sint64 amount) |
801 | { |
799 | { |
802 | archetype *at = archetype::find (arch); |
|
|
803 | |
|
|
804 | if (!at) |
|
|
805 | return 0; |
|
|
806 | |
|
|
807 | if (amount > 0) |
800 | if (amount) |
808 | { |
801 | { |
809 | object *tmp = arch_to_object (at); |
802 | object *ob = archetype::get (arch); |
|
|
803 | |
|
|
804 | if (!ob) |
|
|
805 | return 0; |
|
|
806 | |
810 | tmp->nrof = amount; |
807 | ob->nrof = amount; |
811 | insert_ob_in_ob (tmp, pl); |
808 | pl->insert (ob); |
812 | } |
809 | } |
813 | |
810 | |
814 | return 1; |
811 | return 1; |
815 | } |
812 | } |
816 | |
813 | |
… | |
… | |
1128 | |
1125 | |
1129 | void |
1126 | void |
1130 | shop_listing (object *sign, object *op) |
1127 | shop_listing (object *sign, object *op) |
1131 | { |
1128 | { |
1132 | int i, j, numitems = 0, numallocated = 0, x1, x2, y1, y2; |
1129 | int i, j, numitems = 0, numallocated = 0, x1, x2, y1, y2; |
1133 | const char *shop_coords = get_ob_key_value (sign, "shop_coords"); |
1130 | const char *shop_coords = sign->kv (shstr_shop_coords); |
1134 | object *stack; |
1131 | object *stack; |
1135 | shopinv *items; |
1132 | shopinv *items; |
1136 | |
1133 | |
1137 | /* Should never happen, but just in case a monster does apply a sign */ |
1134 | /* Should never happen, but just in case a monster does apply a sign */ |
1138 | if (op->type != PLAYER) |
1135 | if (op->type != PLAYER) |