summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/spells2.cc
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-20 19:56:19 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-20 19:56:19 +0000
commit741f3db05f169b784e130a11e87f4485d6a679e4 (patch)
tree8d6004441e49d4158cd5ecf1a004944abc5b92d6 /crawl-ref/source/spells2.cc
parent131216891cbe3539a153395c83f74ac52c216d0a (diff)
downloadcrawl-ref-741f3db05f169b784e130a11e87f4485d6a679e4.tar.gz
crawl-ref-741f3db05f169b784e130a11e87f4485d6a679e4.zip
Expand restore_stat() to allow for more fine-grained constrol of stat
restoration; the amount to be restored can now be specified. Use this where necessary. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4417 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/spells2.cc')
-rw-r--r--crawl-ref/source/spells2.cc52
1 files changed, 31 insertions, 21 deletions
diff --git a/crawl-ref/source/spells2.cc b/crawl-ref/source/spells2.cc
index 14fa175bb2..783f4a92e6 100644
--- a/crawl-ref/source/spells2.cc
+++ b/crawl-ref/source/spells2.cc
@@ -689,20 +689,24 @@ bool brand_weapon(brand_type which_brand, int power)
return true;
} // end brand_weapon()
-bool restore_stat(unsigned char which_stat, bool suppress_msg)
+// Restore the stat in which_stat by the amount in stat_gain, displaying
+// a message if suppress_msg is false. If stat_gain is 0, restore the
+// stat completely.
+bool restore_stat(unsigned char which_stat, unsigned char stat_gain,
+ bool suppress_msg)
{
- bool statRestored = false;
+ bool stat_restored = false;
// a bit hackish, but cut me some slack, man! --
// besides, a little recursion never hurt anyone {dlb}:
if (which_stat == STAT_ALL)
{
- for (unsigned char loopy = STAT_STRENGTH; loopy < NUM_STATS; loopy++)
+ for (unsigned char loopy = STAT_STRENGTH; loopy < NUM_STATS; ++loopy)
{
- if (restore_stat(loopy, suppress_msg) == true)
- statRestored = true;
+ if (restore_stat(loopy, stat_gain, suppress_msg))
+ stat_restored = true;
}
- return statRestored; // early return {dlb}
+ return stat_restored; // early return {dlb}
}
// the real function begins here {dlb}:
@@ -725,14 +729,6 @@ bool restore_stat(unsigned char which_stat, bool suppress_msg)
ptr_redraw = &you.redraw_strength;
break;
- case STAT_DEXTERITY:
- msg += "dexterity";
-
- ptr_stat = &you.dex;
- ptr_stat_max = &you.max_dex;
- ptr_redraw = &you.redraw_dexterity;
- break;
-
case STAT_INTELLIGENCE:
msg += "intelligence";
@@ -740,23 +736,37 @@ bool restore_stat(unsigned char which_stat, bool suppress_msg)
ptr_stat_max = &you.max_intel;
ptr_redraw = &you.redraw_intelligence;
break;
+
+ case STAT_DEXTERITY:
+ msg += "dexterity";
+
+ ptr_stat = &you.dex;
+ ptr_stat_max = &you.max_dex;
+ ptr_redraw = &you.redraw_dexterity;
+ break;
}
if (*ptr_stat < *ptr_stat_max)
{
msg += " returning.";
if ( !suppress_msg )
- mpr(msg.c_str());
+ mpr(msg.c_str(), MSGCH_RECOVERY);
+
+ if (stat_gain == 0 || *ptr_stat + stat_gain > *ptr_stat_max)
+ stat_gain = *ptr_stat_max - *ptr_stat;
- *ptr_stat = *ptr_stat_max;
- *ptr_redraw = 1;
- statRestored = true;
+ if (stat_gain != 0)
+ {
+ *ptr_stat += stat_gain;
+ *ptr_redraw = true;
+ stat_restored = true;
- if (ptr_stat == &you.strength)
- burden_change();
+ if (ptr_stat == &you.strength)
+ burden_change();
+ }
}
- return statRestored;
+ return stat_restored;
} // end restore_stat()
void turn_undead(int pow)