]> git.localhorst.tv Git - l2e.git/blobdiff - src/battle/BattleState.cpp
put hero into a variable when applying damage for debugging purposes
[l2e.git] / src / battle / BattleState.cpp
index d0bb108da3a65256ce0b9846a8eb6557cc663364..bd039ff588c7e86bb278065dad1a49bd092a1c5d 100644 (file)
@@ -211,7 +211,6 @@ void BattleState::ExitState(Application &ctrl, SDL_Surface *screen) {
 }
 
 void BattleState::ResumeState(Application &ctrl, SDL_Surface *screen) {
-       // TODO: check for victory or defeat
        if (ranAway) {
                ctrl.PopState(); // quit the battle scene
                return;
@@ -376,20 +375,33 @@ void BattleState::ApplyDamage() {
        TargetSelection &ts(ac.Selection());
        if (ts.TargetsEnemies()) {
                for (int i(0); i < MaxMonsters(); ++i) {
+                       Monster &monster(MonsterAt(i));
                        if (ts.IsBad(i)) {
-                               MonsterAt(i).SubtractHealth(ts.GetAmount(i));
-                               // TODO: collect reward if dead
+                               monster.SubtractHealth(ts.GetAmount(i));
+                               if (monster.Health() == 0) {
+                                       expReward += monster.ExpReward();
+                                       goldReward += monster.GoldReward();
+                               }
                        }
                }
        } else {
                for (int i(0); i < NumHeroes(); ++i) {
+                       Hero &hero(HeroAt(i));
                        if (ts.IsBad(i)) {
-                               HeroAt(i).SubtractHealth(ts.GetAmount(i));
+                               hero.SubtractHealth(ts.GetAmount(i));
                        }
                }
        }
 }
 
+AttackChoice &BattleState::CurrentAttackAttackChoice() {
+       if (CurrentAttack().isMonster) {
+               return monsterAttacks[CurrentAttack().index];
+       } else {
+               return AttackChoiceAt(CurrentAttack().index);
+       }
+}
+
 void BattleState::ClearAllAttacks() {
        attackCursor = -1;
        activeHero = -1;