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

Function money2u

src/shk.c:185–212  ·  view source on GitHub ↗

* Transfer money from monster to inventory. * Used when the shopkeeper pay for items, and when * the priest gives you money for an ale. */

Source from the content-addressed store, hash-verified

183 * the priest gives you money for an ale.
184 */
185void
186money2u(struct monst *mon, long amount)
187{
188 struct obj *mongold = findgold(mon->minvent);
189
190 if (amount <= 0) {
191 impossible("%s payment in money2u!", amount ? "negative" : "zero");
192 return;
193 }
194 if (!mongold || mongold->quan < amount) {
195 impossible("%s paying without %s gold?", a_monnam(mon),
196 mongold ? "enough" : "");
197 return;
198 }
199
200 if (mongold->quan > amount)
201 mongold = splitobj(mongold, amount);
202 obj_extract_self(mongold);
203
204 if (!merge_choice(gi.invent, mongold)
205 && inv_cnt(FALSE) >= invlet_basic) {
206 You("have no room for the gold!");
207 dropy(mongold);
208 } else {
209 addinv(mongold);
210 disp.botl = TRUE;
211 }
212}
213
214staticfn struct monst *
215next_shkp(struct monst *shkp, boolean withbill)

Callers 2

payFunction · 0.85
priest_talkFunction · 0.85

Calls 10

findgoldFunction · 0.85
a_monnamFunction · 0.85
splitobjFunction · 0.85
obj_extract_selfFunction · 0.85
merge_choiceFunction · 0.85
inv_cntFunction · 0.85
YouFunction · 0.85
dropyFunction · 0.85
addinvFunction · 0.85
impossibleFunction · 0.70

Tested by

no test coverage detected