does shkp's shop stock this item type? */
| 802 | |
| 803 | /* does shkp's shop stock this item type? */ |
| 804 | boolean |
| 805 | saleable(struct monst *shkp, struct obj *obj) |
| 806 | { |
| 807 | int i, shp_indx = ESHK(shkp)->shoptype - SHOPBASE; |
| 808 | const struct shclass *shp = &shtypes[shp_indx]; |
| 809 | |
| 810 | if (shp->symb == RANDOM_CLASS) |
| 811 | return TRUE; |
| 812 | for (i = 0; i < SIZE(shtypes[0].iprobs) && shp->iprobs[i].iprob; i++) { |
| 813 | /* pseudo-class needs special handling */ |
| 814 | if (shp->iprobs[i].itype == VEGETARIAN_CLASS) { |
| 815 | if (veggy_item(obj, 0)) |
| 816 | return TRUE; |
| 817 | } else if ((shp->iprobs[i].itype < 0) |
| 818 | ? shp->iprobs[i].itype == -obj->otyp |
| 819 | : shp->iprobs[i].itype == obj->oclass) |
| 820 | return TRUE; |
| 821 | } |
| 822 | /* not found */ |
| 823 | return FALSE; |
| 824 | } |
| 825 | |
| 826 | /* positive value: class; negative value: specific object type. |
| 827 | can also return non-existing object class (eg. VEGETARIAN_CLASS) */ |
no test coverage detected