本文整理汇总了C++中item::is_food_container方法的典型用法代码示例。如果您正苦于以下问题:C++ item::is_food_container方法的具体用法?C++ item::is_food_container怎么用?C++ item::is_food_container使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类item
的用法示例。
在下文中一共展示了item::is_food_container方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: switch
/*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;
}
示例2: rate_action_eat
hint_rating player::rate_action_eat( const item &it ) const
{
if( !it.is_food_container( this ) && !it.is_food( this ) ) {
return HINT_CANT;
}
const auto rating = can_eat( it );
if( rating == EDIBLE ) {
return HINT_GOOD;
} else if( rating == INEDIBLE || rating == INEDIBLE_MUTATION ) {
return HINT_CANT;
}
return HINT_IFFY;
}
示例3: get_near_zone_type_for_item
zone_type_id zone_manager::get_near_zone_type_for_item( const item &it,
const tripoint &where ) const
{
auto cat = it.get_category();
if( it.has_flag( "FIREWOOD" ) ) {
if( has_near( zone_type_id( "LOOT_WOOD" ), where ) ) {
return zone_type_id( "LOOT_WOOD" );
}
}
if( cat.id() == "food" ) {
const bool preserves = it.is_food_container() && it.type->container->preserves;
const auto &it_food = it.is_food_container() ? it.contents.front() : it;
if( it_food.is_food() ) { // skip food without comestible, like MREs
if( it_food.get_comestible()->comesttype == "DRINK" ) {
if( !preserves && it_food.goes_bad() && has_near( zone_type_id( "LOOT_PDRINK" ), where ) ) {
return zone_type_id( "LOOT_PDRINK" );
} else if( has_near( zone_type_id( "LOOT_DRINK" ), where ) ) {
return zone_type_id( "LOOT_DRINK" );
}
}
if( !preserves && it_food.goes_bad() && has_near( zone_type_id( "LOOT_PFOOD" ), where ) ) {
return zone_type_id( "LOOT_PFOOD" );
}
}
return zone_type_id( "LOOT_FOOD" );
}
if( cat.id() == "guns" ) {
return zone_type_id( "LOOT_GUNS" );
}
if( cat.id() == "magazines" ) {
return zone_type_id( "LOOT_MAGAZINES" );
}
if( cat.id() == "ammo" ) {
return zone_type_id( "LOOT_AMMO" );
}
if( cat.id() == "weapons" ) {
return zone_type_id( "LOOT_WEAPONS" );
}
if( cat.id() == "tools" ) {
return zone_type_id( "LOOT_TOOLS" );
}
if( cat.id() == "clothing" ) {
if( it.is_filthy() && has_near( zone_type_id( "LOOT_FCLOTHING" ), where ) ) {
return zone_type_id( "LOOT_FCLOTHING" );
}
return zone_type_id( "LOOT_CLOTHING" );
}
if( cat.id() == "drugs" ) {
return zone_type_id( "LOOT_DRUGS" );
}
if( cat.id() == "books" ) {
return zone_type_id( "LOOT_BOOKS" );
}
if( cat.id() == "mods" ) {
return zone_type_id( "LOOT_MODS" );
}
if( cat.id() == "mutagen" ) {
return zone_type_id( "LOOT_MUTAGENS" );
}
if( cat.id() == "bionics" ) {
return zone_type_id( "LOOT_BIONICS" );
}
if( cat.id() == "veh_parts" ) {
return zone_type_id( "LOOT_VEHICLE_PARTS" );
}
if( cat.id() == "other" ) {
return zone_type_id( "LOOT_OTHER" );
}
if( cat.id() == "fuel" ) {
return zone_type_id( "LOOT_FUEL" );
}
if( cat.id() == "seeds" ) {
return zone_type_id( "LOOT_SEEDS" );
}
if( cat.id() == "chems" ) {
return zone_type_id( "LOOT_CHEMICAL" );
}
if( cat.id() == "spare_parts" ) {
return zone_type_id( "LOOT_SPARE_PARTS" );
}
if( cat.id() == "artifacts" ) {
return zone_type_id( "LOOT_ARTIFACTS" );
}
if( cat.id() == "armor" ) {
if( it.is_filthy() && has_near( zone_type_id( "LOOT_FARMOR" ), where ) ) {
return zone_type_id( "LOOT_FARMOR" );
}
return zone_type_id( "LOOT_ARMOR" );
}
return zone_type_id();
}
示例4: can_disassemble
bool player::can_disassemble( const item &obj, const inventory &inv, std::string *err ) const
{
const auto error = [&err]( const std::string & message ) {
if( err != nullptr ) {
*err = message;
}
return false;
};
const auto &r = recipe_dictionary::get_uncraft( obj.typeId() );
if( !r ) {
return error( string_format( _( "You cannot disassemble this." ) ) );
}
// check sufficient light
if( lighting_craft_speed_multiplier( r ) == 0.0f ) {
return error( _( "You can't see to craft!" ) );
}
// refuse to disassemble rotten items
if( obj.goes_bad() || ( obj.is_food_container() && obj.contents.front().goes_bad() ) ) {
if( obj.rotten() || ( obj.is_food_container() && obj.contents.front().rotten() ) ) {
return error( _( "It's rotten, I'm not taking that apart." ) );
}
}
if( obj.count_by_charges() && !r.has_flag( "UNCRAFT_SINGLE_CHARGE" ) ) {
// Create a new item to get the default charges
int qty = r.create_result().charges;
if( obj.charges < qty ) {
auto msg = ngettext( "You need at least %d charge of %s.",
"You need at least %d charges of %s.", qty );
return error( string_format( msg, qty, obj.tname().c_str() ) );
}
}
const auto &dis = r.disassembly_requirements();
for( const auto &opts : dis.get_qualities() ) {
for( const auto &qual : opts ) {
if( !qual.has( inv ) ) {
// Here should be no dot at the end of the string as 'to_string()' provides it.
return error( string_format( _( "You need %s" ), qual.to_string().c_str() ) );
}
}
}
for( const auto &opts : dis.get_tools() ) {
const bool found = std::any_of( opts.begin(), opts.end(),
[&]( const tool_comp & tool ) {
return ( tool.count <= 0 && inv.has_tools( tool.type, 1 ) ) ||
( tool.count > 0 && inv.has_charges( tool.type, tool.count ) );
} );
if( !found ) {
if( opts.front().count <= 0 ) {
return error( string_format( _( "You need %s." ),
item::nname( opts.front().type ).c_str() ) );
} else {
return error( string_format( ngettext( "You need a %s with %d charge.",
"You need a %s with %d charges.",
opts.front().count ),
item::nname( opts.front().type ).c_str(), opts.front().count ) );
}
}
}
return true;
}