2019-12-14 12:28:23 +00:00
|
|
|
#include "ExperienceLibrary.hpp"
|
|
|
|
#include "../Models/Creature.hpp"
|
|
|
|
|
|
|
|
void CreatureLib::Battling::ExperienceLibrary::HandleExperienceGain(
|
2020-06-02 14:20:47 +00:00
|
|
|
CreatureLib::Battling::Creature* faintedMon,
|
|
|
|
const std::unordered_set<ArbUt::BorrowedPtr<Creature>>& opponents) const {
|
2019-12-14 12:28:23 +00:00
|
|
|
for (auto opponent : opponents) {
|
2020-05-20 13:18:27 +00:00
|
|
|
if (opponent->IsFainted())
|
|
|
|
continue;
|
|
|
|
if (!opponent->AllowedExperienceGain())
|
|
|
|
continue;
|
2019-12-14 12:28:23 +00:00
|
|
|
auto levelDiff = faintedMon->GetLevel() - opponent->GetLevel() + 10;
|
|
|
|
if (levelDiff <= 0)
|
|
|
|
continue;
|
|
|
|
auto experienceGain = levelDiff * 10;
|
|
|
|
opponent->AddExperience(static_cast<uint32_t>(experienceGain));
|
|
|
|
}
|
|
|
|
}
|