]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/Hero.cpp
removed stupid file headers that eclipse put in
[l2e.git] / src / battle / Hero.cpp
index 3fbd320dc6e308d0e40651e4db1f66f239030f8b..7dd8abb26d453d40277cee55307eed744a8665e0 100644 (file)
@@ -1,32 +1,25 @@
-/*
- * 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"
+
+using common::Ikari;
+using common::Spell;
+using std::vector;
+
 namespace battle {
 
 Hero::Hero()
-: name("")
-, sprite(0)
-
-, maxHealth(0)
-, health(0)
-, maxMana(0)
-, mana(0)
+: master(0) {
 
-, attack(0)
-, defense(0)
-, agility(0)
-, intelligence(0)
-, gut(0)
-, magicResistance(0)
+}
 
-, level(0)
-, ip(0) {
+Hero::Hero(common::Hero &h)
+: master(&h)
+, stats(h.GetStats()) {
 
 }
 
@@ -34,4 +27,91 @@ Hero::~Hero() {
 
 }
 
+
+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);
+       }
+}
+
 }