本文整理汇总了C++中inventory::has_quality方法的典型用法代码示例。如果您正苦于以下问题:C++ inventory::has_quality方法的具体用法?C++ inventory::has_quality怎么用?C++ inventory::has_quality使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类inventory
的用法示例。
在下文中一共展示了inventory::has_quality方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: has
bool quality_requirement::has( const inventory &crafting_inv, int ) const
{
if( g->u.has_trait( "DEBUG_HS" ) ) {
return true;
}
return crafting_inv.has_quality( type, level, count );
}
示例2: has
bool quality_requirement::has( const inventory &crafting_inv, int,
std::function<void( int )> ) const
{
if( g->u.has_trait( trait_DEBUG_HS ) ) {
return true;
}
return crafting_inv.has_quality( type, level, count );
}
示例3: check_enough_materials
bool requirement_data::check_enough_materials( const item_comp &comp,
const inventory &crafting_inv, int batch ) const
{
if( comp.available != a_true ) {
return false;
}
const int cnt = std::abs( comp.count ) * batch;
const tool_comp *tq = find_by_type( tools, comp.type );
if( tq != nullptr && tq->available == a_true ) {
// The very same item type is also needed as tool!
// Use charges of it, or use it by count?
const int tc = tq->by_charges() ? 1 : std::abs( tq->count );
// Check for components + tool count. Check item amount (excludes
// pseudo items) and tool amount (includes pseudo items)
// Imagine: required = 1 welder (component) + 1 welder (tool),
// available = 1 welder (real item), 1 welding rig (creates
// a pseudo welder item). has_components(welder,2) returns false
// as there is only one real welder available, but has_tools(welder,2)
// returns true.
// Keep in mind that both requirements (tool+component) are checked
// before this. That assures that one real item is actually available,
// two welding rigs (and no real welder) would make this component
// non-available even before this function is called.
// Only ammo and (some) food is counted by charges, both are unlikely
// to appear as tool, but it's possible /-:
const item_comp i_tmp( comp.type, cnt + tc );
const tool_comp t_tmp( comp.type, -( cnt + tc ) ); // not by charges!
// batch factor is explicitly 1, because it's already included in the count.
if( !i_tmp.has( crafting_inv, 1 ) && !t_tmp.has( crafting_inv, 1 ) ) {
comp.available = a_insufficent;
}
}
const itype *it = item::find_type( comp.type );
for( const auto &ql : it->qualities ) {
const quality_requirement *qr = find_by_type( qualities, ql.first );
if( qr == nullptr || qr->level > ql.second ) {
continue;
}
// This item can be used for the quality requirement, same as above for specific
// tools applies.
if( !crafting_inv.has_quality( qr->type, qr->level, qr->count + abs( comp.count ) ) ) {
comp.available = a_insufficent;
}
}
return comp.available == a_true;
}
示例4: has
bool quality_requirement::has( const inventory &crafting_inv, int ) const
{
return crafting_inv.has_quality( type, level, count );
}