spellMenus[index].Clear();
spellMenus[index].Reserve(HeroAt(index).Spells().size());
for (vector<const Spell *>::const_iterator i(HeroAt(index).Spells().begin()), end(HeroAt(index).Spells().end()); i != end; ++i) {
spellMenus[index].Clear();
spellMenus[index].Reserve(HeroAt(index).Spells().size());
for (vector<const Spell *>::const_iterator i(HeroAt(index).Spells().begin()), end(HeroAt(index).Spells().end()); i != end; ++i) {
attackOrder.push_back(Order(i, false));
}
for (vector<Monster>::size_type i(0), end(monsters.size()); i < end; ++i) {
attackOrder.push_back(Order(i, false));
}
for (vector<Monster>::size_type i(0), end(monsters.size()); i < end; ++i) {
void BattleState::CalculateDamage() {
AttackChoice &ac(CurrentAttack().isMonster ? monsterAttacks[CurrentAttack().index] : AttackChoiceAt(CurrentAttack().index));
if (ac.GetType() == AttackChoice::DEFEND) return;
void BattleState::CalculateDamage() {
AttackChoice &ac(CurrentAttack().isMonster ? monsterAttacks[CurrentAttack().index] : AttackChoiceAt(CurrentAttack().index));
if (ac.GetType() == AttackChoice::DEFEND) return;
TargetSelection &ts(ac.Selection());
if (ts.TargetsEnemies()) {
for (int i(0); i < MaxMonsters(); ++i) {
TargetSelection &ts(ac.Selection());
if (ts.TargetsEnemies()) {
for (int i(0); i < MaxMonsters(); ++i) {
- MonsterAt(i).SubtractHealth(ts.GetAmount(i));
+ monster.SubtractHealth(ts.GetAmount(i));
+ if (monster.Health() == 0) {
+ expReward += monster.ExpReward();
+ goldReward += monster.GoldReward();
+ }
Vector<int> offset(CalculateScreenOffset(screen));
RenderBackground(screen, offset);
RenderMonsters(screen, offset);
}
void BattleState::RenderBackground(SDL_Surface *screen, const Vector<int> &offset) {
Vector<int> offset(CalculateScreenOffset(screen));
RenderBackground(screen, offset);
RenderMonsters(screen, offset);
}
void BattleState::RenderBackground(SDL_Surface *screen, const Vector<int> &offset) {
// black for now
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
SDL_Rect destRect;
// black for now
SDL_FillRect(screen, 0, SDL_MapRGB(screen->format, 0, 0, 0));
SDL_Rect destRect;
for (vector<Monster>::size_type i(0), end(monsters.size()); i < end; ++i) {
if (MonsterPositionOccupied(i)) {
// TODO: better solution for running animations
for (vector<Monster>::size_type i(0), end(monsters.size()); i < end; ++i) {
if (MonsterPositionOccupied(i)) {
// TODO: better solution for running animations
for (int i(0); i < numHeroes; ++i) {
if (heroes[i].AttackAnimation() && heroes[i].AttackAnimation()->Running()) {
heroes[i].AttackAnimation()->DrawCenter(screen, heroesPositions[i] + offset);
for (int i(0); i < numHeroes; ++i) {
if (heroes[i].AttackAnimation() && heroes[i].AttackAnimation()->Running()) {
heroes[i].AttackAnimation()->DrawCenter(screen, heroesPositions[i] + offset);
int tagHeight(attackTypeMenu.Height());
int tagWidth(attackTypeMenu.Width() * 2 + attackTypeMenu.Width() / 2);
int tagHeight(attackTypeMenu.Height());
int tagWidth(attackTypeMenu.Width() * 2 + attackTypeMenu.Width() / 2);
int tagHeight(res->normalFont->CharHeight() * 4 + res->smallHeroTagFrame->BorderHeight() * 2);
int tagWidth(res->normalFont->CharWidth() * 6 + res->smallHeroTagFrame->BorderWidth() * 2);
int tagHeight(res->normalFont->CharHeight() * 4 + res->smallHeroTagFrame->BorderHeight() * 2);
int tagWidth(res->normalFont->CharWidth() * 6 + res->smallHeroTagFrame->BorderWidth() * 2);