@@ -1383,6 +1383,7 @@ void firestarter_actor::load( const JsonObject &obj, const std::string & )
13831383 optional ( obj, false , " moves" , moves_cost_fast, 100 );
13841384 optional ( obj, false , " moves_slow" , moves_cost_slow, 1000 );
13851385 optional ( obj, false , " need_sunlight" , need_sunlight, false );
1386+ optional ( obj, false , " qualities_needed" , qualities_needed );
13861387}
13871388
13881389std::unique_ptr<iuse_actor> firestarter_actor::clone () const
@@ -1532,6 +1533,30 @@ ret_val<void> firestarter_actor::can_use( const Character &p, const item &it,
15321533 return ret_val<void >::make_failure ( _ ( " You need direct sunlight to light a fire with this." ) );
15331534 }
15341535
1536+ if ( qualities_needed.empty () ) {
1537+ return ret_val<void >::make_success ();
1538+ }
1539+
1540+ std::map<quality_id, int > unmet_reqs;
1541+ inventory inv;
1542+ inv.form_from_map ( p.pos_bub ( *here ), 1 , &p, true , true );
1543+ for ( const auto &quality : qualities_needed ) {
1544+ if ( !p.has_quality ( quality.first , quality.second ) &&
1545+ !inv.has_quality ( quality.first , quality.second ) ) {
1546+ unmet_reqs.insert ( quality );
1547+ }
1548+ }
1549+ if ( unmet_reqs.empty () ) {
1550+ return ret_val<void >::make_success ();
1551+ }
1552+ std::string unmet_reqs_string = enumerate_as_string ( unmet_reqs.begin (), unmet_reqs.end (),
1553+ [&]( const std::pair<quality_id, int > &unmet_req ) {
1554+ return string_format ( " %s %d" , unmet_req.first .obj ().name , unmet_req.second );
1555+ } );
1556+ return ret_val<void >::make_failure ( n_gettext ( " You need a tool with %s." ,
1557+ " You need tools with %s." ,
1558+ unmet_reqs.size () ), unmet_reqs_string );
1559+
15351560 return ret_val<void >::make_success ();
15361561}
15371562
0 commit comments