summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spl-cast.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-11 11:57:14 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2008-10-11 11:57:14 +0000
commit89adf4610b5206a5f42187ee90cd01e54583f5d9 (patch)
treeb1964ae7a858303a2f52c7c71fc0b95346276a54 /crawl-ref/source/spl-cast.cc
parentac38a5b60508bcd3b0a6a3537469513c94b79130 (diff)
downloadcrawl-ref-89adf4610b5206a5f42187ee90cd01e54583f5d9.tar.gz
crawl-ref-89adf4610b5206a5f42187ee90cd01e54583f5d9.zip
Add food-item-based hunger descriptions to spells.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@7210 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spl-cast.cc')
-rw-r--r--crawl-ref/source/spl-cast.cc32
1 files changed, 16 insertions, 16 deletions
diff --git a/crawl-ref/source/spl-cast.cc b/crawl-ref/source/spl-cast.cc
index 611e227a68..0074ab92eb 100644
--- a/crawl-ref/source/spl-cast.cc
+++ b/crawl-ref/source/spl-cast.cc
@@ -4541,22 +4541,27 @@ const char* failure_rate_to_string( int fail )
"Perfect"; // 100%
}
+static unsigned int _breakpoint_rank(int val, const int breakpoints[],
+ unsigned int num_breakpoints)
+{
+ unsigned int result = 0;
+ while (result < num_breakpoints && val >= breakpoints[result])
+ ++result;
+ return result;
+}
+
const char* spell_hunger_string( spell_type spell )
{
if ( you.is_undead == US_UNDEAD )
return "N/A";
const int hunger = spell_hunger(spell);
- if ( hunger == 0 )
- return "None";
- else if ( hunger < 25 )
- return "Minor";
- else if ( hunger < 150 )
- return "Moderate";
- else if ( hunger < 500 )
- return "Major";
- else
- return "Extreme";
+ const char* hunger_descriptions[] = {
+ "None", "Grape", "Apple", "Choko", "Ration"
+ };
+ const int breakpoints[] = { 1, 25, 150, 500 };
+ return (hunger_descriptions[_breakpoint_rank(hunger, breakpoints,
+ ARRAYSZ(breakpoints))]);
}
int spell_power_colour(spell_type spell)
@@ -4580,12 +4585,7 @@ static int _power_to_barcount( int power )
return -1;
const int breakpoints[] = { 5, 10, 15, 25, 35, 50, 75, 100, 150 };
- int result = 0;
- for (unsigned int i = 0; i < ARRAYSZ(breakpoints); ++i)
- if (power > breakpoints[i])
- ++result;
-
- return (result + 1);
+ return (_breakpoint_rank(power, breakpoints, ARRAYSZ(breakpoints)) + 1);
}
int spell_power_bars( spell_type spell )