This commit is contained in:
@@ -6,6 +6,7 @@ use crate::StringKey;
|
||||
/// A unique key that can be used to store a reference to a type. Opaque reference to a byte
|
||||
/// internally.
|
||||
#[derive(Debug, Copy, Clone, Eq, PartialEq, Default, Hash, Atom)]
|
||||
#[repr(C)]
|
||||
pub struct TypeIdentifier {
|
||||
/// The unique internal value.
|
||||
val: u8,
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
use crate::StringKey;
|
||||
#[doc(inline)]
|
||||
pub use growth_rates::*;
|
||||
#[doc(inline)]
|
||||
@@ -14,6 +15,7 @@ pub use species_data::*;
|
||||
pub use statistic_set::*;
|
||||
#[doc(inline)]
|
||||
pub use statistics::*;
|
||||
use std::fmt::{Display, Formatter};
|
||||
|
||||
/// Growth rates define how fast a Pokemon can level up.
|
||||
mod growth_rates;
|
||||
@@ -31,3 +33,29 @@ mod species_data;
|
||||
mod statistic_set;
|
||||
/// Statistics are numerical values on Pokemon that are used in battle.
|
||||
mod statistics;
|
||||
|
||||
/// A parameter for an effect. This is basically a simple way to dynamically store multiple different
|
||||
/// primitives on data.
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
|
||||
pub enum EffectParameter {
|
||||
/// A boolean value.
|
||||
Bool(bool),
|
||||
/// An integer value. Stored as a 64 bit int to deal with potentially large numbers.
|
||||
Int(i64),
|
||||
/// A float value. Stored as a 32 bit float.
|
||||
Float(f32),
|
||||
/// A string value.
|
||||
String(StringKey),
|
||||
}
|
||||
|
||||
impl Display for EffectParameter {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
EffectParameter::Bool(v) => f.write_fmt(format_args!("EffectParameter::Bool({})", v)),
|
||||
EffectParameter::Int(v) => f.write_fmt(format_args!("EffectParameter::Int({})", v)),
|
||||
EffectParameter::Float(v) => f.write_fmt(format_args!("EffectParameter::Float({})", v)),
|
||||
EffectParameter::String(v) => f.write_fmt(format_args!("EffectParameter::String({})", v)),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,6 +9,7 @@ use crate::StringKey;
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
|
||||
#[repr(u8)]
|
||||
pub enum MoveCategory {
|
||||
/// A physical move uses the physical attack stats and physical defense stats to calculate damage.
|
||||
Physical = 0,
|
||||
@@ -21,6 +22,7 @@ pub enum MoveCategory {
|
||||
/// The move target defines what kind of targets the move can touch.
|
||||
#[derive(Copy, Clone, PartialEq, Eq, Debug, Default)]
|
||||
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
||||
#[repr(u8)]
|
||||
pub enum MoveTarget {
|
||||
/// Adjacent allows a move to target any Pokemon that is either directly to the left or right of
|
||||
/// the user, opposed to the user, or left or right of the slot that is opposing the user.
|
||||
|
||||
@@ -1,20 +1,6 @@
|
||||
use crate::static_data::EffectParameter;
|
||||
use crate::StringKey;
|
||||
|
||||
/// A parameter for an effect. This is basically a simple way to dynamically store multiple different
|
||||
/// primitives on data.
|
||||
#[derive(PartialEq, Debug)]
|
||||
#[cfg_attr(feature = "wasm", derive(unique_type_id_derive::UniqueTypeId))]
|
||||
pub enum EffectParameter {
|
||||
/// A boolean value.
|
||||
Bool(bool),
|
||||
/// An integer value. Stored as a 64 bit int to deal with potentially large numbers.
|
||||
Int(i64),
|
||||
/// A float value. Stored as a 32 bit float.
|
||||
Float(f32),
|
||||
/// A string value.
|
||||
String(StringKey),
|
||||
}
|
||||
|
||||
/// A secondary effect is an effect on a move that happens after it hits.
|
||||
#[derive(PartialEq, Debug)]
|
||||
pub struct SecondaryEffect {
|
||||
|
||||
@@ -48,9 +48,9 @@ impl Nature {
|
||||
/// Calculates the modifier for a given stat. If it's the increased stat, returns the increased
|
||||
/// modifier, if it's the decreased stat, returns the decreased modifier. Otherwise returns 1.0
|
||||
pub fn get_stat_modifier(&self, stat: Statistic) -> f32 {
|
||||
if stat == self.increase_stat {
|
||||
if stat == self.increase_stat && stat != self.decrease_stat {
|
||||
self.increase_modifier
|
||||
} else if stat == self.decrease_stat {
|
||||
} else if stat == self.decrease_stat && stat != self.increase_stat {
|
||||
self.decrease_modifier
|
||||
} else {
|
||||
1.0
|
||||
|
||||
Reference in New Issue
Block a user