2022-06-11 18:51:37 +00:00
|
|
|
use crate::static_data::SecondaryEffect;
|
2022-06-11 15:22:46 +00:00
|
|
|
use crate::StringKey;
|
2022-06-16 15:59:33 +00:00
|
|
|
use hashbrown::HashSet;
|
|
|
|
|
|
|
|
#[cfg(feature = "serde")]
|
|
|
|
use serde::{Deserialize, Serialize};
|
2021-01-30 21:29:59 +00:00
|
|
|
|
2022-06-14 17:11:24 +00:00
|
|
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
2022-06-16 15:59:33 +00:00
|
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
|
|
|
#[cfg_attr(feature = "serde", serde(rename_all = "snake_case"))]
|
2021-01-30 21:29:59 +00:00
|
|
|
pub enum MoveCategory {
|
2022-06-14 17:11:24 +00:00
|
|
|
Physical = 0,
|
|
|
|
Special = 1,
|
|
|
|
Status = 2,
|
2021-01-30 21:29:59 +00:00
|
|
|
}
|
|
|
|
|
2022-06-14 17:11:24 +00:00
|
|
|
#[derive(Copy, Clone, PartialEq, Debug)]
|
2022-06-16 15:59:33 +00:00
|
|
|
#[cfg_attr(feature = "serde", derive(Serialize, Deserialize))]
|
2021-01-30 21:29:59 +00:00
|
|
|
pub enum MoveTarget {
|
2022-06-14 17:11:24 +00:00
|
|
|
Adjacent = 0,
|
2021-01-30 21:29:59 +00:00
|
|
|
AdjacentAlly,
|
|
|
|
AdjacentAllySelf,
|
|
|
|
AdjacentOpponent,
|
|
|
|
|
|
|
|
All,
|
|
|
|
AllAdjacent,
|
|
|
|
AllAdjacentOpponent,
|
|
|
|
AllAlly,
|
|
|
|
AllOpponent,
|
|
|
|
|
|
|
|
Any,
|
|
|
|
|
|
|
|
RandomOpponent,
|
2022-06-16 15:59:33 +00:00
|
|
|
#[cfg_attr(feature = "serde", serde(rename = "Self"))]
|
2021-01-30 21:29:59 +00:00
|
|
|
SelfUse,
|
|
|
|
}
|
|
|
|
|
|
|
|
#[derive(PartialEq, Debug)]
|
|
|
|
pub struct MoveData {
|
2022-06-11 15:22:46 +00:00
|
|
|
name: StringKey,
|
2021-01-30 21:29:59 +00:00
|
|
|
move_type: u8,
|
|
|
|
category: MoveCategory,
|
|
|
|
base_power: u8,
|
|
|
|
accuracy: u8,
|
|
|
|
base_usages: u8,
|
|
|
|
target: MoveTarget,
|
|
|
|
priority: i8,
|
|
|
|
secondary_effect: SecondaryEffect,
|
2022-06-16 15:59:33 +00:00
|
|
|
flags: HashSet<StringKey>,
|
2021-01-30 21:29:59 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
impl MoveData {
|
|
|
|
pub fn new(
|
2022-06-11 15:22:46 +00:00
|
|
|
name: &StringKey,
|
2021-01-30 21:29:59 +00:00
|
|
|
move_type: u8,
|
|
|
|
category: MoveCategory,
|
|
|
|
base_power: u8,
|
|
|
|
accuracy: u8,
|
|
|
|
base_usages: u8,
|
|
|
|
target: MoveTarget,
|
|
|
|
priority: i8,
|
|
|
|
secondary_effect: SecondaryEffect,
|
2022-06-16 15:59:33 +00:00
|
|
|
flags: HashSet<StringKey>,
|
2021-01-30 21:29:59 +00:00
|
|
|
) -> MoveData {
|
|
|
|
MoveData {
|
2022-06-11 15:22:46 +00:00
|
|
|
name: name.clone(),
|
2021-01-30 21:29:59 +00:00
|
|
|
move_type,
|
|
|
|
category,
|
|
|
|
base_power,
|
|
|
|
accuracy,
|
|
|
|
base_usages,
|
|
|
|
target,
|
|
|
|
priority,
|
|
|
|
secondary_effect,
|
|
|
|
flags,
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-06-14 17:11:24 +00:00
|
|
|
pub fn name(&self) -> &StringKey {
|
|
|
|
&self.name
|
|
|
|
}
|
|
|
|
pub fn move_type(&self) -> u8 {
|
|
|
|
self.move_type
|
|
|
|
}
|
|
|
|
pub fn category(&self) -> MoveCategory {
|
|
|
|
self.category
|
|
|
|
}
|
|
|
|
pub fn base_power(&self) -> u8 {
|
|
|
|
self.base_power
|
|
|
|
}
|
|
|
|
pub fn accuracy(&self) -> u8 {
|
|
|
|
self.accuracy
|
|
|
|
}
|
|
|
|
pub fn base_usages(&self) -> u8 {
|
|
|
|
self.base_usages
|
|
|
|
}
|
|
|
|
pub fn target(&self) -> MoveTarget {
|
|
|
|
self.target
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn priority(&self) -> i8 {
|
|
|
|
self.priority
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn secondary_effect(&self) -> &SecondaryEffect {
|
|
|
|
&self.secondary_effect
|
|
|
|
}
|
|
|
|
|
2022-06-16 15:59:33 +00:00
|
|
|
pub fn has_secondary_effect(&self) -> bool {
|
|
|
|
self.secondary_effect.effect_name() != &StringKey::empty()
|
|
|
|
}
|
|
|
|
|
|
|
|
pub fn has_flag(&self, key: &StringKey) -> bool {
|
2021-01-30 21:29:59 +00:00
|
|
|
self.flags.contains(key)
|
|
|
|
}
|
|
|
|
}
|