summaryrefslogtreecommitdiffstats
path: root/crawl-ref
diff options
context:
space:
mode:
authordolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-22 17:36:57 +0000
committerdolorous <dolorous@c06c8d41-db1a-0410-9941-cceddc491573>2009-02-22 17:36:57 +0000
commit03725e818345745c8c383f339cc10c51a82ffdf0 (patch)
tree173b5973602b821ac515d4ed6b7b2ccfe1ec896b /crawl-ref
parente23410c57e1a84fc01deacb8b09cd1389148f514 (diff)
downloadcrawl-ref-03725e818345745c8c383f339cc10c51a82ffdf0.tar.gz
crawl-ref-03725e818345745c8c383f339cc10c51a82ffdf0.zip
Clean up gourmand-related routines: only check for gourmand duration
instead of checking for wearing the amulet *and* gourmand duration, account for gourmand (both the amulet and the mutation) in the output screen, and treat gourmand (both the amulet and the mutation) consistently with regard to potions of blood. git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@9153 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref')
-rw-r--r--crawl-ref/source/food.cc64
-rw-r--r--crawl-ref/source/output.cc3
-rw-r--r--crawl-ref/source/player.cc5
-rw-r--r--crawl-ref/source/player.h2
4 files changed, 37 insertions, 37 deletions
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc
index b392fce971..736b5de852 100644
--- a/crawl-ref/source/food.cc
+++ b/crawl-ref/source/food.cc
@@ -1509,16 +1509,8 @@ int prompt_eat_chunks()
return (0);
// If we *know* player doesn't have the gourmand effect, don't prompt.
- if (!player_mutation_level(MUT_GOURMAND)
- && player_mutation_level(MUT_CARNIVOROUS) < 3)
- {
- if (!player_wearing_slot(EQ_AMULET))
- return (0);
-
- const item_def& amu(you.inv[you.equip[EQ_AMULET]]);
- if (item_type_known(amu) && amu.sub_type != AMU_THE_GOURMAND)
- return (0);
- }
+ if (!player_likes_chunks(true))
+ return (0);
bool found_valid = false;
std::vector<item_def *> chunks;
@@ -1574,7 +1566,7 @@ int prompt_eat_chunks()
const bool easy_eat = Options.easy_eat_chunks && !you.is_undead;
const bool easy_contam = easy_eat
- && (Options.easy_eat_gourmand && wearing_amulet(AMU_THE_GOURMAND)
+ && (Options.easy_eat_gourmand && you.duration[DUR_GOURMAND] > 0
|| Options.easy_eat_contaminated);
if (found_valid)
@@ -1719,9 +1711,7 @@ static int _chunk_nutrition(bool likes_chunks)
: apply_herbivore_nutrition_effects(nutrition));
}
- const int gourmand =
- wearing_amulet(AMU_THE_GOURMAND) ? you.duration[DUR_GOURMAND] : 0;
-
+ const int gourmand = you.duration[DUR_GOURMAND];
const int effective_nutrition =
_apply_gourmand_nutrition_effects(nutrition, gourmand);
@@ -2492,6 +2482,29 @@ bool is_forbidden_food(const item_def &food)
return (false);
}
+static bool _check_amu_the_gourmand(bool reqid)
+{
+ if (wearing_amulet(AMU_THE_GOURMAND, !reqid))
+ {
+ const int amulet = you.equip[EQ_AMULET];
+
+ ASSERT(amulet != -1);
+
+ if (!item_type_known(you.inv[amulet]))
+ {
+ // For artefact amulets, this will tell you its name and
+ // subtype. Other properties may still be hidden.
+ set_ident_flags(you.inv[amulet], ISFLAG_KNOW_TYPE);
+ set_ident_type(OBJ_JEWELLERY, AMU_THE_GOURMAND, ID_KNOWN_TYPE);
+ mpr(you.inv[amulet].name(DESC_INVENTORY, false).c_str());
+ }
+
+ return (true);
+ }
+
+ return (false);
+}
+
bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg,
bool reqid, bool check_hunger)
{
@@ -2575,24 +2588,8 @@ bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg,
if (ur_chunkslover)
return (true);
- // Else, we're not hungry enough.
- if (wearing_amulet(AMU_THE_GOURMAND, !reqid))
- {
- const int amulet = you.equip[EQ_AMULET];
-
- ASSERT(amulet != -1);
-
- if (!item_type_known(you.inv[amulet]))
- {
- // For artefact amulets, this will tell you its name
- // and subtype. Other properties may still be hidden.
- set_ident_flags(you.inv[amulet], ISFLAG_KNOW_TYPE);
- set_ident_type(OBJ_JEWELLERY, AMU_THE_GOURMAND,
- ID_KNOWN_TYPE);
- mpr(you.inv[amulet].name(DESC_INVENTORY, false).c_str());
- }
+ if (_check_amu_the_gourmand(reqid))
return (true);
- }
if (!suppress_msg)
mpr("You aren't quite hungry enough to eat that!");
@@ -2603,6 +2600,7 @@ bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg,
// rations for non-herbivores) are okay.
return (true);
}
+
case OBJ_CORPSES:
if (you.species == SP_VAMPIRE)
{
@@ -2654,6 +2652,7 @@ bool can_ingest(int what_isit, int kindof_thing, bool suppress_msg,
return (false);
}
default:
+ _check_amu_the_gourmand(reqid);
return (true);
}
@@ -2752,8 +2751,7 @@ static corpse_effect_type _determine_chunk_effect(corpse_effect_type chunktype,
// contaminated meat as though it were "clean" meat - level 3
// saprovores get rotting meat effect from clean chunks, since they
// love rotting meat.
- if (wearing_amulet(AMU_THE_GOURMAND)
- && x_chance_in_y(you.duration[DUR_GOURMAND], GOURMAND_MAX))
+ if (x_chance_in_y(you.duration[DUR_GOURMAND], GOURMAND_MAX))
{
if (player_mutation_level(MUT_SAPROVOROUS) == 3)
{
diff --git a/crawl-ref/source/output.cc b/crawl-ref/source/output.cc
index 434b5dc504..7022b53ef7 100644
--- a/crawl-ref/source/output.cc
+++ b/crawl-ref/source/output.cc
@@ -2030,7 +2030,8 @@ static std::vector<formatted_string> _get_overview_resistances(
int saplevel = player_mutation_level(MUT_SAPROVOROUS);
const char* pregourmand;
const char* postgourmand;
- if ( wearing_amulet(AMU_THE_GOURMAND, calc_unid) )
+
+ if (player_mutation_level(MUT_GOURMAND) || you.duration[DUR_GOURMAND] > 0)
{
pregourmand = "Gourmand : ";
postgourmand = itosym1(1);
diff --git a/crawl-ref/source/player.cc b/crawl-ref/source/player.cc
index 2bf3a2170f..15abd4d22b 100644
--- a/crawl-ref/source/player.cc
+++ b/crawl-ref/source/player.cc
@@ -1292,10 +1292,11 @@ bool player_can_smell()
return (you.species != SP_MUMMY);
}
-bool player_likes_chunks()
+bool player_likes_chunks(bool permanently)
{
return (player_mutation_level(MUT_GOURMAND)
- || player_mutation_level(MUT_CARNIVOROUS) > 0);
+ || player_mutation_level(MUT_CARNIVOROUS) > 0
+ || (!permanently && you.duration[DUR_GOURMAND] > 0));
}
// If temp is set to false, temporary sources or resistance won't be counted.
diff --git a/crawl-ref/source/player.h b/crawl-ref/source/player.h
index 2ec0821269..bdc557bc09 100644
--- a/crawl-ref/source/player.h
+++ b/crawl-ref/source/player.h
@@ -174,7 +174,7 @@ bool player_item_conserve(bool calc_unid = true);
int player_mental_clarity(bool calc_unid = true, bool items = true);
bool player_can_smell();
-bool player_likes_chunks();
+bool player_likes_chunks(bool permanently = false);
bool player_can_swim();
bool player_likes_water(bool permanently = false);