* Transfer money from inventory to monster when paying * shopkeepers, priests, oracle, succubus, and other demons. * Simple with only gold coins. * This routine will handle money changing when multiple * coin types is implemented, only appropriate * monsters will pay change. (Peaceful shopkeepers, priests * and the oracle try to maintain goodwill while selling * their wares or serv
| 154 | * if the monster kept the change. |
| 155 | */ |
| 156 | long |
| 157 | money2mon(struct monst *mon, long amount) |
| 158 | { |
| 159 | struct obj *ygold = findgold(gi.invent); |
| 160 | |
| 161 | if (amount <= 0) { |
| 162 | impossible("%s payment in money2mon!", amount ? "negative" : "zero"); |
| 163 | return 0L; |
| 164 | } |
| 165 | if (!ygold || ygold->quan < amount) { |
| 166 | impossible("Paying without %s gold?", ygold ? "enough" : ""); |
| 167 | return 0L; |
| 168 | } |
| 169 | |
| 170 | if (ygold->quan > amount) |
| 171 | ygold = splitobj(ygold, amount); |
| 172 | else if (ygold->owornmask) |
| 173 | remove_worn_item(ygold, FALSE); /* quiver */ |
| 174 | freeinv(ygold); |
| 175 | add_to_minv(mon, ygold); |
| 176 | disp.botl = TRUE; |
| 177 | return amount; |
| 178 | } |
| 179 | |
| 180 | /* |
| 181 | * Transfer money from monster to inventory. |
no test coverage detected