From 64e4d12734ccf937c966414ff514c9ae4d7a1be8 Mon Sep 17 00:00:00 2001 From: Deskull Date: Sat, 8 Mar 2014 23:05:55 +0900 Subject: [PATCH] Add GetLevel() to Creature class. --- Deeangband/Creature.cpp | 12 +++++++++++- Deeangband/Creature.h | 8 +++++++- Deeangband/Deeangband.h | 1 + 3 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Deeangband/Creature.cpp b/Deeangband/Creature.cpp index 472db8b..c2e32a2 100644 --- a/Deeangband/Creature.cpp +++ b/Deeangband/Creature.cpp @@ -9,7 +9,7 @@ #include "stdafx.h" #include "Creature.h" -static const SOUL soulLevel[CREATURE_MAX_LEVEL] = +const SOUL Creature::soulLevel[CREATURE_MAX_LEVEL] = { // 0 45, @@ -185,6 +185,16 @@ string Creature::GetName(void) return name; } +LEVEL Creature::GetLevel(void) +{ + LEVEL level; + for(level = 1; level < CREATURE_MAX_LEVEL; level++) + { + if(Creature::soulLevel[level - 1] > this->currentSoul) return level; + } + return level; +} + HP Creature::GetCurHP(void) { return currentHp; diff --git a/Deeangband/Creature.h b/Deeangband/Creature.h index 0c19448..406f6f7 100644 --- a/Deeangband/Creature.h +++ b/Deeangband/Creature.h @@ -26,7 +26,7 @@ class Creature : public GameElement { private: - static const SOUL soulLevel; //!< •K—vƒ\ƒEƒ‹ƒŒƒxƒ‹ƒe[ƒuƒ‹ + static const SOUL soulLevel[CREATURE_MAX_LEVEL]; //!< •K—vƒ\ƒEƒ‹ƒŒƒxƒ‹ƒe[ƒuƒ‹ string name; //!< ƒNƒŠ[ƒ`ƒƒ[‚Ì–¼‘O HP currentHp; //!< Œ»Ý‚ÌHP @@ -137,6 +137,12 @@ public: */ bool Creature::TakeEffect(Effect* effectPtr, POWER amount); + /*! + * @brief ƒNƒŠ[ƒ`ƒƒ[‚ÌŒ»ƒŒƒxƒ‹‚ð•Ô‚· + * @return ƒNƒŠ[ƒ`ƒƒ[‚ÌŒ»ƒŒƒxƒ‹ + */ + LEVEL Creature::GetLevel(void); + /*! * @brief ƒNƒŠ[ƒ`ƒƒ[‚ÌŒ»HP‚ð•Ô‚· * @return ƒNƒŠ[ƒ`ƒƒ[‚ÌŒ»HP diff --git a/Deeangband/Deeangband.h b/Deeangband/Deeangband.h index 520c34d..8b1503f 100644 --- a/Deeangband/Deeangband.h +++ b/Deeangband/Deeangband.h @@ -69,6 +69,7 @@ class Door; class Trap; typedef int BASE_STATUS; //!< Šî‘b”\—Í’l‚̕ϐ”Œ^ +typedef int LEVEL; //!< LEVEL‚̕ϐ”Œ^ typedef int HP; //!< HP‚̕ϐ”Œ^ typedef int MP; //!< MP‚̕ϐ”Œ^ typedef int64_t SOUL; //!< ƒ\ƒEƒ‹‚̕ϐ”Œ^ -- 2.11.0