X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;ds=sidebyside;f=src%2Fbattle%2FBattleState.cpp;h=5547bbf8235822c64bf6d6ca6ecb49ba98df9af4;hb=9a273798937710928304fdcc5e33a78c6f8b48be;hp=d0bb108da3a65256ce0b9846a8eb6557cc663364;hpb=7263bddbde91d555decd58f043f6b43f54ba2b00;p=l2e.git diff --git a/src/battle/BattleState.cpp b/src/battle/BattleState.cpp index d0bb108..5547bbf 100644 --- a/src/battle/BattleState.cpp +++ b/src/battle/BattleState.cpp @@ -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,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 { @@ -390,6 +393,14 @@ void BattleState::ApplyDamage() { } } +AttackChoice &BattleState::CurrentAttackAttackChoice() { + if (CurrentAttack().isMonster) { + return monsterAttacks[CurrentAttack().index]; + } else { + return AttackChoiceAt(CurrentAttack().index); + } +} + void BattleState::ClearAllAttacks() { attackCursor = -1; activeHero = -1;