A lot more work on WASM script execution
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2022-09-07 18:01:26 +02:00
parent f9761f61da
commit b1890681a1
102 changed files with 748 additions and 202 deletions

13
src/dynamic_data/models/pokemon_party.rs Normal file → Executable file
View 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
}
}