Skip to content

Commit

Permalink
Merge pull request #40073 from jbytheway/dps_test_cleanup
Browse files Browse the repository at this point in the history
DPS test cleanup
  • Loading branch information
ifreund authored May 2, 2020
2 parents 771b6be + 1c10133 commit b4fbce7
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 12 deletions.
9 changes: 1 addition & 8 deletions src/melee.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2392,14 +2392,7 @@ melee_statistic_data melee::get_stats()

void melee::clear_stats()
{
melee_stats.attack_count = 0;
melee_stats.hit_count = 0;
melee_stats.double_crit_count = 0;
melee_stats.crit_count = 0;
melee_stats.double_crit_chance = 0.0;
melee_stats.crit_chance = 0.0;
melee_stats.actual_crit_count = 0;
melee_stats.damage_amount = 0;
melee_stats = melee_statistic_data{};
}

namespace melee
Expand Down
11 changes: 7 additions & 4 deletions tests/effective_dps_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,6 @@ static double weapon_dps_trials( avatar &attacker, monster &defender, item &weap
clear_character( attacker );
REQUIRE( attacker.can_wield( weapon ).success() );


// FIXME: This is_wielding check always fails
//REQUIRE( attacker.is_wielding( weapon ) );

melee::clear_stats();
melee_statistic_data melee_stats = melee::get_stats();
// rerun the trials in groups of 1000 until 100 crits occur
Expand All @@ -38,6 +34,10 @@ static double weapon_dps_trials( avatar &attacker, monster &defender, item &weap
// Reset and re-wield weapon before each attack to prevent skill-up during trials
clear_character( attacker );
attacker.wield( weapon );
// Verify that wielding worked (and not e.g. using martial arts
// instead)
REQUIRE( attacker.used_weapon().type == weapon.type );

int before_moves = attacker.get_moves();

// Keep the defender at maximum health
Expand Down Expand Up @@ -83,6 +83,9 @@ static void check_accuracy_dps( avatar &attacker, monster &defender, item &wpn1,
REQUIRE( wpn1_stats.hit_count > 0 );
REQUIRE( wpn2_stats.hit_count > 0 );
REQUIRE( wpn3_stats.hit_count > 0 );
CAPTURE( wpn1_stats.attack_count );
CAPTURE( wpn2_stats.attack_count );
CAPTURE( wpn3_stats.attack_count );
double wpn1_hit_rate = static_cast<double>( wpn1_stats.hit_count ) / wpn1_stats.attack_count;
double wpn2_hit_rate = static_cast<double>( wpn2_stats.hit_count ) / wpn2_stats.attack_count;
double wpn3_hit_rate = static_cast<double>( wpn3_stats.hit_count ) / wpn3_stats.attack_count;
Expand Down
2 changes: 2 additions & 0 deletions tests/player_helpers.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,8 @@ bool player_has_item_of_type( const std::string &type )

void clear_character( player &dummy, bool debug_storage )
{
dummy.normalize(); // In particular this clears martial arts style

// Remove first worn item until there are none left.
std::list<item> temp;
while( dummy.takeoff( dummy.i_at( -2 ), &temp ) );
Expand Down

0 comments on commit b4fbce7

Please sign in to comment.