X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fbattle%2FHero.cpp;h=1d8393e0395daca372e466a0b069e83764a0d2a7;hb=f552d26f537af9fa48255bd71cdc1a0a1b860bac;hp=4bcc6d30175b9372170288cf0d3c3e6551d1b2da;hpb=fa3de7178227b9cc7f11c92208b5904cee3ae4c4;p=l2e.git diff --git a/src/battle/Hero.cpp b/src/battle/Hero.cpp index 4bcc6d3..1d8393e 100644 --- a/src/battle/Hero.cpp +++ b/src/battle/Hero.cpp @@ -7,33 +7,26 @@ #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) - -, 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()) { } @@ -41,4 +34,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); + } +} + }