Adds effects for changing target stats.

This commit is contained in:
2022-09-10 12:20:48 +02:00
parent a710527975
commit 0f85f4f0a4
8 changed files with 218 additions and 0 deletions

View File

@@ -171,6 +171,13 @@ impl Pokemon {
unsafe { pokemon_heal(self.inner.reference, amount, allow_revive) }
}
#[cfg(not(feature = "mock_data"))]
pub fn set_weight(&self, weight: f32) {
unsafe {
pokemon_set_weight(self.reference(), weight);
}
}
#[cfg(not(feature = "mock_data"))]
pub fn battle_side(&self) -> BattleSide {
self.battle()
@@ -319,6 +326,7 @@ extern "wasm" {
fn pokemon_change_form(r: ExternRef<Pokemon>, form: ExternRef<Form>);
fn pokemon_damage(r: ExternRef<Pokemon>, damage: u32, source: DamageSource);
fn pokemon_heal(r: ExternRef<Pokemon>, amount: u32, allow_revive: bool) -> bool;
fn pokemon_set_weight(r: ExternRef<Pokemon>, weight: f32);
fn pokemon_add_volatile_by_name(r: ExternRef<Pokemon>, name: *const c_char) -> ScriptPtr;
fn pokemon_add_volatile(r: ExternRef<Pokemon>, script: ScriptPtr) -> ScriptPtr;

View File

@@ -35,6 +35,35 @@ impl EffectParameter {
}
}
}
pub fn as_bool(&self) -> bool {
if let EffectParameter::Bool(b) = self {
return *b;
}
panic!("Unexpected effect parameter type: {}", self);
}
pub fn as_int(&self) -> i64 {
if let EffectParameter::Int(i) = self {
return *i;
}
panic!("Unexpected effect parameter type: {}", self);
}
pub fn as_float(&self) -> f32 {
if let EffectParameter::Float(f) = self {
return *f;
}
panic!("Unexpected effect parameter type: {}", self);
}
pub fn as_string(&self) -> StringKey {
if let EffectParameter::String(s) = self {
return s.clone();
}
panic!("Unexpected effect parameter type: {}", self);
}
}
#[cfg(not(feature = "mock_data"))]