bool requirements::can_make_with_inventory( const inventory &crafting_inv ) const { bool retval = true; // Doing this in several steps avoids C++ Short-circuit evaluation // and makes sure that the available value is set for every entry retval &= has_comps(crafting_inv, qualities); retval &= has_comps(crafting_inv, tools); retval &= has_comps(crafting_inv, components); retval &= check_enough_materials(crafting_inv); return retval; }
bool requirement_data::check_enough_materials( const inventory &crafting_inv, int batch ) const { bool retval = true; for( const auto &component_choices : components ) { bool atleast_one_available = false; for( const auto &comp : component_choices ) { if( check_enough_materials( comp, crafting_inv, batch ) ) { atleast_one_available = true; } } if( !atleast_one_available ) { retval = false; } } return retval; }
bool requirement_data::can_make_with_inventory( const inventory &crafting_inv, int batch ) const { bool retval = true; // All functions must be called to update the available settings in the components. if( !has_comps( crafting_inv, qualities ) ) { retval = false; } if( !has_comps( crafting_inv, tools, batch ) ) { retval = false; } if( !has_comps( crafting_inv, components, batch ) ) { retval = false; } if( !check_enough_materials( crafting_inv, batch ) ) { retval = false; } return retval; }