Implements new event batch id
continuous-integration/drone/push Build is passing
Details
continuous-integration/drone/push Build is passing
Details
This commit is contained in:
parent
5e0bd632b9
commit
12cd2ef33e
|
@ -55,7 +55,8 @@ impl Script for Struggle {
|
||||||
if damage == 0 {
|
if damage == 0 {
|
||||||
damage = 1
|
damage = 1
|
||||||
}
|
}
|
||||||
mv.user().damage(damage, DamageSource::Struggle)?;
|
mv.user()
|
||||||
|
.damage(damage, DamageSource::Struggle, Default::default())?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -15,4 +15,5 @@ paste = { version = "1.0.7" }
|
||||||
hashbrown = { version = "0.13.2" }
|
hashbrown = { version = "0.13.2" }
|
||||||
dlmalloc = { version = "0.2.4", features = ["global"] }
|
dlmalloc = { version = "0.2.4", features = ["global"] }
|
||||||
mockall = { version = "0.11.2", optional = true, features = ["nightly"] }
|
mockall = { version = "0.11.2", optional = true, features = ["nightly"] }
|
||||||
num-traits = { version = "0.2", default-features = false }
|
num-traits = { version = "0.2", default-features = false }
|
||||||
|
uuid = { version = "1.3.4", default-features = false }
|
|
@ -25,3 +25,20 @@ pub use pokemon::*;
|
||||||
pub use statistic_set::*;
|
pub use statistic_set::*;
|
||||||
pub use turn_choices::*;
|
pub use turn_choices::*;
|
||||||
pub use with_volatile::*;
|
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),
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
use crate::app_interface::{
|
use crate::app_interface::{
|
||||||
Ability, AbilityIndex, Battle, BattleSide, ClampedStatisticSet, DynamicLibrary, Form, Gender,
|
Ability, AbilityIndex, Battle, BattleSide, ClampedStatisticSet, DynamicLibrary, EventBatchId,
|
||||||
Item, LearnedMove, LevelInt, Nature, Species, Statistic, StatisticSet, TypeIdentifier,
|
Form, Gender, Item, LearnedMove, LevelInt, Nature, Species, Statistic, StatisticSet,
|
||||||
WithVolatile,
|
TypeIdentifier, WithVolatile,
|
||||||
};
|
};
|
||||||
use crate::handling::Script;
|
use crate::handling::Script;
|
||||||
use alloc::boxed::Box;
|
use alloc::boxed::Box;
|
||||||
|
@ -65,7 +65,12 @@ pub trait PokemonTrait: WithVolatile {
|
||||||
fn change_species(&self, species: Species, form: Form);
|
fn change_species(&self, species: Species, form: Form);
|
||||||
fn change_form(&self, form: Form);
|
fn change_form(&self, form: Form);
|
||||||
fn is_fainted(&self) -> PkmnResult<bool>;
|
fn is_fainted(&self) -> PkmnResult<bool>;
|
||||||
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<bool>;
|
fn heal(&self, amount: u32, allow_revive: bool) -> PkmnResult<bool>;
|
||||||
fn set_weight(&self, weight: f32);
|
fn set_weight(&self, weight: f32);
|
||||||
fn clear_status(&self);
|
fn clear_status(&self);
|
||||||
|
@ -95,8 +100,8 @@ mod implementation {
|
||||||
|
|
||||||
use crate::app_interface::dynamic_data::dynamic_library::DynamicLibraryImpl;
|
use crate::app_interface::dynamic_data::dynamic_library::DynamicLibraryImpl;
|
||||||
use crate::app_interface::{
|
use crate::app_interface::{
|
||||||
AbilityImpl, BattleImpl, FormImpl, ItemImpl, LearnedMoveImpl, NatureImpl, SpeciesImpl,
|
AbilityImpl, BattleImpl, EventBatchId, FormImpl, ItemImpl, LearnedMoveImpl, NatureImpl,
|
||||||
StatisticSetImpl,
|
SpeciesImpl, StatisticSetImpl,
|
||||||
};
|
};
|
||||||
use crate::handling::cached_value::CachedValue;
|
use crate::handling::cached_value::CachedValue;
|
||||||
use crate::handling::wasm_result::WasmResult;
|
use crate::handling::wasm_result::WasmResult;
|
||||||
|
@ -333,8 +338,23 @@ mod implementation {
|
||||||
fn is_fainted(&self) -> PkmnResult<bool> {
|
fn is_fainted(&self) -> PkmnResult<bool> {
|
||||||
Ok(self.current_health()? == 0)
|
Ok(self.current_health()? == 0)
|
||||||
}
|
}
|
||||||
fn damage(&self, damage: u32, source: DamageSource) -> PkmnResult<()> {
|
fn damage(
|
||||||
unsafe { pokemon_damage(self.inner.reference, damage, source).as_res() }
|
&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<bool> {
|
fn heal(&self, amount: u32, allow_revive: bool) -> PkmnResult<bool> {
|
||||||
|
@ -608,6 +628,8 @@ mod implementation {
|
||||||
r: ExternRef<PokemonImpl>,
|
r: ExternRef<PokemonImpl>,
|
||||||
damage: u32,
|
damage: u32,
|
||||||
source: DamageSource,
|
source: DamageSource,
|
||||||
|
evt_batch_id_1: u64,
|
||||||
|
evt_batch_id_2: u64,
|
||||||
) -> WasmResult<()>;
|
) -> WasmResult<()>;
|
||||||
fn pokemon_heal(
|
fn pokemon_heal(
|
||||||
r: ExternRef<PokemonImpl>,
|
r: ExternRef<PokemonImpl>,
|
||||||
|
@ -688,7 +710,7 @@ mockall::mock!(
|
||||||
fn change_species(&self, species: Species, form: Form);
|
fn change_species(&self, species: Species, form: Form);
|
||||||
fn change_form(&self, form: Form);
|
fn change_form(&self, form: Form);
|
||||||
fn is_fainted(&self) -> PkmnResult<bool>;
|
fn is_fainted(&self) -> PkmnResult<bool>;
|
||||||
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<bool>;
|
fn heal(&self, amount: u32, allow_revive: bool) -> PkmnResult<bool>;
|
||||||
fn set_weight(&self, weight: f32);
|
fn set_weight(&self, weight: f32);
|
||||||
fn clear_status(&self);
|
fn clear_status(&self);
|
||||||
|
|
Loading…
Reference in New Issue