4 * Created on: Aug 6, 2012
10 #include "AttackChoice.h"
11 #include "Resources.h"
12 #include "../common/Ikari.h"
13 #include "../common/Item.h"
14 #include "../common/Spell.h"
52 void Hero::SubtractHealth(int amount) {
53 if (amount > Health()) {
57 int ipGain(amount * 255 / health);
58 if (ip + ipGain > 255) {
67 void Hero::UpdateSpellMenu() {
69 SpellMenu().Reserve(Spells().size());
70 for (vector<const Spell *>::const_iterator i(Spells().begin()), end(Spells().end()); i != end; ++i) {
71 bool enabled((*i)->CanUseInBattle() && (*i)->Cost() <= Mana());
72 SpellMenu().Add((*i)->Name(), *i, enabled, 0, (*i)->Cost());
76 void Hero::UpdateIkariMenu(const Resources *res) {
78 IkariMenu().Reserve(6);
84 Weapon()->HasIkari() && Weapon()->GetIkari()->Cost() <= IP(),
87 Weapon()->HasIkari() ? Weapon()->GetIkari()->Name() : "");
89 IkariMenu().Add(res->noEquipmentText, 0, false, res->weaponMenuIcon);
96 Armor()->HasIkari() && Armor()->GetIkari()->Cost() <= IP(),
99 Armor()->HasIkari() ? Armor()->GetIkari()->Name() : "");
101 IkariMenu().Add(res->noEquipmentText, 0, false, res->armorMenuIcon);
108 Shield()->HasIkari() && Shield()->GetIkari()->Cost() <= IP(),
111 Shield()->HasIkari() ? Shield()->GetIkari()->Name() : "");
113 IkariMenu().Add(res->noEquipmentText, 0, false, res->shieldMenuIcon);
120 Helmet()->HasIkari() && Helmet()->GetIkari()->Cost() <= IP(),
123 Helmet()->HasIkari() ? Helmet()->GetIkari()->Name() : "");
125 IkariMenu().Add(res->noEquipmentText, 0, false, res->helmetMenuIcon);
132 Ring()->HasIkari() && Ring()->GetIkari()->Cost() <= IP(),
135 Ring()->HasIkari() ? Ring()->GetIkari()->Name() : "");
137 IkariMenu().Add(res->noEquipmentText, 0, false, res->ringMenuIcon);
144 Jewel()->HasIkari() && Jewel()->GetIkari()->Cost() <= IP(),
147 Jewel()->HasIkari() ? Jewel()->GetIkari()->Name() : "");
149 IkariMenu().Add(res->noEquipmentText, 0, false, res->jewelMenuIcon);