Initial work on rune as scripting library
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
2024-04-07 18:55:41 +02:00
parent 6379abf446
commit 67b0abe59f
24 changed files with 1186 additions and 739 deletions

View File

@@ -1,5 +1,6 @@
use crate::static_data::Parameter;
use crate::StringKey;
use hashbrown::HashMap;
use std::fmt::Debug;
use std::sync::Arc;
@@ -10,7 +11,7 @@ pub trait Ability: Debug {
/// The name of the script effect of the ability.
fn effect(&self) -> &StringKey;
/// The parameters for the script effect of the ability.
fn parameters(&self) -> &Vec<Arc<Parameter>>;
fn parameters(&self) -> &HashMap<StringKey, Arc<Parameter>>;
}
/// An ability is a passive effect in battle that is attached to a Pokemon.
@@ -21,12 +22,12 @@ pub struct AbilityImpl {
/// The name of the script effect of the ability.
effect: StringKey,
/// The parameters for the script effect of the ability.
parameters: Vec<Arc<Parameter>>,
parameters: HashMap<StringKey, Arc<Parameter>>,
}
impl AbilityImpl {
/// Instantiates a new ability.
pub fn new(name: &StringKey, effect: &StringKey, parameters: Vec<Arc<Parameter>>) -> Self {
pub fn new(name: &StringKey, effect: &StringKey, parameters: HashMap<StringKey, Arc<Parameter>>) -> Self {
Self {
name: name.clone(),
effect: effect.clone(),
@@ -37,17 +38,11 @@ impl AbilityImpl {
impl Ability for AbilityImpl {
/// The name of the ability.
fn name(&self) -> &StringKey {
&self.name
}
fn name(&self) -> &StringKey { &self.name }
/// The name of the script effect of the ability.
fn effect(&self) -> &StringKey {
&self.effect
}
fn effect(&self) -> &StringKey { &self.effect }
/// The parameters for the script effect of the ability.
fn parameters(&self) -> &Vec<Arc<Parameter>> {
&self.parameters
}
fn parameters(&self) -> &HashMap<StringKey, Arc<Parameter>> { &self.parameters }
}
/// An ability index allows us to find an ability on a form. It combines a bool for whether the