Simplify WASM interface for static_statistic_set
continuous-integration/drone/push Build is passing Details

This commit is contained in:
Deukhoofd 2023-01-14 12:09:08 +01:00
parent fb98798046
commit 44a169cba7
Signed by: Deukhoofd
GPG Key ID: F63E044490819F6F
2 changed files with 16 additions and 15 deletions

View File

@ -3,7 +3,7 @@ use alloc::boxed::Box;
use core::any::Any;
use core::sync::atomic::{AtomicBool, Ordering};
use pkmn_lib_interface::app_interface::{
BattleSide, DamageSource, ExecutingMove, Pokemon, TurnChoice,
get_volatile_as, BattleSide, DamageSource, ExecutingMove, Pokemon, TurnChoice,
};
use pkmn_lib_interface::handling::{Script, ScriptCapabilities};
@ -48,7 +48,7 @@ impl Script for Assurance {
_hit: u8,
base_power: &mut u8,
) {
if let Some(s) = pkmn_lib_interface::app_interface::get_volatile_as::<AssuranceData>(
if let Some(s) = get_volatile_as::<AssuranceData>(
target.battle_side().as_ref(),
AssuranceData::get_const_name(),
) {

View File

@ -56,16 +56,22 @@ mod implementation {
Self::from_ref(reference, &|reference| Self {
inner: Rc::new(ImmutableStatisticSetInner {
reference,
hp: cached_value!({ static_statistics_set_get_hp(reference) }),
attack: cached_value!({ static_statistics_set_get_attack(reference) }),
defense: cached_value!({ static_statistics_set_get_defense(reference) }),
hp: cached_value!({ static_statistics_set_get_stat(reference, Statistic::HP) }),
attack: cached_value!({
static_statistics_set_get_stat(reference, Statistic::Attack)
}),
defense: cached_value!({
static_statistics_set_get_stat(reference, Statistic::Defense)
}),
special_attack: cached_value!({
static_statistics_set_get_special_attack(reference)
static_statistics_set_get_stat(reference, Statistic::SpecialAttack)
}),
special_defense: cached_value!({
static_statistics_set_get_special_defense(reference)
static_statistics_set_get_stat(reference, Statistic::SpecialDefense)
}),
speed: cached_value!({
static_statistics_set_get_stat(reference, Statistic::Speed)
}),
speed: cached_value!({ static_statistics_set_get_speed(reference) }),
}),
})
}
@ -101,15 +107,10 @@ mod implementation {
crate::handling::cacheable::cacheable!(ImmutableStatisticSetImpl);
extern "wasm" {
fn static_statistics_set_get_hp(r: ExternRef<ImmutableStatisticSetImpl>) -> u16;
fn static_statistics_set_get_attack(r: ExternRef<ImmutableStatisticSetImpl>) -> u16;
fn static_statistics_set_get_defense(r: ExternRef<ImmutableStatisticSetImpl>) -> u16;
fn static_statistics_set_get_special_attack(r: ExternRef<ImmutableStatisticSetImpl>)
-> u16;
fn static_statistics_set_get_special_defense(
fn static_statistics_set_get_stat(
r: ExternRef<ImmutableStatisticSetImpl>,
stat: Statistic,
) -> u16;
fn static_statistics_set_get_speed(r: ExternRef<ImmutableStatisticSetImpl>) -> u16;
}
}
#[cfg(not(feature = "mock_data"))]