]> git.localhorst.tv Git - l2e.git/commitdiff
collecting exp/gold reward in battle state
authorDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 20 Aug 2012 20:46:42 +0000 (22:46 +0200)
committerDaniel Karbach <daniel.karbach@localhorst.tv>
Mon, 20 Aug 2012 20:46:42 +0000 (22:46 +0200)
src/battle/BattleState.cpp
src/battle/BattleState.h

index 84d1a497240da814a105eb64301889b412c7650e..5547bbf8235822c64bf6d6ca6ecb49ba98df9af4 100644 (file)
@@ -375,9 +375,13 @@ 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 {
index a10ff7e8fae2b6947dd651c4a403c9b33c57e76d..9f30fb5a1d439effc3b4ef8857ac1d7d69d1df60 100644 (file)
@@ -58,6 +58,8 @@ public:
        , numHeroes(0)
        , activeHero(-1)
        , attackCursor(-1)
+       , expReward(0)
+       , goldReward(0)
        , ranAway(false) { assert(background && res); }
 
 public:
@@ -190,6 +192,8 @@ private:
        int numHeroes;
        int activeHero;
        int attackCursor;
+       int expReward;
+       int goldReward;
        bool ranAway;
 
 };