give price quotes for all objects linked to this one (ie, on this spot) */
| 5403 | |
| 5404 | /* give price quotes for all objects linked to this one (ie, on this spot) */ |
| 5405 | void |
| 5406 | price_quote(struct obj *first_obj) |
| 5407 | { |
| 5408 | struct obj *otmp; |
| 5409 | char buf[BUFSZ], price[40]; |
| 5410 | long cost = 0L; |
| 5411 | int cnt = 0; |
| 5412 | boolean contentsonly = FALSE; |
| 5413 | winid tmpwin; |
| 5414 | struct monst *shkp; |
| 5415 | |
| 5416 | shkp = shop_keeper(inside_shop(u.ux, u.uy)); |
| 5417 | /* caller has verified that there is a shopkeeper, but the static |
| 5418 | analyzer doesn't realize it */ |
| 5419 | if (!shkp || !inhishop(shkp)) |
| 5420 | return; |
| 5421 | |
| 5422 | tmpwin = create_nhwindow(NHW_MENU); |
| 5423 | putstr(tmpwin, 0, "Fine goods for sale:"); |
| 5424 | putstr(tmpwin, 0, ""); |
| 5425 | for (otmp = first_obj; otmp; otmp = otmp->nexthere) { |
| 5426 | if (otmp->oclass == COIN_CLASS) |
| 5427 | continue; |
| 5428 | cost = (otmp->no_charge || otmp == uball || otmp == uchain) ? 0L |
| 5429 | : get_cost(otmp, shkp); |
| 5430 | contentsonly = !cost; |
| 5431 | if (Has_contents(otmp)) |
| 5432 | cost += contained_cost(otmp, shkp, 0L, FALSE, FALSE); |
| 5433 | if (otmp->globby) |
| 5434 | cost *= get_pricing_units(otmp); /* always quan 1, vary by wt */ |
| 5435 | if (!cost) { |
| 5436 | Strcpy(price, "no charge"); |
| 5437 | contentsonly = FALSE; |
| 5438 | } else { |
| 5439 | Sprintf(price, "%ld %s%s", cost, currency(cost), |
| 5440 | (otmp->quan) > 1L ? " each" : ""); |
| 5441 | } |
| 5442 | Sprintf(buf, "%s%s, %s", contentsonly ? the_contents_of : "", |
| 5443 | doname(otmp), price); |
| 5444 | putstr(tmpwin, 0, buf), cnt++; |
| 5445 | } |
| 5446 | if (cnt > 1) { |
| 5447 | display_nhwindow(tmpwin, TRUE); |
| 5448 | } else if (cnt == 1) { |
| 5449 | if (!cost) { |
| 5450 | /* "<doname(obj)>, no charge" */ |
| 5451 | SetVoice(shkp, 0, 80, 0); |
| 5452 | verbalize("%s!", upstart(buf)); /* buf contains the string */ |
| 5453 | } else { |
| 5454 | /* print cost in slightly different format, so can't reuse buf; |
| 5455 | cost and contentsonly are already set up */ |
| 5456 | Sprintf(buf, "%s%s", contentsonly ? the_contents_of : "", |
| 5457 | doname(first_obj)); |
| 5458 | SetVoice(shkp, 0, 80, 0); |
| 5459 | verbalize("%s, price %ld %s%s%s", upstart(buf), cost, |
| 5460 | currency(cost), (first_obj->quan > 1L) ? " each" : "", |
| 5461 | contentsonly ? "." : shk_embellish(first_obj, cost)); |
| 5462 | } |
no test coverage detected