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