for menustyle=Traditional, choose between paying for everything (by declining to itemize), asking item-by-item (by accepting itemization), or switch to selecting via menu (special 'm' answer at "Itemize? [ynq m]" prompt); for other menustyles, always select via menu; player can use 'm' prefix before 'p' command to invert those behaviors; once the method is chosen, actually pay for t
| 2042 | once the method is chosen, actually pay for the selected items, item by |
| 2043 | item for as long as hero has enough credit+cash */ |
| 2044 | staticfn boolean |
| 2045 | pay_billed_items( |
| 2046 | struct monst *shkp, |
| 2047 | int ibillct, |
| 2048 | Bill *ibill, |
| 2049 | boolean stashed_gold, |
| 2050 | boolean *paid_p) /* output */ |
| 2051 | { |
| 2052 | struct bill_x *bp; |
| 2053 | struct obj *otmp; |
| 2054 | long umoney; |
| 2055 | boolean itemize, more_than_one; |
| 2056 | boolean queuedpay = FALSE, via_menu; |
| 2057 | int buy, indx, bidx, pass, iprompt, ebillct; |
| 2058 | struct eshk *eshkp = ESHK(shkp); |
| 2059 | |
| 2060 | umoney = money_cnt(gi.invent); |
| 2061 | if (!umoney && !eshkp->credit) { |
| 2062 | You("%shave no gold or credit%s.", |
| 2063 | stashed_gold ? "seem to " : "", *paid_p ? " left" : ""); |
| 2064 | return TRUE; |
| 2065 | } |
| 2066 | bp = eshkp->bill_p; |
| 2067 | otmp = bp_to_obj(bp); |
| 2068 | ebillct = eshkp->billct; |
| 2069 | more_than_one = (ebillct > 1 || otmp->quan < bp->bquan |
| 2070 | /* note: will only get here for a single item, so |
| 2071 | we can deduce that it is ibill[0] */ |
| 2072 | || ibill[0].usedup == UndisclosedContainer); |
| 2073 | if ((umoney + eshkp->credit) < cheapest_item(ibillct, ibill)) { |
| 2074 | You("don't have enough gold to buy%s the item%s %s.", |
| 2075 | more_than_one ? " any of" : "", plur(more_than_one ? 2 : 1), |
| 2076 | (ebillct > 1) ? "you've picked" : "on your bill"); |
| 2077 | if (stashed_gold) |
| 2078 | pline("Maybe you have some gold stashed away?"); |
| 2079 | return TRUE; |
| 2080 | } |
| 2081 | |
| 2082 | via_menu = (flags.menu_style != MENU_TRADITIONAL); |
| 2083 | /* allow 'm p' to request a menu for menustyle:traditional; |
| 2084 | for other styles, it will do the opposite; that doesn't make |
| 2085 | a whole lot of sense for a 'request-menu' prefix, but otherwise |
| 2086 | it would simply be redundant and there wouldn't be any way to |
| 2087 | skip the menu when hero owes for multiple items */ |
| 2088 | if (iflags.menu_requested) |
| 2089 | via_menu = !via_menu; |
| 2090 | /* this will loop for a second iteration iff not initially using a |
| 2091 | menu and player answers 'm' at custom ynq prompt */ |
| 2092 | do { |
| 2093 | if (via_menu /*&& more_than_one*/ ) { |
| 2094 | if (!menu_pick_pay_items(ibillct, ibill)) |
| 2095 | return TRUE; |
| 2096 | queuedpay = TRUE; |
| 2097 | itemize = FALSE; |
| 2098 | via_menu = FALSE; /* reset so that we don't loop */ |
| 2099 | } else { |
| 2100 | iprompt = !more_than_one ? 'y' |
| 2101 | : yn_function("Itemized billing?", "ynq m", 'q', TRUE); |
no test coverage detected