This commit is contained in:
12
src/script_implementations/rune/wrappers/static_data/mod.rs
Normal file
12
src/script_implementations/rune/wrappers/static_data/mod.rs
Normal file
@@ -0,0 +1,12 @@
|
||||
mod nature;
|
||||
mod statistic_set;
|
||||
|
||||
use crate::static_data::{Statistic, TimeOfDay};
|
||||
|
||||
pub fn register(module: &mut rune::Module) -> anyhow::Result<()> {
|
||||
module.ty::<TimeOfDay>()?;
|
||||
module.ty::<Statistic>()?;
|
||||
statistic_set::register(module)?;
|
||||
nature::register(module)?;
|
||||
Ok(())
|
||||
}
|
||||
@@ -0,0 +1,31 @@
|
||||
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>()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug, Any)]
|
||||
pub struct RuneNature(Arc<dyn Nature>);
|
||||
|
||||
impl_rune_wrapper!(&Arc<dyn Nature>, RuneNature);
|
||||
|
||||
impl RuneNature {
|
||||
#[rune::function]
|
||||
pub fn increased_stat(&self) -> Statistic { self.0.increased_stat() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn decreased_stat(&self) -> Statistic { self.0.decreased_stat() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn increased_modifier(&self) -> f32 { self.0.increased_modifier() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn decreased_modifier(&self) -> f32 { self.0.decreased_modifier() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn get_stat_modifier(&self, stat: Statistic) -> f32 { self.0.get_stat_modifier(stat) }
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
use crate::script_implementations::rune::wrappers::impl_rune_wrapper;
|
||||
use crate::static_data::{StaticStatisticSet, Statistic, StatisticSet};
|
||||
use rune::Any;
|
||||
use std::sync::Arc;
|
||||
|
||||
pub fn register(module: &mut rune::Module) -> anyhow::Result<()> {
|
||||
module.ty::<RuneStatisticSet>()?;
|
||||
module.ty::<RuneStaticStatisticSet>()?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[derive(Debug, Any)]
|
||||
pub struct RuneStatisticSet(Arc<StatisticSet<u32>>);
|
||||
|
||||
impl_rune_wrapper!(&Arc<StatisticSet<u32>>, RuneStatisticSet);
|
||||
impl RuneStatisticSet {
|
||||
#[rune::function]
|
||||
pub fn get(&self, stat: Statistic) -> u32 { self.0.get_stat(stat) }
|
||||
|
||||
#[rune::function]
|
||||
pub fn set(&mut self, stat: Statistic, value: u32) { self.0.set_stat(stat, value) }
|
||||
|
||||
#[rune::function]
|
||||
pub fn hp(&self) -> u32 { self.0.hp() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn attack(&self) -> u32 { self.0.attack() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn defense(&self) -> u32 { self.0.defense() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn special_attack(&self) -> u32 { self.0.special_attack() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn special_defense(&self) -> u32 { self.0.special_defense() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn speed(&self) -> u32 { self.0.speed() }
|
||||
}
|
||||
|
||||
#[derive(Debug, Any)]
|
||||
pub struct RuneStaticStatisticSet(Arc<StaticStatisticSet<u16>>);
|
||||
|
||||
impl_rune_wrapper!(&Arc<StaticStatisticSet<u16>>, RuneStaticStatisticSet);
|
||||
|
||||
impl RuneStaticStatisticSet {
|
||||
#[rune::function]
|
||||
pub fn get(&self, stat: Statistic) -> u16 { self.0.get_stat(stat) }
|
||||
|
||||
#[rune::function]
|
||||
pub fn hp(&self) -> u16 { self.0.hp() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn attack(&self) -> u16 { self.0.attack() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn defense(&self) -> u16 { self.0.defense() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn special_attack(&self) -> u16 { self.0.special_attack() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn special_defense(&self) -> u16 { self.0.special_defense() }
|
||||
|
||||
#[rune::function]
|
||||
pub fn speed(&self) -> u16 { self.0.speed() }
|
||||
}
|
||||
Reference in New Issue
Block a user