A lot more work on WASM script execution
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:
13
src/dynamic_data/models/pokemon_party.rs
Normal file → Executable file
13
src/dynamic_data/models/pokemon_party.rs
Normal file → Executable file
@@ -4,6 +4,7 @@ use crate::dynamic_data::models::pokemon::Pokemon;
|
||||
|
||||
/// A list of Pokemon belonging to a trainer.
|
||||
#[derive(Debug)]
|
||||
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
|
||||
pub struct PokemonParty {
|
||||
/// The underlying list of Pokemon.
|
||||
pokemon: Vec<Option<Arc<Pokemon>>>,
|
||||
@@ -89,4 +90,16 @@ impl PokemonParty {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Checks if the party contains a given pokemon.
|
||||
pub fn has_pokemon(&self, pokemon: &Pokemon) -> bool {
|
||||
for p in &self.pokemon {
|
||||
if let Some(p) = p {
|
||||
if std::ptr::eq(p.as_ref(), pokemon) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user