This commit is contained in:
@@ -1,9 +1,20 @@
|
||||
use crate::static_data::EffectParameter;
|
||||
use crate::{StringKey, ValueIdentifiable, ValueIdentifier};
|
||||
use std::fmt::Debug;
|
||||
|
||||
/// An ability is a passive effect in battle that is attached to a Pokemon.
|
||||
pub trait Ability: Debug + ValueIdentifiable {
|
||||
/// The name of the ability.
|
||||
fn name(&self) -> &StringKey;
|
||||
/// 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<EffectParameter>;
|
||||
}
|
||||
|
||||
/// An ability is a passive effect in battle that is attached to a Pokemon.
|
||||
#[derive(Debug)]
|
||||
pub struct Ability {
|
||||
pub struct AbilityImpl {
|
||||
/// A unique identifier so we know what value this is.
|
||||
identifier: ValueIdentifier,
|
||||
/// The name of the ability.
|
||||
@@ -14,7 +25,7 @@ pub struct Ability {
|
||||
parameters: Vec<EffectParameter>,
|
||||
}
|
||||
|
||||
impl Ability {
|
||||
impl AbilityImpl {
|
||||
/// Instantiates a new ability.
|
||||
pub fn new(name: &StringKey, effect: &StringKey, parameters: Vec<EffectParameter>) -> Self {
|
||||
Self {
|
||||
@@ -24,22 +35,24 @@ impl Ability {
|
||||
parameters,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl Ability for AbilityImpl {
|
||||
/// The name of the ability.
|
||||
pub fn name(&self) -> &StringKey {
|
||||
fn name(&self) -> &StringKey {
|
||||
&self.name
|
||||
}
|
||||
/// The name of the script effect of the ability.
|
||||
pub fn effect(&self) -> &StringKey {
|
||||
fn effect(&self) -> &StringKey {
|
||||
&self.effect
|
||||
}
|
||||
/// The parameters for the script effect of the ability.
|
||||
pub fn parameters(&self) -> &Vec<EffectParameter> {
|
||||
fn parameters(&self) -> &Vec<EffectParameter> {
|
||||
&self.parameters
|
||||
}
|
||||
}
|
||||
|
||||
impl ValueIdentifiable for Ability {
|
||||
impl ValueIdentifiable for AbilityImpl {
|
||||
fn value_identifier(&self) -> ValueIdentifier {
|
||||
self.identifier
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user