* Decide whether a particular object can be eaten by the possibly * polymorphed character. Not used for monster checks. */
| 88 | * polymorphed character. Not used for monster checks. |
| 89 | */ |
| 90 | boolean |
| 91 | is_edible(struct obj *obj) |
| 92 | { |
| 93 | /* protect invocation tools but not Rider corpses (handled elsewhere)*/ |
| 94 | /* if (obj->oclass != FOOD_CLASS && obj_resists(obj, 0, 0)) */ |
| 95 | if (objects[obj->otyp].oc_unique) |
| 96 | return FALSE; |
| 97 | /* above also prevents the Amulet from being eaten, so we must never |
| 98 | allow fake amulets to be eaten either [which is already the case] */ |
| 99 | |
| 100 | if (gy.youmonst.data == &mons[PM_FIRE_ELEMENTAL] |
| 101 | && is_flammable(obj)) |
| 102 | return TRUE; |
| 103 | |
| 104 | if (metallivorous(gy.youmonst.data) && is_metallic(obj) |
| 105 | && (gy.youmonst.data != &mons[PM_RUST_MONSTER] || is_rustprone(obj))) |
| 106 | return TRUE; |
| 107 | |
| 108 | /* Ghouls only eat non-veggy corpses or eggs (see dogfood()) */ |
| 109 | if (u.umonnum == PM_GHOUL) |
| 110 | return (boolean)((obj->otyp == CORPSE |
| 111 | && !vegan(&mons[obj->corpsenm])) |
| 112 | || (obj->otyp == EGG)); |
| 113 | |
| 114 | if (u.umonnum == PM_GELATINOUS_CUBE && is_organic(obj) |
| 115 | /* [g-cubes can eat containers and retain all contents |
| 116 | as engulfed items, but poly'd player can't do that] */ |
| 117 | && !Has_contents(obj)) |
| 118 | return TRUE; |
| 119 | |
| 120 | return (boolean) (obj->oclass == FOOD_CLASS); |
| 121 | } |
| 122 | |
| 123 | /* used for hero init, life saving (if choking), and prayer results of fix |
| 124 | starving, fix weak from hunger, or golden glow boon (if u.uhunger < 900) */ |
no test coverage detected