Skip to content

Commit

Permalink
Un-bold repair/disassembly headings; cleanup
Browse files Browse the repository at this point in the history
These sections don't need to draw the eye so much.

Also do a little bit of code refactoring to avoid unnecessary math.
  • Loading branch information
wapcaplet committed Feb 15, 2020
1 parent be30886 commit aba8f6f
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 23 deletions.
37 changes: 20 additions & 17 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1205,6 +1205,7 @@ void item::basic_info( std::vector<iteminfo> &info, const iteminfo_query *parts,
int dmg_cut = damage_melee( DT_CUT );
int dmg_stab = damage_melee( DT_STAB );
if( parts->test( iteminfo_parts::BASE_DAMAGE ) ) {
insert_separation_line( info );
std::string sep;
if( dmg_bash ) {
info.emplace_back( "BASE", _( "Bash: " ), "", iteminfo::no_newline, dmg_bash );
Expand Down Expand Up @@ -2703,13 +2704,12 @@ void item::repair_info( std::vector<iteminfo> &info, const iteminfo_query *parts
insert_separation_line( info );
const std::set<std::string> &rep = repaired_with();
if( !rep.empty() ) {
info.emplace_back( "DESCRIPTION", _( "<bold>Repair</bold>: using " ) +
info.emplace_back( "DESCRIPTION", _( "Repair using " ) +
enumerate_as_string( rep.begin(), rep.end(), []( const itype_id & e ) {
return nname( e );
}, enumeration_conjunction::or_ ) );
}, enumeration_conjunction::or_ ) + "." );
if( reinforceable() ) {
info.emplace_back( "DESCRIPTION", _( "* This item can be "
"<good>reinforced</good>." ) );
info.emplace_back( "DESCRIPTION", _( "* This item can be <good>reinforced</good>." ) );
}
} else {
info.emplace_back( "DESCRIPTION", _( "* This item is <bad>not repairable</bad>." ) );
Expand All @@ -2736,7 +2736,7 @@ void item::disassembly_info( std::vector<iteminfo> &info, const iteminfo_query *
} );
insert_separation_line( info );
info.push_back( iteminfo( "DESCRIPTION",
string_format( _( "<bold>Disassembly</bold>: takes %s and "
string_format( _( "Disassembly takes %s and "
"might yield: %s." ),
to_string_approx( time_duration::from_turns( dis.time /
100 ) ), components_list ) ) );
Expand Down Expand Up @@ -2917,15 +2917,18 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query *parts,

const std::string space = " ";

std::set<matec_id> all_techniques = type->techniques;
all_techniques.insert( techniques.begin(), techniques.end() );
if( !all_techniques.empty() && parts->test( iteminfo_parts::DESCRIPTION_TECHNIQUES ) ) {
insert_separation_line( info );
info.push_back( iteminfo( "DESCRIPTION", _( "<bold>Techniques when wielded</bold>: " ) +
enumerate_as_string( all_techniques.begin(), all_techniques.end(), []( const matec_id & tid ) {
return string_format( "<stat>%s</stat>: <info>%s</info>", _( tid.obj().name ),
_( tid.obj().description ) );
} ) ) );
if( parts->test( iteminfo_parts::DESCRIPTION_TECHNIQUES ) ) {
std::set<matec_id> all_techniques = type->techniques;
all_techniques.insert( techniques.begin(), techniques.end() );

if( !all_techniques.empty() ) {
insert_separation_line( info );
info.push_back( iteminfo( "DESCRIPTION", _( "<bold>Techniques when wielded</bold>: " ) +
enumerate_as_string( all_techniques.begin(), all_techniques.end(), []( const matec_id & tid ) {
return string_format( "<stat>%s</stat>: <info>%s</info>", _( tid.obj().name ),
_( tid.obj().description ) );
} ) ) );
}
}

if( !is_gunmod() && has_flag( "REACH_ATTACK" ) &&
Expand All @@ -2943,10 +2946,9 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query *parts,
}

///\EFFECT_MELEE >2 allows seeing melee damage stats on weapons
if( debug_mode ||
( g->u.get_skill_level( skill_melee ) > 2 &&
if( ( g->u.get_skill_level( skill_melee ) > 2 &&
( damage_melee( DT_BASH ) > 0 || damage_melee( DT_CUT ) > 0 ||
damage_melee( DT_STAB ) > 0 || type->m_to_hit > 0 ) ) ) {
damage_melee( DT_STAB ) > 0 || type->m_to_hit > 0 ) ) || debug_mode ) {
damage_instance non_crit;
g->u.roll_all_damage( false, non_crit, true, *this );
damage_instance crit;
Expand Down Expand Up @@ -3001,6 +3003,7 @@ void item::final_info( std::vector<iteminfo> &info, const iteminfo_query *parts,
}
}


if( parts->test( iteminfo_parts::DESCRIPTION_USE_METHODS ) ) {
for( const std::pair<const std::string, use_function> &method : type->use_methods ) {
insert_separation_line( info );
Expand Down
13 changes: 7 additions & 6 deletions tests/iteminfo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ TEST_CASE( "weapon attack ratings and moves", "[item][iteminfo][weapon]" )

iteminfo_test(
item( "halligan" ), q,
"--\n"
"Bash: <color_c_yellow>20</color>"
" Cut: <color_c_yellow>5</color>"
" To-hit bonus: <color_c_yellow>+2</color>\n"
Expand Down Expand Up @@ -295,12 +296,12 @@ TEST_CASE( "repairable and with what tools", "[item][iteminfo][repair]" )
iteminfo_test(
item( "halligan" ), q,
"--\n"
"<color_c_white>Repair</color>: using extended toolset, arc welder, or makeshift arc welder\n" );
"Repair using extended toolset, arc welder, or makeshift arc welder.\n" );

iteminfo_test(
item( "hazmat_suit" ), q,
"--\n"
"<color_c_white>Repair</color>: using soldering iron or extended toolset\n" );
"Repair using soldering iron or extended toolset.\n" );

iteminfo_test(
item( "rock" ), q,
Expand All @@ -323,23 +324,23 @@ TEST_CASE( "disassembly time and yield", "[item][iteminfo][disassembly]" )
iteminfo_test(
item( "string_36" ), q,
"--\n"
"<color_c_white>Disassembly</color>: takes about 5 minutes and might yield: 6 short strings.\n" );
"Disassembly takes about 5 minutes and might yield: 6 short strings.\n" );

// short string
iteminfo_test(
item( "string_6" ), q,
"--\n"
"<color_c_white>Disassembly</color>: takes about 5 minutes and might yield: thread (50).\n" );
"Disassembly takes about 5 minutes and might yield: thread (50).\n" );

iteminfo_test(
item( "sheet_metal" ), q,
"--\n"
"<color_c_white>Disassembly</color>: takes about 2 minutes and might yield: small metal sheet (24).\n" );
"Disassembly takes about 2 minutes and might yield: small metal sheet (24).\n" );

iteminfo_test(
item( "soldering_iron" ), q,
"--\n"
"<color_c_white>Disassembly</color>: takes about 20 minutes and might yield:"
"Disassembly takes about 20 minutes and might yield:"
" 2 electronic scraps, copper (1), scrap metal (1), and copper wire (5).\n" );

}
Expand Down

0 comments on commit aba8f6f

Please sign in to comment.