From 6f143c5fef3f6b07e91afb722e117d54fb3e60f2 Mon Sep 17 00:00:00 2001 From: haranp Date: Wed, 7 Nov 2007 20:31:57 +0000 Subject: Merged 2705, 2799 (better, monochrome spell power descriptions.) git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/branches/stone_soup-0.3@2800 c06c8d41-db1a-0410-9941-cceddc491573 --- crawl-ref/source/spl-cast.cc | 43 ++++++++++++++++++++++++------------------- 1 file changed, 24 insertions(+), 19 deletions(-) diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc index cf7a338448..2480ba424c 100644 --- a/crawl-ref/source/spl-cast.cc +++ b/crawl-ref/source/spl-cast.cc @@ -179,10 +179,7 @@ static std::string spell_extra_description(spell_type spell) desc << std::setw(30) << spell_title(spell); // spell power, hunger level, level - const char* colstr = colour_to_str(spell_power_colour(spell)); - desc << '<' << colstr << '>' - << std::setw(30) << spell_power_string(spell) - << "' + desc << std::setw(30) << spell_power_string(spell) << std::setw(12) << spell_hunger_string(spell) << spell_difficulty(spell); @@ -3553,15 +3550,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); @@ -3577,13 +3565,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 ) @@ -3591,5 +3576,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, '.'); } -- cgit v1.2.3-54-g00ecf