summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spl-cast.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-31 12:49:37 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-10-31 12:49:37 +0000
commit64b141991066a155ff820ffdc30e919550b9a8cd (patch)
treec32812150cb8b0f47f4ea5b53343ac2573794a68 /crawl-ref/source/spl-cast.cc
parent8f95470bfb148b72878f19a0b1680ba76d4f5fc9 (diff)
downloadcrawl-ref-64b141991066a155ff820ffdc30e919550b9a8cd.tar.gz
crawl-ref-64b141991066a155ff820ffdc30e919550b9a8cd.zip
1822982: slightly better spell power string.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@2705 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spl-cast.cc')
-rw-r--r--crawl-ref/source/spl-cast.cc38
1 files changed, 23 insertions, 15 deletions
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 88a9debc42..81498eda49 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -3583,15 +3583,6 @@ const char* spell_hunger_string( spell_type spell )
return "Extreme";
}
-std::string spell_power_string(spell_type spell)
-{
- const int numbars = spell_power_bars(spell);
- if ( numbars < 0 )
- return "N/A";
- else
- return std::string(numbars, '#');
-}
-
int spell_power_colour(spell_type spell)
{
const int powercap = spell_power_cap(spell);
@@ -3607,13 +3598,10 @@ int spell_power_colour(spell_type spell)
return GREEN;
}
-int spell_power_bars( spell_type spell )
+static int power_to_barcount( int power )
{
- const int powercap = spell_power_cap(spell);
- if ( powercap == 0 )
+ if ( power == -1 )
return -1;
- const int power = std::min(calc_spell_power(spell, true), powercap);
-
const int breakpoints[] = { 5, 10, 15, 25, 35, 50, 75, 100, 150 };
int result = 0;
for ( unsigned int i = 0; i < ARRAYSIZE(breakpoints); ++i )
@@ -3621,5 +3609,25 @@ int spell_power_bars( spell_type spell )
if ( power > breakpoints[i] )
++result;
}
- return result + 1;
+ return result + 1;
+}
+
+int spell_power_bars( spell_type spell )
+{
+ const int cap = spell_power_cap(spell);
+ if ( cap == 0 )
+ return -1;
+ const int power = std::min(calc_spell_power(spell, true), cap);
+ return power_to_barcount(power);
+}
+
+std::string spell_power_string(spell_type spell)
+{
+ const int numbars = spell_power_bars(spell);
+ const int capbars = power_to_barcount(spell_power_cap(spell));
+ ASSERT( numbars <= capbars );
+ if ( numbars < 0 )
+ return "N/A";
+ else
+ return std::string(numbars, '#') + std::string(capbars - numbars, '.');
}