diff --git a/src/Battling/Pokemon/Pokemon.cpp b/src/Battling/Pokemon/Pokemon.cpp index 7c1034d..112e82f 100644 --- a/src/Battling/Pokemon/Pokemon.cpp +++ b/src/Battling/Pokemon/Pokemon.cpp @@ -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 {