summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-25 17:11:45 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2008-04-25 17:11:45 +0000
commit6297b352b077c9c5e8fdd154cc1cda620d617f71 (patch)
treeb017d96fee4be48579f2a1ce9c5f8a89af4192e4 /crawl-ref
parent7249037678b8250bbbdb59ee89b7e1852cf63b53 (diff)
downloadcrawl-ref-6297b352b077c9c5e8fdd154cc1cda620d617f71.tar.gz
crawl-ref-6297b352b077c9c5e8fdd154cc1cda620d617f71.zip
Consolidate the mutation-counting routines.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@4628 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/chardump.cc8
-rw-r--r--crawl-ref/source/decks.cc4
-rw-r--r--crawl-ref/source/mutation.cc43
-rw-r--r--crawl-ref/source/mutation.h5
-rw-r--r--crawl-ref/source/religion.cc4
5 files changed, 26 insertions, 38 deletions
diff --git a/crawl-ref/source/chardump.cc b/crawl-ref/source/chardump.cc
index 519fabf849..252a46540e 100644
--- a/crawl-ref/source/chardump.cc
+++ b/crawl-ref/source/chardump.cc
@@ -1093,14 +1093,8 @@ static void sdump_hiscore(dump_params &par)
static void sdump_mutations(dump_params &par)
{
std::string &text(par.text);
- // Can't use how_mutated() here, as it doesn't count demonic powers
- int xz = 0;
- for (int xy = 0; xy < NUM_MUTATIONS; ++xy)
- if (you.mutation[xy] > 0)
- xz++;
-
- if (xz > 0)
+ if (how_mutated(true, false))
{
text += "\n";
text += describe_mutations();
diff --git a/crawl-ref/source/decks.cc b/crawl-ref/source/decks.cc
index 009d10c589..99a079490c 100644
--- a/crawl-ref/source/decks.cc
+++ b/crawl-ref/source/decks.cc
@@ -2036,7 +2036,7 @@ static void _helix_card(int power, deck_rarity_type rarity)
if ( power_level == 0 )
{
- switch ( count_mutations() ? random2(3) : 0 )
+ switch ( how_mutated() ? random2(3) : 0 )
{
case 0:
mutate(RANDOM_MUTATION);
@@ -2052,7 +2052,7 @@ static void _helix_card(int power, deck_rarity_type rarity)
}
else if ( power_level == 1 )
{
- switch ( count_mutations() ? random2(3) : 0 )
+ switch ( how_mutated() ? random2(3) : 0 )
{
case 0:
mutate(coinflip() ? RANDOM_GOOD_MUTATION : RANDOM_MUTATION);
diff --git a/crawl-ref/source/mutation.cc b/crawl-ref/source/mutation.cc
index 30e08a0cff..40eac860b2 100644
--- a/crawl-ref/source/mutation.cc
+++ b/crawl-ref/source/mutation.cc
@@ -51,8 +51,7 @@
#include "xom.h"
-int how_mutated(void);
-char body_covered(void);
+static char body_covered(void);
const char *troll_claw_descrip[4] = {
"You have claws for hands.",
@@ -1752,7 +1751,7 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
if (which_mutation == RANDOM_MUTATION
|| which_mutation == RANDOM_XOM_MUTATION)
{
- if ( random2(15) < how_mutated() )
+ if ( random2(15) < how_mutated(false, true) )
{
if (!force_mutation && !one_chance_in(3))
return (false);
@@ -2165,43 +2164,41 @@ bool mutate(mutation_type which_mutation, bool failMsg, bool force_mutation,
return true;
}
-int how_mutated(void)
+int how_mutated(bool all, bool levels)
{
int j = 0;
for (int i = 0; i < NUM_MUTATIONS; i++)
{
- if (you.mutation[i] && you.demon_pow[i] < you.mutation[i])
+ if (you.mutation[i])
{
- // these allow for 14 levels:
- if (i == MUT_STRONG || i == MUT_CLEVER || i == MUT_AGILE
- || i == MUT_WEAK || i == MUT_DOPEY || i == MUT_CLUMSY)
+ if (!all && you.demon_pow[i] < you.mutation[i])
+ continue;
+
+ if (levels)
{
- j += (you.mutation[i] / 5 + 1);
+ // these allow for 14 levels:
+ if (i == MUT_STRONG || i == MUT_CLEVER || i == MUT_AGILE
+ || i == MUT_WEAK || i == MUT_DOPEY || i == MUT_CLUMSY)
+ {
+ j += (you.mutation[i] / 5 + 1);
+ }
+ else
+ j += you.mutation[i];
}
else
- j += you.mutation[i];
+ j++;
}
}
#if DEBUG_DIAGNOSTICS
- mprf(MSGCH_DIAGNOSTICS, "levels: %d", j );
+ mprf(MSGCH_DIAGNOSTICS, "how_mutated(): all = %u, levels = %u, j = %d",
+ all, levels, j);
#endif
return (j);
} // end how_mutated()
-int count_mutations()
-{
- int count = 0;
-
- for (int i = 0; i < NUM_MUTATIONS; i++)
- if (you.mutation[i] && you.demon_pow[i] < you.mutation[i])
- count++;
-
- return count;
-}
-
bool delete_mutation(mutation_type which_mutation, bool force_mutation)
{
mutation_type mutat = which_mutation;
@@ -2373,7 +2370,7 @@ bool delete_mutation(mutation_type which_mutation, bool force_mutation)
return true;
} // end delete_mutation()
-char body_covered(void)
+static char body_covered(void)
{
// checks how much of your body is covered by scales, etc.
char covered = 0;
diff --git a/crawl-ref/source/mutation.h b/crawl-ref/source/mutation.h
index 93324d422c..e309e51c3e 100644
--- a/crawl-ref/source/mutation.h
+++ b/crawl-ref/source/mutation.h
@@ -58,9 +58,6 @@ formatted_string describe_mutations();
* *********************************************************************** */
bool delete_mutation(mutation_type which_mutation, bool force_mutation = false);
-// used by Zin (religion.cc)
-int count_mutations(void);
-
// last updated 12may2000 {dlb}
/* ***********************************************************************
* called from: chardump
@@ -81,7 +78,7 @@ bool give_bad_mutation( bool forceMutation = false, bool failMsg = true );
void demonspawn(void);
bool perma_mutate(mutation_type which_mut, int how_much);
-int how_mutated();
+int how_mutated(bool all = false, bool levels = false);
#ifdef DEBUG_DIAGNOSTICS
void sanity_check_mutation_defs();
diff --git a/crawl-ref/source/religion.cc b/crawl-ref/source/religion.cc
index 8fc7be3044..c224c73827 100644
--- a/crawl-ref/source/religion.cc
+++ b/crawl-ref/source/religion.cc
@@ -2897,7 +2897,7 @@ static bool _zin_retribution()
int punishment = random2(10);
// if little mutated or can't unmutate, do something else instead
- if (punishment < 2 && count_mutations() <= random2(3)
+ if (punishment < 2 && how_mutated() <= random2(3)
|| !can_safely_mutate())
{
punishment = random2(8)+2;
@@ -2917,7 +2917,7 @@ static bool _zin_retribution()
success = true;
}
- if (success && !count_mutations())
+ if (success && !how_mutated())
{
simple_god_message(" rids your body of chaos!", god);
// lower penance a bit more for being particularly successful