19 lines
683 B
C++
19 lines
683 B
C++
#include "ExperienceLibrary.hpp"
|
|
#include "../Models/Creature.hpp"
|
|
|
|
void CreatureLib::Battling::ExperienceLibrary::HandleExperienceGain(
|
|
CreatureLib::Battling::Creature* faintedMon,
|
|
const std::unordered_set<ArbUt::BorrowedPtr<Creature>>& opponents) const {
|
|
for (auto opponent : opponents) {
|
|
if (opponent->IsFainted())
|
|
continue;
|
|
if (!opponent->AllowedExperienceGain())
|
|
continue;
|
|
auto levelDiff = faintedMon->GetLevel() - opponent->GetLevel() + 10;
|
|
if (levelDiff <= 0)
|
|
continue;
|
|
auto experienceGain = levelDiff * 10;
|
|
opponent->AddExperience(static_cast<uint32_t>(experienceGain));
|
|
}
|
|
}
|