]> git.localhorst.tv Git - l2e.git/blob - src/battle/Hero.cpp
7dd8abb26d453d40277cee55307eed744a8665e0
[l2e.git] / src / battle / Hero.cpp
1 #include "Hero.h"
2
3 #include "AttackChoice.h"
4 #include "Resources.h"
5 #include "../common/Ikari.h"
6 #include "../common/Item.h"
7 #include "../common/Spell.h"
8
9 using common::Ikari;
10 using common::Spell;
11 using std::vector;
12
13 namespace battle {
14
15 Hero::Hero()
16 : master(0) {
17
18 }
19
20 Hero::Hero(common::Hero &h)
21 : master(&h)
22 , stats(h.GetStats()) {
23
24 }
25
26 Hero::~Hero() {
27
28 }
29
30
31 void Hero::UpdateSpellMenu() {
32         SpellMenu().Clear();
33         SpellMenu().Reserve(Spells().size());
34         for (vector<const Spell *>::const_iterator i(Spells().begin()), end(Spells().end()); i != end; ++i) {
35                 bool enabled((*i)->CanUseInBattle() && (*i)->Cost() <= Mana());
36                 SpellMenu().Add((*i)->Name(), *i, enabled, 0, (*i)->Cost());
37         }
38 }
39
40 void Hero::UpdateIkariMenu(const Resources *res) {
41         IkariMenu().Clear();
42         IkariMenu().Reserve(6);
43
44         if (HasWeapon()) {
45                 IkariMenu().Add(
46                                 Weapon()->Name(),
47                                 Weapon(),
48                                 Weapon()->HasIkari() && Weapon()->GetIkari()->Cost() <= IP(),
49                                 res->weaponMenuIcon,
50                                 0,
51                                 Weapon()->HasIkari() ? Weapon()->GetIkari()->Name() : "");
52         } else {
53                 IkariMenu().Add(res->noEquipmentText, 0, false, res->weaponMenuIcon);
54         }
55
56         if (HasArmor()) {
57                 IkariMenu().Add(
58                                 Armor()->Name(),
59                                 Armor(),
60                                 Armor()->HasIkari() && Armor()->GetIkari()->Cost() <= IP(),
61                                 res->armorMenuIcon,
62                                 0,
63                                 Armor()->HasIkari() ? Armor()->GetIkari()->Name() : "");
64         } else {
65                 IkariMenu().Add(res->noEquipmentText, 0, false, res->armorMenuIcon);
66         }
67
68         if (HasShield()) {
69                 IkariMenu().Add(
70                                 Shield()->Name(),
71                                 Shield(),
72                                 Shield()->HasIkari() && Shield()->GetIkari()->Cost() <= IP(),
73                                 res->shieldMenuIcon,
74                                 0,
75                                 Shield()->HasIkari() ? Shield()->GetIkari()->Name() : "");
76         } else {
77                 IkariMenu().Add(res->noEquipmentText, 0, false, res->shieldMenuIcon);
78         }
79
80         if (HasHelmet()) {
81                 IkariMenu().Add(
82                                 Helmet()->Name(),
83                                 Helmet(),
84                                 Helmet()->HasIkari() && Helmet()->GetIkari()->Cost() <= IP(),
85                                 res->helmetMenuIcon,
86                                 0,
87                                 Helmet()->HasIkari() ? Helmet()->GetIkari()->Name() : "");
88         } else {
89                 IkariMenu().Add(res->noEquipmentText, 0, false, res->helmetMenuIcon);
90         }
91
92         if (HasRing()) {
93                 IkariMenu().Add(
94                                 Ring()->Name(),
95                                 Ring(),
96                                 Ring()->HasIkari() && Ring()->GetIkari()->Cost() <= IP(),
97                                 res->ringMenuIcon,
98                                 0,
99                                 Ring()->HasIkari() ? Ring()->GetIkari()->Name() : "");
100         } else {
101                 IkariMenu().Add(res->noEquipmentText, 0, false, res->ringMenuIcon);
102         }
103
104         if (HasJewel()) {
105                 IkariMenu().Add(
106                                 Jewel()->Name(),
107                                 Jewel(),
108                                 Jewel()->HasIkari() && Jewel()->GetIkari()->Cost() <= IP(),
109                                 res->jewelMenuIcon,
110                                 0,
111                                 Jewel()->HasIkari() ? Jewel()->GetIkari()->Name() : "");
112         } else {
113                 IkariMenu().Add(res->noEquipmentText, 0, false, res->jewelMenuIcon);
114         }
115 }
116
117 }