Loads of cleanup
Some checks reported errors
continuous-integration/drone/push Build was killed

This commit is contained in:
2022-11-27 17:29:29 +01:00
parent aa3ceaed3e
commit efd1acdfa5
45 changed files with 259 additions and 162 deletions

View File

@@ -26,7 +26,6 @@ use crate::{script_hook, PkmnResult, StringKey, ValueIdentifiable, ValueIdentifi
/// An individual Pokemon as we know and love them.
#[derive(Debug)]
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
pub struct Pokemon {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,
@@ -57,7 +56,7 @@ pub struct Pokemon {
/// currently not used, and can be used for other implementations.
coloring: u8,
/// The held item of the Pokemon.
held_item: RwLock<Option<Arc<Item>>>,
held_item: RwLock<Option<Arc<dyn Item>>>,
/// The remaining health points of the Pokemon.
current_health: AtomicU32,
@@ -238,7 +237,7 @@ impl Pokemon {
self.coloring
}
/// Gets the held item of a Pokemon
pub fn held_item(&self) -> &RwLock<Option<Arc<Item>>> {
pub fn held_item(&self) -> &RwLock<Option<Arc<dyn Item>>> {
&self.held_item
}
/// Checks whether the Pokemon is holding a specific item.
@@ -250,11 +249,11 @@ impl Pokemon {
false
}
/// Changes the held item of the Pokemon. Returns the previously held item.
pub fn set_held_item(&self, item: &Arc<Item>) -> Option<Arc<Item>> {
pub fn set_held_item(&self, item: &Arc<dyn Item>) -> Option<Arc<dyn Item>> {
self.held_item.write().replace(item.clone())
}
/// Removes the held item from the Pokemon. Returns the previously held item.
pub fn remove_held_item(&self) -> Option<Arc<Item>> {
pub fn remove_held_item(&self) -> Option<Arc<dyn Item>> {
self.held_item.write().take()
}
/// Makes the Pokemon uses its held item.
@@ -524,7 +523,7 @@ impl Pokemon {
.set(ability_script)
.as_ref()
// Ensure the ability script gets initialized with the parameters for the ability.
.on_initialize(self.library.as_ref(), self.active_ability().parameters())
.on_initialize(self.library.as_ref(), self.active_ability().parameters().to_vec())
} else {
self.ability_script.clear();
}