opposite of costly_gold(); hero has dropped gold in a shop; called from sellobj(); ought to be called from subfrombill() too */
| 3874 | /* opposite of costly_gold(); hero has dropped gold in a shop; |
| 3875 | called from sellobj(); ought to be called from subfrombill() too */ |
| 3876 | void |
| 3877 | donate_gold( |
| 3878 | long gltmp, |
| 3879 | struct monst *shkp, |
| 3880 | boolean selling) /* T: dropped in shop; F: kicked and landed in shop */ |
| 3881 | { |
| 3882 | struct eshk *eshkp = ESHK(shkp); |
| 3883 | |
| 3884 | if (eshkp->debit >= gltmp) { |
| 3885 | if (eshkp->loan) { /* you carry shop's gold */ |
| 3886 | if (eshkp->loan > gltmp) |
| 3887 | eshkp->loan -= gltmp; |
| 3888 | else |
| 3889 | eshkp->loan = 0L; |
| 3890 | } |
| 3891 | eshkp->debit -= gltmp; |
| 3892 | Your("debt is %spaid off.", eshkp->debit ? "partially " : ""); |
| 3893 | } else { |
| 3894 | long delta = gltmp - eshkp->debit; |
| 3895 | |
| 3896 | eshkp->credit += delta; |
| 3897 | if (eshkp->debit) { |
| 3898 | eshkp->debit = 0L; |
| 3899 | eshkp->loan = 0L; |
| 3900 | Your("debt is paid off."); |
| 3901 | } |
| 3902 | if (eshkp->credit == delta) |
| 3903 | You("have %sestablished %ld %s credit.", |
| 3904 | !selling ? "re-" : "", delta, currency(delta)); |
| 3905 | else |
| 3906 | pline("%ld %s added%s to your credit; total is now %ld %s.", |
| 3907 | delta, currency(delta), !selling ? " back" : "", |
| 3908 | eshkp->credit, currency(eshkp->credit)); |
| 3909 | } |
| 3910 | } |
| 3911 | |
| 3912 | void |
| 3913 | sellobj_state(int deliberate) |
no test coverage detected