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

@@ -22,7 +22,6 @@ use crate::{script_hook, PkmnResult, StringKey, ValueIdentifiable, ValueIdentifi
/// A pokemon battle, with any amount of sides and pokemon per side.
#[derive(Debug)]
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
pub struct Battle {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,

View File

@@ -7,7 +7,6 @@ use crate::{ValueIdentifiable, ValueIdentifier};
/// A battle party is a wrapper around a party, with the indices for which the party is responsible
/// on the field attached.
#[derive(Debug)]
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
pub struct BattleParty {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,

View File

@@ -9,7 +9,6 @@ use crate::{script_hook, ValueIdentifiable, ValueIdentifier};
/// The RNG for a battle.
#[derive(Default)]
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
pub struct BattleRandom {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,

View File

@@ -18,7 +18,6 @@ use crate::{script_hook, PkmnResult, StringKey, ValueIdentifiable, ValueIdentifi
/// A side on a battle.
#[derive(Debug)]
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
pub struct BattleSide {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,

View File

@@ -11,12 +11,14 @@ use crate::dynamic_data::script_handling::{ScriptSource, ScriptSourceData, Scrip
use crate::dynamic_data::ScriptContainer;
use crate::dynamic_data::TargetList;
use crate::static_data::{MoveData, TypeIdentifier};
use crate::{PkmnResult, PokemonError};
use crate::{PkmnResult, PokemonError, ValueIdentifiable, ValueIdentifier};
/// A hit data is the data for a single hit, on a single target.
#[derive(Default, Debug)]
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
pub struct HitData {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,
/// Whether or not the hit is critical.
critical: AtomicBool,
/// The base power of the hit.
@@ -85,8 +87,10 @@ impl HitData {
/// An executing move is the data of the move for while it is executing.
#[derive(Debug)]
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
pub struct ExecutingMove {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,
/// The number of hits this move has.
number_of_hits: u8,
/// A list of hits for this move. For multi target multi hit moves, this stores the hits linearly,
@@ -122,6 +126,7 @@ impl ExecutingMove {
hits.push(HitData::default())
}
Self {
identifier: Default::default(),
number_of_hits,
hits,
user,
@@ -218,3 +223,15 @@ impl ScriptSource for ExecutingMove {
self.user.get_own_scripts(scripts);
}
}
impl ValueIdentifiable for ExecutingMove {
fn value_identifier(&self) -> ValueIdentifier {
self.identifier
}
}
impl ValueIdentifiable for HitData {
fn value_identifier(&self) -> ValueIdentifier {
self.identifier
}
}

View File

@@ -7,7 +7,6 @@ use crate::{ValueIdentifiable, ValueIdentifier};
/// A learned move is the data attached to a Pokemon for a move it has learned. It has information
/// such as the remaining amount of users, how it has been learned, etc.
#[derive(Debug)]
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
pub struct LearnedMove {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,

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();
}

View File

@@ -7,7 +7,6 @@ use crate::{ValueIdentifiable, ValueIdentifier};
/// A list of Pokemon belonging to a trainer.
#[derive(Debug)]
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
pub struct PokemonParty {
/// A unique identifier so we know what value this is.
identifier: ValueIdentifier,