diff options
author | ennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-01-05 18:16:35 +0000 |
---|---|---|
committer | ennewalker <ennewalker@c06c8d41-db1a-0410-9941-cceddc491573> | 2008-01-05 18:16:35 +0000 |
commit | ed292ae42a345b986f295c49afb59cb2ed27280c (patch) | |
tree | 7c3fd8f7b3783c8dd1f78be4f9d12a5661c4dc0a /crawl-ref/source/food.cc | |
parent | 076f55f3906d1693015193cc9e1dc598dc43398a (diff) | |
download | crawl-ref-ed292ae42a345b986f295c49afb59cb2ed27280c.tar.gz crawl-ref-ed292ae42a345b986f295c49afb59cb2ed27280c.zip |
Exposing (species-dependent) max and min hunger so that tiles can use that info.
git-svn-id: https://crawl-ref.svn.sourceforge.net/svnroot/crawl-ref/trunk@3204 c06c8d41-db1a-0410-9941-cceddc491573
Diffstat (limited to 'crawl-ref/source/food.cc')
-rw-r--r-- | crawl-ref/source/food.cc | 45 |
1 files changed, 32 insertions, 13 deletions
diff --git a/crawl-ref/source/food.cc b/crawl-ref/source/food.cc index 6f7133cd2e..ff0aef44a9 100644 --- a/crawl-ref/source/food.cc +++ b/crawl-ref/source/food.cc @@ -553,19 +553,8 @@ static bool food_change(bool suppress_message) char newstate = HS_ENGORGED; bool state_changed = false; - // this case shouldn't actually happen: - if (you.is_undead == US_UNDEAD) - you.hunger = 6000; - - // take care of ghouls - they can never be 'full' - if (you.species == SP_GHOUL && you.hunger > 6999) - you.hunger = 6999; - - // vampires can never be engorged or starve to death - if (you.species == SP_VAMPIRE && you.hunger <= 700) - you.hunger = 701; - if (you.species == SP_VAMPIRE && you.hunger > 10999) - you.hunger = 10999; + you.hunger = std::max(you_min_hunger(), you.hunger); + you.hunger = std::min(you_max_hunger(), you.hunger); // get new hunger state if (you.hunger <= 1000) @@ -1647,3 +1636,33 @@ static void heal_from_food(int hp_amt, int mp_amt, bool unrot, calc_hp(); calc_mp(); } // end heal_from_food() + +int you_max_hunger() +{ + // this case shouldn't actually happen: + if (you.is_undead == US_UNDEAD) + return 6000; + + // take care of ghouls - they can never be 'full' + if (you.species == SP_GHOUL) + return 6999; + + // vampires can never be engorged + if (you.species == SP_VAMPIRE) + return 10999; + + return 40000; +} + +int you_min_hunger() +{ + // this case shouldn't actually happen: + if (you.is_undead == US_UNDEAD) + return 6000; + + // vampires can never starve to death + if (you.species == SP_VAMPIRE) + return 701; + + return 0; +} |