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

Function rob_shop

src/shk.c:686–719  ·  view source on GitHub ↗

shop merchandise has been taken; pay for it with any credit available; return false if the debt is fully covered by credit, true otherwise */

Source from the content-addressed store, hash-verified

684/* shop merchandise has been taken; pay for it with any credit available;
685 return false if the debt is fully covered by credit, true otherwise */
686staticfn boolean
687rob_shop(struct monst *shkp)
688{
689 struct eshk *eshkp;
690 long total;
691
692 eshkp = ESHK(shkp);
693 rouse_shk(shkp, TRUE);
694 total = (addupbill(shkp) + eshkp->debit);
695 if (eshkp->credit >= total) {
696 Your("credit of %ld %s is used to cover your shopping bill.",
697 eshkp->credit, currency(eshkp->credit));
698 total = 0L; /* credit gets cleared by setpaid() */
699 } else {
700 You("escaped the shop without paying!");
701 total -= eshkp->credit;
702 }
703 setpaid(shkp);
704 if (!total)
705 return FALSE;
706
707 /* by this point, we know an actual robbery has taken place */
708 eshkp->robbed += total;
709 You("stole %ld %s worth of merchandise.", total, currency(total));
710 livelog_printf(LL_ACHIEVE, "stole %ld %s worth of merchandise from %s %s",
711 total, currency(total), s_suffix(shkname(shkp)),
712 shtypes[eshkp->shoptype - SHOPBASE].name);
713
714 if (!Role_if(PM_ROGUE)) /* stealing is unlawful */
715 adjalign(-sgn(u.ualign.type));
716
717 hot_pursuit(shkp);
718 return TRUE;
719}
720
721/* give a message when entering an untended shop (caller has verified that) */
722staticfn void

Callers 2

u_left_shopFunction · 0.85
remote_burglaryFunction · 0.85

Calls 12

rouse_shkFunction · 0.85
addupbillFunction · 0.85
YourFunction · 0.85
currencyFunction · 0.85
YouFunction · 0.85
setpaidFunction · 0.85
livelog_printfFunction · 0.85
s_suffixFunction · 0.85
shknameFunction · 0.85
adjalignFunction · 0.85
sgnFunction · 0.85
hot_pursuitFunction · 0.85

Tested by

no test coverage detected