Defensive programming.
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user