… | |
… | |
126 | { |
126 | { |
127 | if (tmp->arch != NULL) |
127 | if (tmp->arch != NULL) |
128 | { |
128 | { |
129 | if (flag == F_BUY) |
129 | if (flag == F_BUY) |
130 | { |
130 | { |
131 | LOG (llevError, "Asking for buy-value of unidentified object.\n"); |
131 | LOG (llevError | logBacktrace, "Asking for buy-value of unidentified object.\n"); |
132 | val = tmp->arch->value * 50 * number; |
132 | val = tmp->arch->value * 50 * number; |
133 | } |
133 | } |
134 | else |
134 | else |
135 | { /* Trying to sell something, or get true value */ |
135 | { /* Trying to sell something, or get true value */ |
136 | if (tmp->type == POTION) |
136 | if (tmp->type == POTION) |
… | |
… | |
150 | else |
150 | else |
151 | { /* No archetype with this object */ |
151 | { /* No archetype with this object */ |
152 | LOG (llevDebug, "In sell item: Have object with no archetype: %s\n", &tmp->name); |
152 | LOG (llevDebug, "In sell item: Have object with no archetype: %s\n", &tmp->name); |
153 | if (flag == F_BUY) |
153 | if (flag == F_BUY) |
154 | { |
154 | { |
155 | LOG (llevError, "Asking for buy-value of unidentified object without arch.\n"); |
155 | LOG (llevError | logBacktrace, "Asking for buy-value of unidentified object without arch.\n"); |
156 | val = number * tmp->value * 10; |
156 | val = number * tmp->value * 10; |
157 | } |
157 | } |
158 | else |
158 | else |
159 | val = number * tmp->value / 5; |
159 | val = number * tmp->value / 5; |
160 | } |
160 | } |
… | |
… | |
465 | } |
465 | } |
466 | |
466 | |
467 | for (tmp = op->inv; tmp; tmp = tmp->below) |
467 | for (tmp = op->inv; tmp; tmp = tmp->below) |
468 | if (tmp->type == MONEY) |
468 | if (tmp->type == MONEY) |
469 | total += tmp->nrof * (sint64)tmp->value; |
469 | total += tmp->nrof * (sint64)tmp->value; |
470 | else if (tmp->type == CONTAINER && QUERY_FLAG (tmp, FLAG_APPLIED) && (tmp->race == NULL || strstr (tmp->race, "gold"))) |
470 | else if (tmp->type == CONTAINER && QUERY_FLAG (tmp, FLAG_APPLIED) && (!tmp->race || tmp->race.contains ("gold"))) |
471 | total += query_money (tmp); |
471 | total += query_money (tmp); |
472 | |
472 | |
473 | return total; |
473 | return total; |
474 | } |
474 | } |
475 | |
475 | |
… | |
… | |
490 | return 0; |
490 | return 0; |
491 | |
491 | |
492 | pay_from_container (pl, pl, to_pay); |
492 | pay_from_container (pl, pl, to_pay); |
493 | |
493 | |
494 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
494 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
495 | if (pouch->type == CONTAINER && QUERY_FLAG (pouch, FLAG_APPLIED) && (pouch->race == NULL || strstr (pouch->race, "gold"))) |
495 | if (pouch->type == CONTAINER && QUERY_FLAG (pouch, FLAG_APPLIED) && (!pouch->race || pouch->race.contains ("gold"))) |
496 | pay_from_container (pl, pouch, to_pay); |
496 | pay_from_container (pl, pouch, to_pay); |
497 | |
497 | |
498 | pl->update_stats (); |
498 | pl->update_stats (); |
499 | return 1; |
499 | return 1; |
500 | } |
500 | } |
… | |
… | |
527 | change_exp (pl, saved_money, "bargaining", SK_EXP_NONE); |
527 | change_exp (pl, saved_money, "bargaining", SK_EXP_NONE); |
528 | |
528 | |
529 | pay_from_container (pl, pl, to_pay); |
529 | pay_from_container (pl, pl, to_pay); |
530 | |
530 | |
531 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
531 | for (pouch = pl->inv; pouch && to_pay; pouch = pouch->below) |
532 | if (pouch->type == CONTAINER && QUERY_FLAG (pouch, FLAG_APPLIED) && (pouch->race == NULL || strstr (pouch->race, "gold"))) |
532 | if (pouch->type == CONTAINER && QUERY_FLAG (pouch, FLAG_APPLIED) && (!pouch->race || pouch->race.contains ("gold"))) |
533 | pay_from_container (pl, pouch, to_pay); |
533 | pay_from_container (pl, pouch, to_pay); |
534 | |
534 | |
535 | pl->update_stats (); |
535 | pl->update_stats (); |
536 | |
536 | |
537 | return 1; |
537 | return 1; |
… | |
… | |
631 | count--; |
631 | count--; |
632 | } |
632 | } |
633 | } |
633 | } |
634 | |
634 | |
635 | for (i = 0; i < NUM_COINS; i++) |
635 | for (i = 0; i < NUM_COINS; i++) |
636 | { |
|
|
637 | if (coin_objs[i]->nrof) |
636 | if (coin_objs[i]->nrof) |
638 | insert_ob_in_ob (coin_objs [i], pouch); |
637 | insert_ob_in_ob (coin_objs [i], pouch); |
639 | else |
638 | else |
640 | coin_objs[i]->destroy (); |
639 | coin_objs[i]->destroy (); |
641 | } |
|
|
642 | } |
640 | } |
643 | |
641 | |
644 | /* Checks all unpaid items in op's inventory, adds up all the money they |
642 | /* Checks all unpaid items in op's inventory, adds up all the money they |
645 | * have, and checks that they can actually afford what they want to buy. |
643 | * have, and checks that they can actually afford what they want to buy. |
646 | * Returns 1 if they can, and 0 if they can't. also prints an appropriate message |
644 | * Returns 1 if they can, and 0 if they can't. also prints an appropriate message |
… | |
… | |
671 | dynbuf_text buf; |
669 | dynbuf_text buf; |
672 | |
670 | |
673 | buf << "You have " << unpaid_count |
671 | buf << "You have " << unpaid_count |
674 | << " unpaid item(s) that would cost you " << cost_string_from_value (unpaid_price, 0) |
672 | << " 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) |
673 | << ". You need another " << cost_string_from_value (unpaid_price - player_wealth, 0) |
676 | << " to be able to afford that."; |
674 | << " to be able to afford that. " |
|
|
675 | "H<You cannot leave a shop without paying - drop unpaid items first to be able to leave.>"; |
677 | |
676 | |
678 | pl->failmsg (buf); |
677 | pl->failmsg (buf); |
679 | |
678 | |
680 | return 0; |
679 | return 0; |
681 | } |
680 | } |
… | |
… | |
756 | LOG (llevError, "Could not find %s archetype\n", coins[count]); |
755 | LOG (llevError, "Could not find %s archetype\n", coins[count]); |
757 | else if ((amount / at->value) > 0) |
756 | else if ((amount / at->value) > 0) |
758 | { |
757 | { |
759 | for (pouch = pl->inv; pouch; pouch = pouch->below) |
758 | for (pouch = pl->inv; pouch; pouch = pouch->below) |
760 | { |
759 | { |
761 | if (pouch->type == CONTAINER && QUERY_FLAG (pouch, FLAG_APPLIED) && pouch->race && strstr (pouch->race, "gold")) |
760 | if (pouch->type == CONTAINER && QUERY_FLAG (pouch, FLAG_APPLIED) && pouch->race && pouch->race.contains ("gold")) |
762 | { |
761 | { |
763 | int w = at->weight * (100 - pouch->stats.Str) / 100; |
762 | int w = at->weight * (100 - pouch->stats.Str) / 100; |
764 | int n = amount / at->value; |
763 | int n = amount / at->value; |
765 | |
764 | |
766 | if (w == 0) |
765 | if (w == 0) |