From f89eba8aceed2c1d43ad58837eebb2f6deff29c0 Mon Sep 17 00:00:00 2001 From: Mark Langsdorf Date: Sat, 2 Nov 2019 10:50:10 -0500 Subject: [PATCH] recipe: include skill_used in required_skills_string() I don't want to know about how a recipe is storing the skills internally, I just want to print out what skills are needed to do something. --- src/recipe.cpp | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/src/recipe.cpp b/src/recipe.cpp index 7c2de1668e91c..66262f79d6ff7 100644 --- a/src/recipe.cpp +++ b/src/recipe.cpp @@ -438,11 +438,21 @@ bool recipe::has_byproducts() const std::string recipe::required_skills_string( const Character *c, bool print_skill_level ) const { if( required_skills.empty() ) { - return _( "none" ); + if( difficulty == 0 ) { + return _( "none" ); + } else { + const int player_skill = c ? c->get_skill_level( skill_used ) : 0; + std::string difficulty_color = difficulty > player_skill ? "yellow" : "green"; + std::string skill_level_string = print_skill_level ? "" : + ( std::to_string( player_skill ) + "/" ); + skill_level_string += std::to_string( difficulty ); + return string_format( "%s (%s)", + skill_used.obj().name(), difficulty_color, skill_level_string ); + } } return enumerate_as_string( required_skills.begin(), required_skills.end(), [&]( const std::pair &skill ) { - const auto player_skill = c ? c->get_skill_level( skill.first ) : 0; + const int player_skill = c ? c->get_skill_level( skill.first ) : 0; std::string difficulty_color = skill.second > player_skill ? "yellow" : "green"; std::string skill_level_string = print_skill_level ? "" : ( std::to_string( player_skill ) + "/" ); skill_level_string += std::to_string( skill.second ); @@ -459,7 +469,12 @@ std::string recipe::required_skills_string( const Character *c ) const std::string recipe::required_skills_string() const { if( required_skills.empty() ) { - return _( "none" ); + if( difficulty == 0 ) { + return _( "none" ); + } else { + return string_format( "%s: %d", skill_used.obj().name(), + difficulty ); + } } return enumerate_as_string( required_skills.begin(), required_skills.end(), [&]( const std::pair &skill ) {