X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fcommon%2FHero.h;fp=src%2Fcommon%2FHero.h;h=d78d14958f37344de310847c8be5f3145cb073e9;hb=06b6411e5dc8fc6b905530f7adbde8bd0c2bb0ea;hp=0000000000000000000000000000000000000000;hpb=e02068d51f5e7f82d4d3195e9a9ce5c9d76f727d;p=l2e.git diff --git a/src/common/Hero.h b/src/common/Hero.h new file mode 100644 index 0000000..d78d149 --- /dev/null +++ b/src/common/Hero.h @@ -0,0 +1,123 @@ +/* + * Hero.h + * + * Created on: Oct 7, 2012 + * Author: holy + */ + +#ifndef COMMON_HERO_H_ +#define COMMON_HERO_H_ + +#include "fwd.h" +#include "Stats.h" +#include "../graphics/fwd.h" + +#include + +namespace common { + +class Hero { + +public: + Hero(); + ~Hero() { } + +public: + const char *Name() const { return name; } + + Uint16 MaxHealth() const { return maxHealth; } + Uint16 Health() const { return health; } + int RelativeHealth(int max) const { return Health() * max / MaxHealth(); } + void SubtractHealth(int amount); + + Uint16 MaxMana() const { return maxMana; } + Uint16 Mana() const { return mana; } + int RelativeMana(int max) const { return MaxMana() == 0 ? 0 : Mana() * max / MaxMana(); } + bool CanUseMagic() const { return MaxMana() > 0; } + + Uint8 MaxIP() const { return 255; } + Uint8 IP() const { return ip; } + int RelativeIP(int max) const { return IP() * max / MaxIP(); } + + Stats &GetStats() { return stats; } + const Stats &GetStats() const { return stats; } + + Uint8 Level() const { return level; } + + Item *Weapon() { return weapon; } + Item *Armor() { return armor; } + Item *Shield() { return shield; } + Item *Helmet() { return helmet; } + Item *Ring() { return ring; } + Item *Jewel() { return jewel; } + + const Item *Weapon() const { return weapon; } + const Item *Armor() const { return armor; } + const Item *Shield() const { return shield; } + const Item *Helmet() const { return helmet; } + const Item *Ring() const { return ring; } + const Item *Jewel() const { return jewel; } + + bool HasWeapon() const { return weapon; } + bool HasArmor() const { return armor; } + bool HasShield() const { return shield; } + bool HasHelmet() const { return helmet; } + bool HasRing() const { return ring; } + bool HasJewel() const { return jewel; } + + const std::vector &Spells() const { return spells; } + + graphics::Sprite *BattleSprite() { return battleSprite; } + graphics::Animation *MeleeAnimation() { return meleeAnimation; } + graphics::Animation *AttackAnimation() { return attackAnimation; } + graphics::Animation *SpellAnimation() { return spellAnimation; } + + graphics::Sprite *MapSprite() { return mapSprite; } + + static void CreateTypeDescription(); + static void Construct(void *); + +// temporary setters +public: + void SetWeapon(common::Item *i) { weapon = i; } + void SetArmor(common::Item *i) { armor = i; } + void SetShield(common::Item *i) { shield = i; } + void SetHelmet(common::Item *i) { helmet = i; } + void SetRing(common::Item *i) { ring = i; } + void SetJewel(common::Item *i) { jewel = i; } + + void AddSpell(Spell *s) { spells.push_back(s); } + +private: + const char *name; + + int maxHealth, health; + int maxMana, mana; + int ip; + + Stats stats; + + int level; + + Item *weapon; + Item *armor; + Item *shield; + Item *helmet; + Item *ring; + Item *jewel; + + // TODO: vector does not seem to be a good choice + std::vector spells; + + graphics::Sprite *battleSprite; + graphics::Animation *meleeAnimation; + graphics::Animation *attackAnimation; + graphics::Animation *spellAnimation; + + graphics::Sprite *mapSprite; + +}; + +} + +#endif /* COMMON_HERO_H_ */