Files
PkmnLib_rs/src/script_implementations/rune/wrappers/static_data/nature.rs
Deukhoofd 4ec07ca049
Some checks failed
continuous-integration/drone/push Build is failing
Large amounts of work on Rune
2024-05-08 15:46:09 +02:00

37 lines
1.1 KiB
Rust

use crate::script_implementations::rune::wrappers::impl_rune_wrapper;
use crate::static_data::{Nature, Statistic};
use rune::Any;
use std::sync::Arc;
pub fn register(module: &mut rune::Module) -> anyhow::Result<()> {
module.ty::<RuneNature>()?;
module.function_meta(RuneNature::increased_stat)?;
module.function_meta(RuneNature::decreased_stat)?;
module.function_meta(RuneNature::increased_modifier)?;
module.function_meta(RuneNature::decreased_modifier)?;
module.function_meta(RuneNature::get_stat_modifier)?;
Ok(())
}
#[derive(Debug, Any)]
pub struct RuneNature(pub Arc<dyn Nature>);
impl_rune_wrapper!(&Arc<dyn Nature>, RuneNature);
impl RuneNature {
#[rune::function]
fn increased_stat(&self) -> Statistic { self.0.increased_stat() }
#[rune::function]
fn decreased_stat(&self) -> Statistic { self.0.decreased_stat() }
#[rune::function]
fn increased_modifier(&self) -> f32 { self.0.increased_modifier() }
#[rune::function]
fn decreased_modifier(&self) -> f32 { self.0.decreased_modifier() }
#[rune::function]
fn get_stat_modifier(&self, stat: Statistic) -> f32 { self.0.get_stat_modifier(stat) }
}