Initial work on adding documentation, reorganises modules
All checks were successful
continuous-integration/drone/push Build is passing
All checks were successful
continuous-integration/drone/push Build is passing
This commit is contained in:
@@ -1,12 +1,20 @@
|
||||
use crate::dynamic_data::script_handling::script::{Script, ScriptContainer};
|
||||
use crate::dynamic_data::script_handling::script_set::ScriptSet;
|
||||
use parking_lot::RwLock;
|
||||
use std::sync::{Arc, Weak};
|
||||
|
||||
pub mod item_script;
|
||||
pub mod script;
|
||||
pub mod script_set;
|
||||
pub mod volatile_scripts;
|
||||
use parking_lot::RwLock;
|
||||
|
||||
#[doc(inline)]
|
||||
pub use item_script::*;
|
||||
#[doc(inline)]
|
||||
pub use script::*;
|
||||
#[doc(inline)]
|
||||
pub use script_set::*;
|
||||
#[doc(inline)]
|
||||
pub use volatile_scripts::*;
|
||||
|
||||
mod item_script;
|
||||
mod script;
|
||||
mod script_set;
|
||||
mod volatile_scripts;
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! script_hook {
|
||||
@@ -25,21 +33,6 @@ macro_rules! script_hook {
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! script_hook_on_lock {
|
||||
($hook_name: ident, $source: ident, $($parameters: expr),*) => {
|
||||
let mut aggregator = $source.read().get_script_iterator();
|
||||
while let Some(script) = aggregator.get_next() {
|
||||
let lock = &mut script.get().read();
|
||||
let script = lock.as_mut().unwrap();
|
||||
if script.is_suppressed() {
|
||||
continue;
|
||||
}
|
||||
script.$hook_name($($parameters),*);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
#[macro_export]
|
||||
macro_rules! run_scripts {
|
||||
($hook_name: ident, $source: ident, $($parameters: expr),*) => {
|
||||
@@ -198,12 +191,14 @@ impl ScriptAggregator {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::any::Any;
|
||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
|
||||
use crate::dynamic_data::script_handling::script::ScriptContainer;
|
||||
use crate::static_data::EffectParameter;
|
||||
use crate::StringKey;
|
||||
use std::any::Any;
|
||||
use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
|
||||
use super::*;
|
||||
|
||||
pub struct TestScript {
|
||||
name: StringKey,
|
||||
|
||||
@@ -1,12 +1,3 @@
|
||||
use crate::dynamic_data::choices::{MoveChoice, TurnChoice};
|
||||
use crate::dynamic_data::models::battle::Battle;
|
||||
use crate::dynamic_data::models::damage_source::DamageSource;
|
||||
use crate::dynamic_data::models::executing_move::ExecutingMove;
|
||||
use crate::dynamic_data::models::pokemon::Pokemon;
|
||||
use crate::static_data::moves::secondary_effect::EffectParameter;
|
||||
use crate::static_data::{Item, Statistic};
|
||||
use crate::StringKey;
|
||||
use parking_lot::{MappedRwLockReadGuard, RwLock, RwLockReadGuard};
|
||||
use std::any::Any;
|
||||
use std::fmt::{Debug, Formatter};
|
||||
use std::ops::Deref;
|
||||
@@ -14,6 +5,17 @@ use std::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
|
||||
use std::sync::Arc;
|
||||
use std::thread::JoinHandle;
|
||||
|
||||
use parking_lot::{MappedRwLockReadGuard, RwLock, RwLockReadGuard};
|
||||
|
||||
use crate::dynamic_data::choices::{MoveChoice, TurnChoice};
|
||||
use crate::dynamic_data::Battle;
|
||||
use crate::dynamic_data::DamageSource;
|
||||
use crate::dynamic_data::ExecutingMove;
|
||||
use crate::dynamic_data::Pokemon;
|
||||
use crate::static_data::EffectParameter;
|
||||
use crate::static_data::{Item, Statistic};
|
||||
use crate::StringKey;
|
||||
|
||||
pub trait Script: Send + Sync {
|
||||
fn name(&self) -> &StringKey;
|
||||
fn get_marked_for_deletion(&self) -> &AtomicBool;
|
||||
@@ -231,9 +233,10 @@ impl Clone for ScriptContainer {
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use std::sync::atomic::{AtomicBool, AtomicPtr};
|
||||
|
||||
use super::*;
|
||||
|
||||
pub struct TestScript {
|
||||
name: StringKey,
|
||||
container: AtomicPtr<ScriptContainer>,
|
||||
|
||||
Reference in New Issue
Block a user