MCPcopy Create free account
hub / github.com/NetHack/NetHack / donate_gold

Function donate_gold

src/shk.c:3876–3910  ·  view source on GitHub ↗

opposite of costly_gold(); hero has dropped gold in a shop; called from sellobj(); ought to be called from subfrombill() too */

Source from the content-addressed store, hash-verified

3874/* opposite of costly_gold(); hero has dropped gold in a shop;
3875 called from sellobj(); ought to be called from subfrombill() too */
3876void
3877donate_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
3912void
3913sellobj_state(int deliberate)

Callers 3

check_shop_objFunction · 0.85
really_kick_objectFunction · 0.85
sellobjFunction · 0.85

Calls 4

YourFunction · 0.85
YouFunction · 0.85
currencyFunction · 0.85
plineFunction · 0.70

Tested by

no test coverage detected