-/*
- * Hero.cpp
- *
- * Created on: Aug 6, 2012
- * Author: holy
- */
-
#include "Hero.h"
+#include "AttackChoice.h"
+#include "Resources.h"
+#include "../common/Ikari.h"
+#include "../common/Item.h"
+#include "../common/Spell.h"
+#include "../math/Vector.h"
+
+using common::Ikari;
+using common::Spell;
+using std::vector;
+
namespace battle {
Hero::Hero()
-: name("")
-, sprite(0)
-
-, weapon(0)
-, armor(0)
-, shield(0)
-, helmet(0)
-, ring(0)
-, jewel(0)
-
-, maxHealth(0)
-, health(0)
-, maxMana(0)
-, mana(0)
-
-, attack(0)
-, defense(0)
-, agility(0)
-, intelligence(0)
-, gut(0)
-, magicResistance(0)
-
-, level(0)
-, ip(0) {
+: master(0) {
+
+}
+
+Hero::Hero(common::Hero &h)
+: master(&h)
+, stats(h.GetStats()) {
}
}
+
+void Hero::UpdateSpellMenu() {
+ SpellMenu().Clear();
+ SpellMenu().Reserve(Spells().size());
+ for (vector<const Spell *>::const_iterator i(Spells().begin()), end(Spells().end()); i != end; ++i) {
+ bool enabled((*i)->CanUseInBattle() && (*i)->Cost() <= Mana());
+ SpellMenu().Add((*i)->Name(), *i, enabled, 0, (*i)->Cost());
+ }
+}
+
+void Hero::UpdateIkariMenu(const Resources *res) {
+ IkariMenu().Clear();
+ IkariMenu().Reserve(6);
+
+ if (HasWeapon()) {
+ IkariMenu().Add(
+ Weapon()->Name(),
+ Weapon(),
+ Weapon()->HasIkari() && Weapon()->GetIkari()->Cost() <= IP(),
+ res->weaponMenuIcon,
+ 0,
+ Weapon()->HasIkari() ? Weapon()->GetIkari()->Name() : "");
+ } else {
+ IkariMenu().Add(res->noEquipmentText, 0, false, res->weaponMenuIcon);
+ }
+
+ if (HasArmor()) {
+ IkariMenu().Add(
+ Armor()->Name(),
+ Armor(),
+ Armor()->HasIkari() && Armor()->GetIkari()->Cost() <= IP(),
+ res->armorMenuIcon,
+ 0,
+ Armor()->HasIkari() ? Armor()->GetIkari()->Name() : "");
+ } else {
+ IkariMenu().Add(res->noEquipmentText, 0, false, res->armorMenuIcon);
+ }
+
+ if (HasShield()) {
+ IkariMenu().Add(
+ Shield()->Name(),
+ Shield(),
+ Shield()->HasIkari() && Shield()->GetIkari()->Cost() <= IP(),
+ res->shieldMenuIcon,
+ 0,
+ Shield()->HasIkari() ? Shield()->GetIkari()->Name() : "");
+ } else {
+ IkariMenu().Add(res->noEquipmentText, 0, false, res->shieldMenuIcon);
+ }
+
+ if (HasHelmet()) {
+ IkariMenu().Add(
+ Helmet()->Name(),
+ Helmet(),
+ Helmet()->HasIkari() && Helmet()->GetIkari()->Cost() <= IP(),
+ res->helmetMenuIcon,
+ 0,
+ Helmet()->HasIkari() ? Helmet()->GetIkari()->Name() : "");
+ } else {
+ IkariMenu().Add(res->noEquipmentText, 0, false, res->helmetMenuIcon);
+ }
+
+ if (HasRing()) {
+ IkariMenu().Add(
+ Ring()->Name(),
+ Ring(),
+ Ring()->HasIkari() && Ring()->GetIkari()->Cost() <= IP(),
+ res->ringMenuIcon,
+ 0,
+ Ring()->HasIkari() ? Ring()->GetIkari()->Name() : "");
+ } else {
+ IkariMenu().Add(res->noEquipmentText, 0, false, res->ringMenuIcon);
+ }
+
+ if (HasJewel()) {
+ IkariMenu().Add(
+ Jewel()->Name(),
+ Jewel(),
+ Jewel()->HasIkari() && Jewel()->GetIkari()->Cost() <= IP(),
+ res->jewelMenuIcon,
+ 0,
+ Jewel()->HasIkari() ? Jewel()->GetIkari()->Name() : "");
+ } else {
+ IkariMenu().Add(res->noEquipmentText, 0, false, res->jewelMenuIcon);
+ }
+}
+
}