* Transfer money from monster to inventory. * Used when the shopkeeper pay for items, and when * the priest gives you money for an ale. */
| 183 | * the priest gives you money for an ale. |
| 184 | */ |
| 185 | void |
| 186 | money2u(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 | |
| 214 | staticfn struct monst * |
| 215 | next_shkp(struct monst *shkp, boolean withbill) |
no test coverage detected