summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spl-util.cc
diff options
context:
space:
mode:
authorharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-29 16:55:20 +0000
committerharanp <haranp@c06c8d41-db1a-0410-9941-cceddc491573>2007-06-29 16:55:20 +0000
commit2b2a5958399c551e7643237bc6b519d299bad164 (patch)
tree645554f77a7f23369028f7ba46eb7c71d07a3160 /crawl-ref/source/spl-util.cc
parentcf277d8cb8c333532b3db63855ef003553e412f5 (diff)
downloadcrawl-ref-2b2a5958399c551e7643237bc6b519d299bad164.tar.gz
crawl-ref-2b2a5958399c551e7643237bc6b519d299bad164.zip
Implemented 1715578: pressing '!' in the Z? screen toggles between
showing schools/success and hunger/power. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@1693 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spl-util.cc')
-rw-r--r--crawl-ref/source/spl-util.cc40
1 files changed, 19 insertions, 21 deletions
diff --git a/crawl-ref/source/spl-util.cc b/crawl-ref/source/spl-util.cc
index 61988ccd19..ed62c89478 100644
--- a/crawl-ref/source/spl-util.cc
+++ b/crawl-ref/source/spl-util.cc
@@ -150,28 +150,26 @@ bool del_spell_from_memory_by_slot( int slot )
int spell_hunger(spell_type which_spell)
{
- int level = seekspell(which_spell)->level;
+ const int level = spell_difficulty(which_spell);
- switch (level)
- {
- case 1: return 50;
- case 2: return 95;
- case 3: return 160;
- case 4: return 250;
- case 5: return 350;
- case 6: return 550;
- case 7: return 700;
- case 8: return 850;
- case 9: return 1000;
- case 10: return 1000;
- case 11: return 1100;
- case 12: return 1250;
- case 13: return 1380;
- case 14: return 1500;
- case 15: return 1600;
- default: return 1600 + (20 * level);
- }
-} // end spell_hunger();
+ const int basehunger[] = {
+ 50, 95, 160, 250, 350, 550, 700, 850, 1000
+ };
+
+ int hunger;
+
+ if ( level < 10 && level > 0 )
+ hunger = basehunger[level-1];
+ else
+ hunger = (basehunger[0] * level * level) / 4;
+
+ hunger -= you.intel * you.skills[SK_SPELLCASTING];
+
+ if ( hunger < 0 )
+ hunger = 0;
+
+ return hunger;
+}
bool spell_needs_tracer(spell_type spell)
{