From c1441bbbc6db1c48f6b84a93c32fc3ed7562dbf0 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sat, 2 May 2020 06:37:58 -0400 Subject: [PATCH 1/3] Simplify melee::clear_stats --- src/melee.cpp | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/src/melee.cpp b/src/melee.cpp index 3e9b024766f38..074138351489a 100644 --- a/src/melee.cpp +++ b/src/melee.cpp @@ -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 From 870dd4f5925292655be1e31934368c2ec4650348 Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sat, 2 May 2020 06:40:22 -0400 Subject: [PATCH 2/3] Updates to dps tests - Capture more values. - Verify that weapon is wielded. - Remove some dead code. --- tests/effective_dps_test.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/tests/effective_dps_test.cpp b/tests/effective_dps_test.cpp index 9d05096d406ef..3e715c2be032f 100644 --- a/tests/effective_dps_test.cpp +++ b/tests/effective_dps_test.cpp @@ -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 @@ -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 @@ -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( wpn1_stats.hit_count ) / wpn1_stats.attack_count; double wpn2_hit_rate = static_cast( wpn2_stats.hit_count ) / wpn2_stats.attack_count; double wpn3_hit_rate = static_cast( wpn3_stats.hit_count ) / wpn3_stats.attack_count; From 1c1013346a93feb6be93581e50391d833d608d0b Mon Sep 17 00:00:00 2001 From: John Bytheway Date: Sat, 2 May 2020 06:41:44 -0400 Subject: [PATCH 3/3] Clear martial arts style in clear_character Having a martial arts style selected can cause problems for the melee tests. Ensure that we don't have one set. --- tests/player_helpers.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/player_helpers.cpp b/tests/player_helpers.cpp index 90e45094e8a83..9d7f0208e435e 100644 --- a/tests/player_helpers.cpp +++ b/tests/player_helpers.cpp @@ -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 temp; while( dummy.takeoff( dummy.i_at( -2 ), &temp ) );