Skip to content

Commit

Permalink
Add check to PokemonCollection that we don't add more Pokemon to a …
Browse files Browse the repository at this point in the history
…SeenTeam than the team actually has.
  • Loading branch information
davidstone committed May 9, 2024
1 parent 288606d commit fb04216
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions source/tm/pokemon/pokemon_collection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,11 @@ struct PokemonCollection {
}

constexpr auto add(PokemonType pokemon) -> PokemonType & requires any_seen_pokemon<PokemonType> {
if constexpr (any_seen_pokemon<PokemonType>) {
if (m_real_size == containers::size(m_container)) {
throw std::runtime_error("Tried to add too many Pokemon to a SeenTeam");
}
}
return containers::push_back(m_container, std::move(pokemon));
}

Expand Down

0 comments on commit fb04216

Please sign in to comment.