Defensive programming.
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2020-08-17 18:23:25 +02:00
parent f3721ad2a5
commit cc92cf1491
10 changed files with 67 additions and 26 deletions

View File

@@ -20,12 +20,15 @@ void PkmnLib::Battling::ExperienceLibrary::HandleExperienceGain(
const std::unordered_set<ArbUt::BorrowedPtr<CreatureLib::Battling::Creature>>& opponents) const {
auto fainted = dynamic_cast<Pokemon*>(faintedMon);
auto expGain = fainted->GetForme()->GetBaseExperience();
AssertNotNull(fainted);
auto& forme = fainted->GetForme();
AssertNotNull(forme);
auto expGain = forme->GetBaseExperience();
auto level = fainted->GetLevel();
float v1 = (expGain * level) / 5;
for (auto op : opponents) {
for (const auto& op : opponents) {
if (!op->AllowedExperienceGain())
continue;
auto experienceGain = CalculateDynamicExperience(level, v1, op, fainted);