More FFI work
All checks were successful
continuous-integration/drone/push Build is passing

This commit is contained in:
2023-04-02 14:17:30 +02:00
parent eec85bb9ed
commit d7b3c0cd8d
4 changed files with 101 additions and 19 deletions

View File

@@ -1,5 +1,4 @@
use std::fmt::Debug;
use std::ops::Deref;
use std::sync::Arc;
use crate::dynamic_data::libraries::battle_stat_calculator::BattleStatCalculator;
@@ -19,12 +18,12 @@ pub trait DynamicLibrary: Debug + ValueIdentifiable {
fn static_data(&self) -> &Box<dyn StaticData>;
/// The stat calculator deals with the calculation of flat and boosted stats, based on the
/// Pokemons attributes.
fn stat_calculator(&self) -> &dyn BattleStatCalculator;
fn stat_calculator(&self) -> &Box<dyn BattleStatCalculator>;
/// The damage calculator deals with the calculation of things relating to damage.
fn damage_calculator(&self) -> &dyn DamageLibrary;
fn damage_calculator(&self) -> &Box<dyn DamageLibrary>;
/// The Misc Library holds minor functions that do not fall in any of the other libraries and
/// calculators.
fn misc_library(&self) -> &dyn MiscLibrary;
fn misc_library(&self) -> &Box<dyn MiscLibrary>;
/// Loads a standard script with a given unique combination of category and key. If no script
/// can be created with this combination, returns None.
@@ -88,17 +87,17 @@ impl DynamicLibrary for DynamicLibraryImpl {
}
/// The stat calculator deals with the calculation of flat and boosted stats, based on the
/// Pokemons attributes.
fn stat_calculator(&self) -> &dyn BattleStatCalculator {
self.stat_calculator.deref()
fn stat_calculator(&self) -> &Box<dyn BattleStatCalculator> {
&self.stat_calculator
}
/// The damage calculator deals with the calculation of things relating to damage.
fn damage_calculator(&self) -> &dyn DamageLibrary {
self.damage_calculator.deref()
fn damage_calculator(&self) -> &Box<dyn DamageLibrary> {
&self.damage_calculator
}
/// The Misc Library holds minor functions that do not fall in any of the other libraries and
/// calculators.
fn misc_library(&self) -> &dyn MiscLibrary {
self.misc_library.deref()
fn misc_library(&self) -> &Box<dyn MiscLibrary> {
&self.misc_library
}
/// Loads a standard script with a given unique combination of category and key. If no script
@@ -138,9 +137,9 @@ pub mod test {
pub DynamicLibrary{}
impl DynamicLibrary for DynamicLibrary {
fn static_data(&self) -> &Box<dyn StaticData>;
fn stat_calculator(&self) -> &dyn BattleStatCalculator;
fn damage_calculator(&self) -> &dyn DamageLibrary;
fn misc_library(&self) -> &dyn MiscLibrary;
fn stat_calculator(&self) -> &Box<dyn BattleStatCalculator>;
fn damage_calculator(&self) -> &Box<dyn DamageLibrary>;
fn misc_library(&self) -> &Box<dyn MiscLibrary>;
fn load_script(
&self,
owner: ScriptOwnerData,