diff --git a/src/requirements.cpp b/src/requirements.cpp index ba5f4a0e712fa..473921f9b5579 100644 --- a/src/requirements.cpp +++ b/src/requirements.cpp @@ -736,17 +736,21 @@ bool requirement_data::has_comps( const read_only_visitable &crafting_inv, { bool retval = true; int total_UPS_charges_used = 0; - for( const auto &set_of_tools : vec ) { + for( const std::vector &set_of_tools : vec ) { bool has_tool_in_set = false; int UPS_charges_used = std::numeric_limits::max(); const std::function use_ups = [ &UPS_charges_used ]( int charges ) { UPS_charges_used = std::min( UPS_charges_used, charges ); }; - for( const auto &tool : set_of_tools ) { + for( const T &tool : set_of_tools ) { if( tool.has( crafting_inv, filter, batch, flags, use_ups ) ) { tool.available = available_status::a_true; } else { + // Trying to track down why the crafting tests are failing? + // Uncomment the below to see the group of requirements that are lacking satisfaction + // Add a printf("\n") to the loop above this to separate different groups onto a separate line + // printf( "T: %s ", tool.type.str().c_str() ); tool.available = available_status::a_false; } has_tool_in_set = has_tool_in_set || tool.available == available_status::a_true; diff --git a/tests/crafting_test.cpp b/tests/crafting_test.cpp index 4113b50e61887..dd5d95b99cb97 100644 --- a/tests/crafting_test.cpp +++ b/tests/crafting_test.cpp @@ -428,6 +428,7 @@ TEST_CASE( "tools use charge to craft", "[crafting][charge]" ) tools.insert( tools.end(), 2, item( "blade" ) ); tools.insert( tools.end(), 5, item( "cable" ) ); tools.insert( tools.end(), 2, item( "polycarbonate_sheet" ) ); + tools.insert( tools.end(), 1, item( "knife_paring" ) ); tools.emplace_back( "motor_tiny" ); tools.emplace_back( "power_supply" ); tools.emplace_back( "scrap" ); @@ -437,8 +438,8 @@ TEST_CASE( "tools use charge to craft", "[crafting][charge]" ) // - 10 charges of surface heat WHEN( "each tool has enough charges" ) { - item hotplate = tool_with_ammo( "hotplate", 20 ); - REQUIRE( hotplate.ammo_remaining() == 20 ); + item hotplate = tool_with_ammo( "hotplate", 30 ); + REQUIRE( hotplate.ammo_remaining() == 30 ); tools.push_back( hotplate ); item soldering = tool_with_ammo( "soldering_iron", 20 ); REQUIRE( soldering.ammo_remaining() == 20 ); @@ -459,6 +460,7 @@ TEST_CASE( "tools use charge to craft", "[crafting][charge]" ) WHEN( "multiple tools have enough combined charges" ) { tools.insert( tools.end(), 2, tool_with_ammo( "hotplate", 5 ) ); tools.insert( tools.end(), 2, tool_with_ammo( "soldering_iron", 5 ) ); + tools.insert( tools.end(), 1, tool_with_ammo( "vac_mold", 4 ) ); THEN( "crafting succeeds, and uses charges from multiple tools" ) { prep_craft( recipe_id( "carver_off" ), tools, true ); @@ -477,9 +479,10 @@ TEST_CASE( "tools use charge to craft", "[crafting][charge]" ) tools.push_back( soldering_iron ); item UPS( "UPS_off" ); item UPS_mag( UPS.magazine_default() ); - UPS_mag.ammo_set( UPS_mag.ammo_default(), 500 ); + UPS_mag.ammo_set( UPS_mag.ammo_default(), 510 ); UPS.put_in( UPS_mag, item_pocket::pocket_type::MAGAZINE_WELL ); tools.emplace_back( UPS ); + tools.push_back( tool_with_ammo( "vac_mold", 4 ) ); THEN( "crafting succeeds, and uses charges from the UPS" ) { prep_craft( recipe_id( "carver_off" ), tools, true );