summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authorBrendan Hickey <brendan@bhickey.net>2013-07-28 11:43:44 -0700
committerBrendan Hickey <brendan@bhickey.net>2013-07-28 12:11:41 -0700
commitd34c657c4e4eff20e0d19b75d0e5214211384be8 (patch)
tree50f18b471e24673e0c708f988ab1998d4924ff22 /crawl-ref
parent92a6f35f339cb52a0fd7ec4ad2014142fb80e110 (diff)
downloadcrawl-ref-d34c657c4e4eff20e0d19b75d0e5214211384be8.tar.gz
crawl-ref-d34c657c4e4eff20e0d19b75d0e5214211384be8.zip
Replace 'you.penance' checks with function calls
Replace you.penance[FOO] with player_under_penance[FOO].
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/decks.cc6
-rw-r--r--crawl-ref/source/describe.cc2
-rw-r--r--crawl-ref/source/dgn-overview.cc4
-rw-r--r--crawl-ref/source/godpassive.cc2
-rw-r--r--crawl-ref/source/melee_attack.cc4
-rw-r--r--crawl-ref/source/mon-behv.cc2
-rw-r--r--crawl-ref/source/mon-pathfind.cc2
-rw-r--r--crawl-ref/source/player.cc9
-rw-r--r--crawl-ref/source/player.h2
-rw-r--r--crawl-ref/source/religion.cc8
-rw-r--r--crawl-ref/source/skill_menu.cc2
-rw-r--r--crawl-ref/source/spl-miscast.cc6
-rw-r--r--crawl-ref/source/wiz-you.cc6
-rw-r--r--crawl-ref/source/xom.cc6
14 files changed, 30 insertions, 31 deletions
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index cb9698b306..84d8a04042 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -1344,7 +1344,7 @@ void evoke_deck(item_def& deck)
// Passive Nemelex retribution: sometimes a card gets swapped out.
// More likely to happen with marked decks.
- if (you.penance[GOD_NEMELEX_XOBEH])
+ if (player_under_penance(GOD_NEMELEX_XOBEH))
{
int c = 1;
if ((flags & (CFLAG_MARKED | CFLAG_SEEN))
@@ -2908,7 +2908,7 @@ static int _card_power(deck_rarity_type rarity)
{
int result = 0;
- if (you.penance[GOD_NEMELEX_XOBEH])
+ if (player_under_penance(GOD_NEMELEX_XOBEH))
result -= you.penance[GOD_NEMELEX_XOBEH];
else if (you_worship(GOD_NEMELEX_XOBEH))
{
@@ -2965,7 +2965,7 @@ void card_effect(card_type which_card, deck_rarity_type rarity,
god_speaks(GOD_XOM, "Xom roars with laughter!");
you.gift_timeout = 200;
}
- else if (you.penance[GOD_XOM])
+ else if (player_under_penance(GOD_XOM))
god_speaks(GOD_XOM, "Xom laughs nastily.");
}
diff --git a/crawl-ref/source/describe.cc b/crawl-ref/source/describe.cc
index 6d97af2125..b9615dd03f 100644
--- a/crawl-ref/source/describe.cc
+++ b/crawl-ref/source/describe.cc
@@ -4130,7 +4130,7 @@ static int _piety_level(int piety)
string god_title(god_type which_god, species_type which_species, int piety)
{
string title;
- if (you.penance[which_god])
+ if (player_under_penance(which_god))
title = divine_title[which_god][0];
else
title = divine_title[which_god][_piety_level(piety)];
diff --git a/crawl-ref/source/dgn-overview.cc b/crawl-ref/source/dgn-overview.cc
index f00b675267..6692be87d1 100644
--- a/crawl-ref/source/dgn-overview.cc
+++ b/crawl-ref/source/dgn-overview.cc
@@ -476,10 +476,10 @@ static string _print_altars_for_gods(const vector<god_type>& gods,
if (has_altar_been_seen)
colour = "white";
// Good gods don't inflict penance unless they hate your god.
- if (you.penance[god] && (!is_good_god(god) || god_hates_your_god(god)))
+ if (player_under_penance(god) && (!is_good_god(god) || god_hates_your_god(god)))
colour = (you.penance[god] > 10) ? "red" : "lightred";
// Indicate good gods that you've abandoned, though.
- else if (you.penance[god])
+ else if (player_under_penance(god))
colour = "magenta";
else if (you_worship(god))
colour = "yellow";
diff --git a/crawl-ref/source/godpassive.cc b/crawl-ref/source/godpassive.cc
index 4560ccec4d..2d1487f970 100644
--- a/crawl-ref/source/godpassive.cc
+++ b/crawl-ref/source/godpassive.cc
@@ -105,7 +105,7 @@ void jiyva_eat_offlevel_items()
void jiyva_slurp_bonus(int item_value, int *js)
{
- if (you.penance[GOD_JIYVA])
+ if (player_under_penance(GOD_JIYVA))
return;
if (you.piety >= piety_breakpoint(1)
diff --git a/crawl-ref/source/melee_attack.cc b/crawl-ref/source/melee_attack.cc
index 3391e5ab9d..f4d97eac8d 100644
--- a/crawl-ref/source/melee_attack.cc
+++ b/crawl-ref/source/melee_attack.cc
@@ -945,7 +945,7 @@ bool melee_attack::attack()
{
set_attack_conducts(conducts, defender->as_monster());
- if (you.penance[GOD_ELYVILON]
+ if (player_under_penance(GOD_ELYVILON)
&& god_hates_your_god(GOD_ELYVILON)
&& ev_margin >= 0
&& one_chance_in(20))
@@ -1419,7 +1419,7 @@ bool melee_attack::player_aux_test_hit()
const int evasion = defender->melee_evasion(attacker);
- if (you.penance[GOD_ELYVILON]
+ if (player_under_penance(GOD_ELYVILON)
&& god_hates_your_god(GOD_ELYVILON)
&& to_hit >= evasion
&& one_chance_in(20))
diff --git a/crawl-ref/source/mon-behv.cc b/crawl-ref/source/mon-behv.cc
index 7cd4581978..3106b5bf6f 100644
--- a/crawl-ref/source/mon-behv.cc
+++ b/crawl-ref/source/mon-behv.cc
@@ -434,7 +434,7 @@ void handle_behaviour(monster* mon)
// Ash penance makes monsters very likely to target you through
// invisibility, depending on their intelligence.
- if (you.penance[GOD_ASHENZARI] && x_chance_in_y(intel, 7))
+ if (player_under_penance(GOD_ASHENZARI) && x_chance_in_y(intel, 7))
proxPlayer = true;
}
diff --git a/crawl-ref/source/mon-pathfind.cc b/crawl-ref/source/mon-pathfind.cc
index b561ad0f20..9933cf3e04 100644
--- a/crawl-ref/source/mon-pathfind.cc
+++ b/crawl-ref/source/mon-pathfind.cc
@@ -62,7 +62,7 @@ int mons_tracking_range(const monster* mon)
range++;
}
- if (you.penance[GOD_ASHENZARI])
+ if (player_under_penance(GOD_ASHENZARI))
range *= 5;
if (mons_foe_is_marked(mon) || mon->has_ench(ENCH_HAUNTING))
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index e868328f9b..c0a372a42a 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -487,12 +487,9 @@ bool player_can_open_doors()
return (you.form != TRAN_BAT && you.form != TRAN_JELLY);
}
-bool player_under_penance(void)
+int player_under_penance(god_type which_god)
{
- if (!you_worship(GOD_NO_GOD))
- return (you.penance[you.religion]);
- else
- return false;
+ return (you.penance[which_god]);
}
// TODO: get rid of this.
@@ -2973,7 +2970,7 @@ void gain_exp(unsigned int exp_gained, unsigned int* actual_gain)
exp_gained *= 2;
}
- if (you.penance[GOD_ASHENZARI])
+ if (player_under_penance(GOD_ASHENZARI))
ash_reduce_penance(exp_gained);
const unsigned int old_exp = you.experience;
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index 383029e7ea..c1cd4362e5 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -809,7 +809,7 @@ bool player_is_shapechanged(void);
bool is_effectively_light_armour(const item_def *item);
bool player_effectively_in_light_armour();
-bool player_under_penance(void);
+int player_under_penance(god_type which_god = you.religion);
int burden_change(void);
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index d2724bff85..4cbe67e7e5 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -1072,7 +1072,7 @@ static void _inc_penance(god_type god, int val)
if (val <= 0)
return;
- if (you.penance[god] == 0)
+ if (!player_under_penance(god))
{
god_acting gdact(god, true);
@@ -2646,7 +2646,7 @@ void gain_piety(int original_gain, int denominator, bool force, bool should_scal
static void _gain_piety_point()
{
// check to see if we owe anything first
- if (you.penance[you.religion] > 0)
+ if (player_under_penance(you.religion))
{
dec_penance(1);
return;
@@ -3983,7 +3983,7 @@ void handle_god_time()
{
// Nemelex penance is special: it's only "active"
// when penance > 100, else it's passive.
- if (you.penance[i] && (i != GOD_NEMELEX_XOBEH
+ if (player_under_penance((god_type) i) && (i != GOD_NEMELEX_XOBEH
|| you.penance[i] > 100))
{
penance_count++;
@@ -3996,7 +3996,7 @@ void handle_god_time()
unsigned int count = 0;
for (int i = GOD_NO_GOD; i < NUM_GODS; ++i)
{
- if (you.penance[i] && (i != GOD_NEMELEX_XOBEH
+ if (player_under_penance((god_type) i) && (i != GOD_NEMELEX_XOBEH
|| you.penance[i] > 100))
{
if (count == which_penance)
diff --git a/crawl-ref/source/skill_menu.cc b/crawl-ref/source/skill_menu.cc
index 54d43f9382..801eee36d6 100644
--- a/crawl-ref/source/skill_menu.cc
+++ b/crawl-ref/source/skill_menu.cc
@@ -562,7 +562,7 @@ string SkillMenuSwitch::get_help()
vector<string> causes;
if (you.attribute[ATTR_XP_DRAIN])
causes.push_back("draining");
- if (you.penance[GOD_ASHENZARI])
+ if (player_under_penance(GOD_ASHENZARI))
causes.push_back("the power of Ashenzari");
return "Skills reduced by "
+ comma_separated_line(causes.begin(), causes.end())
diff --git a/crawl-ref/source/spl-miscast.cc b/crawl-ref/source/spl-miscast.cc
index fcac3eccac..baf9f58311 100644
--- a/crawl-ref/source/spl-miscast.cc
+++ b/crawl-ref/source/spl-miscast.cc
@@ -542,7 +542,7 @@ bool MiscastEffect::_ouch(int dam, beam_type flavour)
{
god_type god = static_cast<god_type>(-source);
- if (god == GOD_XOM && you.penance[GOD_XOM] == 0)
+ if (god == GOD_XOM && !player_under_penance(GOD_XOM))
method = KILLED_BY_XOM;
else
method = KILLED_BY_DIVINE_WRATH;
@@ -713,7 +713,7 @@ bool MiscastEffect::_create_monster(monster_type what, int abj_deg,
// hostile_at() assumes the monster is hostile to the player,
// but should be hostile to the target monster unless the miscast
// is a result of either divine wrath or a Zot trap.
- if (target->is_monster() && you.penance[god] == 0
+ if (target->is_monster() && !player_under_penance(god)
&& source != ZOT_TRAP_MISCAST)
{
monster* mon_target = target_as_monster();
@@ -743,7 +743,7 @@ bool MiscastEffect::_create_monster(monster_type what, int abj_deg,
{
if (what == RANDOM_MOBILE_MONSTER)
data.summon_type = SPELL_SHADOW_CREATURES;
- else if (you.penance[god] > 0)
+ else if (player_under_penance(god))
data.summon_type = MON_SUMM_WRATH;
else if (source == ZOT_TRAP_MISCAST)
data.summon_type = MON_SUMM_ZOT;
diff --git a/crawl-ref/source/wiz-you.cc b/crawl-ref/source/wiz-you.cc
index e14dbc7b5c..e5e4539301 100644
--- a/crawl-ref/source/wiz-you.cc
+++ b/crawl-ref/source/wiz-you.cc
@@ -401,7 +401,7 @@ void wizard_set_piety()
while (diff != 0);
// Automatically reduce penance to 0.
- if (you.penance[you.religion] > 0)
+ if (player_under_penance())
dec_penance(you.penance[you.religion]);
}
@@ -1027,8 +1027,10 @@ void wizard_god_mollify()
{
for (int i = GOD_NO_GOD; i < NUM_GODS; ++i)
{
- if (you.penance[i])
+ if (player_under_penance((god_type) i))
+ {
dec_penance((god_type) i, you.penance[i]);
+ }
}
}
diff --git a/crawl-ref/source/xom.cc b/crawl-ref/source/xom.cc
index 6d727bd211..bc884a495a 100644
--- a/crawl-ref/source/xom.cc
+++ b/crawl-ref/source/xom.cc
@@ -186,7 +186,7 @@ static bool _xom_feels_nasty()
bool xom_is_nice(int tension)
{
- if (you.penance[GOD_XOM])
+ if (player_under_penance(GOD_XOM))
return false;
if (you_worship(GOD_XOM))
@@ -3416,7 +3416,7 @@ static bool _will_not_banish()
static bool _allow_xom_banishment()
{
// Always allowed if under penance.
- if (you.penance[GOD_XOM])
+ if (player_under_penance(GOD_XOM))
return true;
// If Xom is bored, banishment becomes viable earlier.
@@ -4287,7 +4287,7 @@ void debug_xom_effects()
fprintf(ostat, "%s\n", mpr_monster_list().c_str());
fprintf(ostat, " --> Tension: %d\n", tension);
- if (you.penance[GOD_XOM])
+ if (player_under_penance(GOD_XOM))
fprintf(ostat, "You are under Xom's penance!\n");
else if (_xom_is_bored())
fprintf(ostat, "Xom is BORED.\n");