Skip to content

Commit

Permalink
recipe: include skill_used in required_skills_string()
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
mlangsdorf committed Nov 4, 2019
1 parent 9db3515 commit f89eba8
Showing 1 changed file with 18 additions and 3 deletions.
21 changes: 18 additions & 3 deletions src/recipe.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 _( "<color_cyan>none</color>" );
if( difficulty == 0 ) {
return _( "<color_cyan>none</color>" );
} 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( "<color_cyan>%s</color> <color_%s>(%s)</color>",
skill_used.obj().name(), difficulty_color, skill_level_string );
}
}
return enumerate_as_string( required_skills.begin(), required_skills.end(),
[&]( const std::pair<skill_id, int> &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 );
Expand All @@ -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 _( "<color_white>none</color>" );
if( difficulty == 0 ) {
return _( "<color_cyan>none</color>" );
} else {
return string_format( "<color_white>%s: %d</color>", skill_used.obj().name(),
difficulty );
}
}
return enumerate_as_string( required_skills.begin(), required_skills.end(),
[&]( const std::pair<skill_id, int> &skill ) {
Expand Down

0 comments on commit f89eba8

Please sign in to comment.