From d4ac7da2bd06abdc31713c4253e711ccffb6319f Mon Sep 17 00:00:00 2001
From: wheals <shm.mark@gmail.com>
Date: Fri, 27 Dec 2013 12:14:08 -0500
Subject: [PATCH] Display minimum delay in a weapon's description.

It could be easily calculated, and it was usually considered extremely important
while only being mentioned in passing in the manual. Thus, all three important
delays are visible now: mindelay, current delay (by swinging your weapon), and
base delay. Like other things on the screen, it's a base property of the weapon,
so there is no reason not to show it.

The screen had to be condensed a little to fit in 80 chars, but even the dark
maul made it.
---
 crawl-ref/source/describe.cc     | 31 +++++++++++++++++++++++++++----
 crawl-ref/source/describe.h      |  1 +
 crawl-ref/source/melee_attack.cc | 19 ++++---------------
 3 files changed, 32 insertions(+), 19 deletions(-)

diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 239a331..fda70e0 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -729,16 +729,39 @@ static string _describe_demon(const string& name, flight_type fly)
 
 void append_weapon_stats(string &description, const item_def &item)
 {
-    description += "\nAccuracy rating: ";
+    description += "\nBase accuracy: ";
     _append_value(description, property(item, PWPN_HIT), true);
-    description += "    ";
+    description += "  ";
 
-    description += "Damage rating: ";
+    description += "Base damage: ";
     _append_value(description, property(item, PWPN_DAMAGE), false);
-    description += "   ";
+    description += "  ";
 
     description += "Base attack delay: ";
     _append_value(description, property(item, PWPN_SPEED) / 10.0f, false);
+    description += "  ";
+
+    description += "Minimum delay: ";
+    _append_value(description, calc_weapon_min_delay(item) / 10.0f, false);
+ }
+
+int calc_weapon_min_delay(item_def weapon)
+{
+        int min_delay = property(weapon, PWPN_SPEED) / 2;
+
+        // Short blades can get up to at least unarmed speed.
+        if (weapon_skill(weapon) == SK_SHORT_BLADES && min_delay > 5)
+            min_delay = 5;
+
+        // All weapons have min delay 7 or better
+        if (min_delay > 7)
+            min_delay = 7;
+
+        // never go faster than speed 3 (ie 3.33 attacks per round)
+        if (min_delay < 3)
+            min_delay = 3;
+
+        return min_delay;
 }
 
 static string _corrosion_resistance_string(const item_def &item)
diff --git a/crawl-ref/source/describe.h b/crawl-ref/source/describe.h
index df2e808..edce213 100644
--- a/crawl-ref/source/describe.h
+++ b/crawl-ref/source/describe.h
@@ -63,6 +63,7 @@ void get_item_desc(const item_def &item, describe_info &inf);
 void inscribe_item(item_def &item, bool msgwin);
 
 void append_weapon_stats(string &description, const item_def &item);
+int calc_weapon_min_delay(item_def weapon);
 void append_armour_stats(string &description, const item_def &item);
 void append_missile_info(string &description);
 
diff --git a/crawl-ref/source/melee_attack.cc b/crawl-ref/source/melee_attack.cc
index 0e96bff..a6e6243 100644
--- a/crawl-ref/source/melee_attack.cc
+++ b/crawl-ref/source/melee_attack.cc
@@ -21,6 +21,7 @@
 #include "cloud.h"
 #include "database.h"
 #include "delay.h"
+#include "describe.h"
 #include "effects.h"
 #include "env.h"
 #include "exercise.h"
@@ -4082,22 +4083,8 @@ random_var melee_attack::player_weapon_speed()
         attack_delay = constant(property(*weapon, PWPN_SPEED));
         attack_delay -= div_rand_round(constant(you.skill(wpn_skill, 10)), 20);
 
-        min_delay = property(*weapon, PWPN_SPEED) / 2;
-
-        // Short blades can get up to at least unarmed speed.
-        if (wpn_skill == SK_SHORT_BLADES && min_delay > 5)
-            min_delay = 5;
-
-        // All weapons have min delay 7 or better
-        if (min_delay > 7)
-            min_delay = 7;
-
-        // never go faster than speed 3 (ie 3.33 attacks per round)
-        if (min_delay < 3)
-            min_delay = 3;
-
         // apply minimum to weapon skill modification
-        attack_delay = rv::max(attack_delay, min_delay);
+        attack_delay = rv::max(attack_delay, calc_weapon_min_delay(*weapon));
 
         if (weapon->base_type == OBJ_WEAPONS
             && damage_brand == SPWPN_SPEED)
@@ -4109,6 +4096,8 @@ random_var melee_attack::player_weapon_speed()
     return attack_delay;
 }
 
+
+
 random_var melee_attack::player_unarmed_speed()
 {
     if (_form_uses_xl())
-- 
1.8.1.4

