Esempio n. 1
0
void stomach_contents::ingest( player &p, item &food, int charges = 1 )
{
    item comest;
    if( food.is_container() ) {
        comest = food.get_contained();
    } else {
        comest = food;
    }
    if( charges == 0 ) {
        // if charges is 0, it means the item is not count_by_charges
        charges = 1;
    }
    // maybe move tapeworm to digestion
    for( const auto &v : p.vitamins_from( comest ) ) {
        vitamins[v.first] += p.has_effect( efftype_id( "tapeworm" ) ) ? v.second / 2 : v.second;
    }
    auto &comest_t = comest.type->comestible;
    const units::volume add_water = std::max( 0_ml, comest_t->quench * 5_ml );
    // if this number is negative, we decrease the quench/increase the thirst of the player
    if( comest_t->quench < 0 ) {
        p.mod_thirst( -comest_t->quench );
    } else {
        mod_quench( comest_t->quench );
    }
    // @TODO: Move quench values to mL and remove the magic number here
    mod_contents( ( comest.base_volume() * charges ) - add_water );

    last_ate = calendar::turn;

    mod_calories( comest_t->get_calories() );
}
Esempio n. 2
0
/*static*/ bool inventory::has_category(const item& it, item_cat cat, const player& u) {
    switch (cat)
    {
    case IC_COMESTIBLE: // food
        if (it.is_food(&u) || it.is_food_container(&u))
        {
             return true;
        }
        break;
    case IC_AMMO: // ammo
        if (it.is_ammo() || it.is_ammo_container())
        {
             return true;
        }
        break;
    case IC_ARMOR: // armour
        if (it.is_armor())
        {
             return true;
        }
        break;
    case IC_BOOK: // books
        if (it.is_book())
        {
             return true;
        }
        break;
    case IC_TOOL: // tools
        if (it.is_tool())
        {
             return true;
        }
        break;
    case IC_CONTAINER: // containers for liquid handling
        if (it.is_tool() || it.is_gun())
        {
            if (it.ammo_type() == "gasoline")
            {
                return true;
            }
        }
        else
        {
            if (it.is_container())
            {
                return true;
            }
        }
        break;
    }
    return false;
}