summaryrefslogtreecommitdiffstats
path: root/crawl-ref/source/religion.cc
diff options
context:
space:
mode:
authorNeil Moore <neil@s-z.org>2014-05-29 11:02:00 -0400
committerNeil Moore <neil@s-z.org>2014-05-29 11:02:00 -0400
commit40568d41d8eedde71212b251670db8238f0299fb (patch)
tree697e5fa1fdab0e5935683485fd0769e3068d0c2f /crawl-ref/source/religion.cc
parentdff2ca7b45eb3abd1019354aca1d6cbd0cf56436 (diff)
downloadcrawl-ref-40568d41d8eedde71212b251670db8238f0299fb.tar.gz
crawl-ref-40568d41d8eedde71212b251670db8238f0299fb.zip
Split off armour and shield upgrade code.
And document that enum order matters.
Diffstat (limited to 'crawl-ref/source/religion.cc')
-rw-r--r--crawl-ref/source/religion.cc34
1 files changed, 23 insertions, 11 deletions
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 7f6025809b..f4515b60ae 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -1710,6 +1710,23 @@ static bool _blessing_wpn(monster* mon)
return true;
}
+static void _upgrade_shield(item_def &sh)
+{
+ // Promote from buckler up through large shield.
+ if (sh.sub_type >= ARM_FIRST_SHIELD && sh.sub_type < ARM_LAST_SHIELD)
+ sh.sub_type++;
+}
+
+static void _upgrade_body_armour(item_def &arm)
+{
+ // Promote from robe up through plate.
+ if (arm.sub_type >= ARM_FIRST_MUNDANE_BODY
+ && arm.sub_type < ARM_LAST_MUNDANE_BODY)
+ {
+ arm.sub_type++;
+ }
+}
+
static bool _blessing_AC(monster* mon)
{
// Pick either a monster's armour or its shield.
@@ -1727,18 +1744,13 @@ static bool _blessing_AC(monster* mon)
item_def& arm(mitm[slot]);
- if (you_worship(GOD_BEOGH)
- && !is_artefact(arm)
- && x_chance_in_y(mon->hit_dice, 250)
- && ((slot == shield
- && !mon->props.exists("given beogh shield")
- && arm.sub_type < ARM_LARGE_SHIELD)
- || (slot == armour
- && !mon->props.exists("given beogh armour")
- && arm.sub_type >= ARM_FIRST_MUNDANE_BODY
- && arm.sub_type < ARM_LAST_MUNDANE_BODY)))
+ if (you_worship(GOD_BEOGH) && !is_artefact(arm)
+ && x_chance_in_y(mon->hit_dice, 250))
{
- arm.sub_type++;
+ if (slot == shield && !mon->props.exists("given beogh shield"))
+ _upgrade_shield(arm);
+ else if (slot == armour && !mon->props.exists("given beogh armour"))
+ _upgrade_body_armour(arm);
}
int ac_change;