Skip to content

Commit

Permalink
Display damage per second in the item info (#38600)
Browse files Browse the repository at this point in the history
* Display damage per second in the item info

So you can quickly eyeball the weapon effectiveness versus plain meatbags

* Added DPS to tests
  • Loading branch information
l29ah authored Mar 18, 2020
1 parent 3bb953e commit 924f105
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
4 changes: 4 additions & 0 deletions src/item.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1212,6 +1212,10 @@ void item::basic_info( std::vector<iteminfo> &info, const iteminfo_query *parts,
if( parts->test( iteminfo_parts::BASE_MOVES ) ) {
info.push_back( iteminfo( "BASE", _( "Moves per attack: " ), "",
iteminfo::lower_is_better, attack_time() ) );
double dps = ( dmg_bash + dmg_cut + dmg_stab ) * to_moves<int>( 1_seconds ) /
static_cast<double>( attack_time() );
info.push_back( iteminfo( "BASE", _( "Damage per second: " ), "",
iteminfo::is_decimal, dps ) );
}
}

Expand Down
3 changes: 2 additions & 1 deletion tests/iteminfo_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,8 @@ TEST_CASE( "weapon attack ratings and moves", "[item][iteminfo]" )
"Bash: <color_c_yellow>20</color>"
" Cut: <color_c_yellow>5</color>"
" To-hit bonus: <color_c_yellow>+2</color>\n"
"Moves per attack: <color_c_yellow>145</color>\n" );
"Moves per attack: <color_c_yellow>145</color>\n"
"Damage per second: <color_c_yellow>17.24</color>\n" );

}

Expand Down

0 comments on commit 924f105

Please sign in to comment.