Fixes battle not ending on capture of last pokemon
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2022-05-15 11:31:39 +02:00
parent 812ef65ea0
commit 3aa6e28a62
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
1 changed files with 9 additions and 2 deletions

View File

@ -91,8 +91,15 @@ void PkmnLib::Battling::Pokemon::AttemptCapture(PkmnLib::Library::Item* catchIte
if (result.WasCaught) {
// By marking the pokemon as caught, it becomes no longer usable for switch in.
_wasCaught = true;
// As the pokemon is caught now, we replace it with an empty space.
_battleData.Side.GetValue()->SetCreature(nullptr, _battleData.Index.GetCreatureIndex());
if (_battleData.Battle.HasValue() && _battleData.Side.HasValue()) {
auto sideIndex = _battleData.Side.GetValue()->GetCreatureIndex(this);
if (!_battleData.Battle.GetValue()->CanSlotBeFilled(_battleData.Side.GetValue()->GetSideIndex(),
sideIndex)) {
_battleData.Side.GetValue()->MarkSlotAsUnfillable(this);
}
_battleData.Battle.GetValue()->ValidateBattleState();
}
}
}
void PkmnLib::Battling::Pokemon::ClearBattleData() noexcept {