Implements experience gain on opponent faint.
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2019-12-14 13:28:23 +01:00
parent 3baed93597
commit 649de39571
9 changed files with 119 additions and 21 deletions

View File

@@ -0,0 +1,13 @@
#include "ExperienceLibrary.hpp"
#include "../Models/Creature.hpp"
void CreatureLib::Battling::ExperienceLibrary::HandleExperienceGain(
CreatureLib::Battling::Creature* faintedMon, const std::unordered_set<Creature*>& opponents) const {
for (auto opponent : opponents) {
auto levelDiff = faintedMon->GetLevel() - opponent->GetLevel() + 10;
if (levelDiff <= 0)
continue;
auto experienceGain = levelDiff * 10;
opponent->AddExperience(static_cast<uint32_t>(experienceGain));
}
}