X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FHero.cpp;h=d09b824d4961f5edb5fc397ec90740de8eae86dd;hb=3d69f521b593457304b282e5f23e36ab165288b6;hp=4bfdf0a0cf651e879cb80d7b1bad92e12effd892;hpb=c0068263474818f39e704eee12f753c0419f7708;p=l2e.git diff --git a/src/battle/Hero.cpp b/src/battle/Hero.cpp index 4bfdf0a..d09b824 100644 --- a/src/battle/Hero.cpp +++ b/src/battle/Hero.cpp @@ -1,43 +1,26 @@ -/* - * 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) - -, meleeAnimation(0) -, attackAnimation(0) -, spellAnimation(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()) { } @@ -45,4 +28,91 @@ Hero::~Hero() { } + +void Hero::UpdateSpellMenu() { + SpellMenu().Clear(); + SpellMenu().Reserve(Spells().size()); + for (vector::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); + } +} + }