public IActionResult Encounter(PokemonSearch pokemonSearch) { Local local = Locals.FindOneByID(pokemonSearch.LocalID); Player player = Players.FindOneByID(pokemonSearch.PlayerID); if (local != null && player != null) { Encounter encounter = new Encounter(); encounter.ID = ++GameState.EncounterID; encounter.LocalID = pokemonSearch.LocalID; encounter.PlayerID = pokemonSearch.PlayerID; PokemonEncountered pokemonEncountered = PokemonEncounter.FindPokemon(local); encounter.PokemonEncountered = pokemonEncountered; if (pokemonEncountered != null) { encounter.PokemonAlreadyCaught = player.Pokedex.Pokemons.FirstOrDefault(pokedexPokemon => pokedexPokemon.PokemonID == pokemonEncountered.LocalPokemon.PokemonID && pokedexPokemon.Enabled) != null; encounter.CanBattle = player.CatchedAnyPokemon(); } GameState.Encounters.Add(encounter); return(Ok(encounter)); } return(BadRequest()); }