diff --git a/gen_7_scripts/src/moves/struggle.rs b/gen_7_scripts/src/moves/struggle.rs index d1058aa..f087e7a 100644 --- a/gen_7_scripts/src/moves/struggle.rs +++ b/gen_7_scripts/src/moves/struggle.rs @@ -55,7 +55,8 @@ impl Script for Struggle { if damage == 0 { damage = 1 } - mv.user().damage(damage, DamageSource::Struggle)?; + mv.user() + .damage(damage, DamageSource::Struggle, Default::default())?; Ok(()) } diff --git a/pkmn_lib_interface/Cargo.toml b/pkmn_lib_interface/Cargo.toml index 7095c68..6d9ed6a 100755 --- a/pkmn_lib_interface/Cargo.toml +++ b/pkmn_lib_interface/Cargo.toml @@ -15,4 +15,5 @@ paste = { version = "1.0.7" } hashbrown = { version = "0.13.2" } dlmalloc = { version = "0.2.4", features = ["global"] } mockall = { version = "0.11.2", optional = true, features = ["nightly"] } -num-traits = { version = "0.2", default-features = false } \ No newline at end of file +num-traits = { version = "0.2", default-features = false } +uuid = { version = "1.3.4", default-features = false } \ No newline at end of file diff --git a/pkmn_lib_interface/src/app_interface/dynamic_data/mod.rs b/pkmn_lib_interface/src/app_interface/dynamic_data/mod.rs index dfd91d3..84f16d7 100755 --- a/pkmn_lib_interface/src/app_interface/dynamic_data/mod.rs +++ b/pkmn_lib_interface/src/app_interface/dynamic_data/mod.rs @@ -25,3 +25,20 @@ pub use pokemon::*; pub use statistic_set::*; pub use turn_choices::*; pub use with_volatile::*; + +#[derive(Default, Copy, Clone)] +pub struct EventBatchId { + id: uuid::Uuid, +} + +impl EventBatchId { + pub fn as_u64_pair(&self) -> (u64, u64) { + self.id.as_u64_pair() + } + + pub fn from_u64_pair(a: u64, b: u64) -> Self { + Self { + id: uuid::Uuid::from_u64_pair(a, b), + } + } +} \ No newline at end of file diff --git a/pkmn_lib_interface/src/app_interface/dynamic_data/pokemon.rs b/pkmn_lib_interface/src/app_interface/dynamic_data/pokemon.rs index 06dc2fd..754495b 100755 --- a/pkmn_lib_interface/src/app_interface/dynamic_data/pokemon.rs +++ b/pkmn_lib_interface/src/app_interface/dynamic_data/pokemon.rs @@ -1,7 +1,7 @@ use crate::app_interface::{ - Ability, AbilityIndex, Battle, BattleSide, ClampedStatisticSet, DynamicLibrary, Form, Gender, - Item, LearnedMove, LevelInt, Nature, Species, Statistic, StatisticSet, TypeIdentifier, - WithVolatile, + Ability, AbilityIndex, Battle, BattleSide, ClampedStatisticSet, DynamicLibrary, EventBatchId, + Form, Gender, Item, LearnedMove, LevelInt, Nature, Species, Statistic, StatisticSet, + TypeIdentifier, WithVolatile, }; use crate::handling::Script; use alloc::boxed::Box; @@ -65,7 +65,12 @@ pub trait PokemonTrait: WithVolatile { fn change_species(&self, species: Species, form: Form); fn change_form(&self, form: Form); fn is_fainted(&self) -> PkmnResult; - fn damage(&self, damage: u32, source: DamageSource) -> PkmnResult<()>; + fn damage( + &self, + damage: u32, + source: DamageSource, + event_batch_id: EventBatchId, + ) -> PkmnResult<()>; fn heal(&self, amount: u32, allow_revive: bool) -> PkmnResult; fn set_weight(&self, weight: f32); fn clear_status(&self); @@ -95,8 +100,8 @@ mod implementation { use crate::app_interface::dynamic_data::dynamic_library::DynamicLibraryImpl; use crate::app_interface::{ - AbilityImpl, BattleImpl, FormImpl, ItemImpl, LearnedMoveImpl, NatureImpl, SpeciesImpl, - StatisticSetImpl, + AbilityImpl, BattleImpl, EventBatchId, FormImpl, ItemImpl, LearnedMoveImpl, NatureImpl, + SpeciesImpl, StatisticSetImpl, }; use crate::handling::cached_value::CachedValue; use crate::handling::wasm_result::WasmResult; @@ -333,8 +338,23 @@ mod implementation { fn is_fainted(&self) -> PkmnResult { Ok(self.current_health()? == 0) } - fn damage(&self, damage: u32, source: DamageSource) -> PkmnResult<()> { - unsafe { pokemon_damage(self.inner.reference, damage, source).as_res() } + fn damage( + &self, + damage: u32, + source: DamageSource, + evt_batch_id: EventBatchId, + ) -> PkmnResult<()> { + let evt_batch_id = evt_batch_id.as_u64_pair(); + unsafe { + pokemon_damage( + self.inner.reference, + damage, + source, + evt_batch_id.0, + evt_batch_id.1, + ) + .as_res() + } } fn heal(&self, amount: u32, allow_revive: bool) -> PkmnResult { @@ -608,6 +628,8 @@ mod implementation { r: ExternRef, damage: u32, source: DamageSource, + evt_batch_id_1: u64, + evt_batch_id_2: u64, ) -> WasmResult<()>; fn pokemon_heal( r: ExternRef, @@ -688,7 +710,7 @@ mockall::mock!( fn change_species(&self, species: Species, form: Form); fn change_form(&self, form: Form); fn is_fainted(&self) -> PkmnResult; - fn damage(&self, damage: u32, source: DamageSource) -> PkmnResult<()>; + fn damage(&self, damage: u32, source: DamageSource, evt_batch_id: EventBatchId) -> PkmnResult<()>; fn heal(&self, amount: u32, allow_revive: bool) -> PkmnResult; fn set_weight(&self, weight: f32); fn clear_status(&self);